]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/winbacula.nsi.in
349e2e54ceb0aac17276f045c28170aeb00fa630
[bacula/bacula] / bacula / src / win32 / winbacula.nsi.in
1 ; winbacula.nsi
2 ;
3 ; Written by Michel Meyers (michel@tcnnet.dyndns.org)
4 ;
5 ; Updated by Kern Sibbald for native Win32 Bacula
6 ;    added a number of elements from Christopher Hull's installer
7 ;
8 ; D. Scott Barninger Nov 13 2004
9 ; added configuration editing for bconsole.conf and wx-console.conf
10 ; better explanation in dialog boxes for editing config files
11 ; added Start Menu items
12 ; fix uninstall of config files to do all not just bacula-fd.conf
13 ;
14 ; D. Scott Barninger Dec 05 2004
15 ; added specification of default permissions for bacula-fd.conf
16 ;   - thanks to Jamie Ffolliott for pointing me at cacls
17 ; added removal of working-dir files if user selects to remove config
18 ; uninstall is now 100% clean
19 ;
20 ; Command line options:
21 ;
22 ; /cygwin     -  do cygwin install into c:\cygwin\bacula
23 ; /service    - 
24 ; /start
25
26 !define PRODUCT "Bacula"
27 !define VERSION "@VERSION@"
28
29 ;                           
30 ; Include the Modern UI
31 ;
32 !include "MUI.nsh"
33 !include "params.nsh"
34 !include "util.nsh"
35
36 ;
37 ; Basics
38 ;
39   Name "Bacula Client"
40   OutFile "winbacula-${VERSION}.exe"
41   SetCompressor lzma
42   InstallDir "c:\bacula"
43
44 ;
45 ; Pull in pages
46 ;
47  !insertmacro MUI_PAGE_WELCOME
48 ;  !insertmacro MUI_PAGE_LICENSE "License.txt"
49  !insertmacro MUI_PAGE_COMPONENTS
50  !insertmacro MUI_PAGE_DIRECTORY
51  !insertmacro MUI_PAGE_INSTFILES
52  !insertmacro MUI_PAGE_FINISH
53
54  !insertmacro MUI_UNPAGE_WELCOME
55  !insertmacro MUI_UNPAGE_CONFIRM
56  !insertmacro MUI_UNPAGE_INSTFILES
57  !insertmacro MUI_UNPAGE_FINISH
58
59
60  !define      MUI_ABORTWARNING
61
62  !insertmacro MUI_LANGUAGE "English"
63
64
65
66 DirText "Setup will install the Bacula Client ${VERSION} to the directory specified below. To install in a different folder, click Browse and select another folder.$\n$\nNote to CYGWIN users: please choose your CYGWIN root directory."
67
68
69 Section "Bacula File Service" SecService
70   ;
71   ; /cygwin on command line forces install dir to c:\cygwin\bacula (useful for silent install)
72   ;
73   Push "/cygwin"
74   Call ParameterGiven
75   Pop $6
76   StrCmp $6 0 NoCygwin
77   StrCpy $INSTDIR "c:\cygwin\bacula"
78  NoCygwin:
79 ; IfFileExists "c:\cygwin" Cygwin ReallyNoCygwin
80 ;Cygwin:
81 ; StrCpy $INSTDIR "c:\cygwin\bacula"
82 ;ReallyNoCygwin:
83
84   ; Check for existing installation
85   StrCpy $7 0
86   IfFileExists "$INSTDIR\bin\bacula-fd.conf" Upgrade NoUpgrade
87  Upgrade:
88     StrCpy $7 1
89     ; Shutdown any baculas that could be running
90     ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
91     ; give it some time to shutdown
92     Sleep 1000
93  NoUpgrade:
94
95   ; Set output path to the installation directory.
96   SetOutPath "$INSTDIR\bin"
97   CreateDirectory "$INSTDIR"
98   CreateDirectory "$INSTDIR\bin"
99   CreateDirectory "$INSTDIR\working"
100   CreateDirectory "c:\tmp"
101   ; Put files there
102   File baculafd\Release\bacula-fd.exe
103   File ..\..\..\depkgs-win32\pthreads\pthreadVCE.dll
104   File License.txt
105   IfFileExists "$INSTDIR\bin\bacula-fd.conf" newconf 
106   File baculafd\bacula-fd.conf
107   goto do_service
108  newconf:
109   File /oname=bacula-fd.conf.new baculafd\bacula-fd.conf
110        
111   ; If /service was given jump to the service install part
112  do_service:
113   Push "/service"
114   Call ParameterGiven
115   Pop $5
116   StrCmp $5 1 Service
117   
118   ; If silent install and not /service don't ask questions and goto NoService...
119   IfSilent NoService
120
121   ; If already installed as service skip it too
122   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
123   StrCmp $9 "1" NoService  
124
125   ; Install as service?
126   MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to install the Bacula Client as a service (automatically starts with your PC)?" IDNO NoService
127  Service:
128     ExecWait '"$INSTDIR\bin\bacula-fd.exe" /install'
129     StrCpy $9 "1"
130     WriteRegDWORD HKLM "Software\Bacula" "InstalledService" "1"
131  NoService:
132
133   ; Create Start Menu Directory
134   SetShellVarContext all
135   CreateDirectory "$SMPROGRAMS\Bacula"
136   ; If not installed as service create Start Menu link
137   StrCmp $9 "1" Uninstall
138   CreateShortCut "$SMPROGRAMS\Bacula\Start Bacula Client.lnk" "$INSTDIR\bin\bacula-fd.exe" "-c $INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.exe" 0
139
140   Uninstall:
141   ; Write the uninstall keys for Windows & create Start Menu entry
142   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula Client"
143   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
144   WriteUninstaller "$INSTDIR\Uninstall.exe"
145   CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
146
147   ; Create bacula-fd.conf and have the user edit it (skipped if silent)
148   IfSilent NoReminder
149   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
150   MessageBox MB_OK "Please edit the client configuration file $INSTDIR\bin\bacula-fd.conf to fit your installation. When you click the OK button Wordpad will open to allow you to do this. Be sure to save your changes before closing Wordpad."
151   Exec 'write "$INSTDIR\bin\bacula-fd.conf"'  ; spawn wordpad with the file to be edited
152  NoReminder:
153
154   ; Start the client? (default skipped if silent, use /start to force starting)
155   Push "/start"
156   Call ParameterGiven
157   Pop $8
158   StrCmp $8 "1" Start
159   IfSilent NoStart
160   Call IsNt
161   Pop $R0
162   StrCmp $R0 "false" do_win98
163   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO SetPerms
164   Exec 'net start bacula'
165  SetPerms:
166   ; set default permissions on config file so it's not world readable
167   Exec 'cmd /C echo Y|cacls "$INSTDIR\bin\bacula-fd.conf" /G SYSTEM:F Administrators:F'
168   goto NoStart 
169  do_win98:
170   File Start.bat
171   File Stop.bat
172   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO NoStart
173  Start:
174   Exec '"$INSTDIR\bin\bacula-fd.exe" -c "$INSTDIR\bin\bacula-fd.conf"'
175  NoStart:
176 SectionEnd
177
178 Section "Install Console" SecConsole
179   SetOutPath "$INSTDIR\bin"
180   File console\Release\bconsole.exe
181   IfFileExists "$INSTDIR\bin\bconsole.conf" newconf 
182   File console\bconsole.conf
183   goto do_next
184  newconf:
185   File /oname=bconsole.conf.new console\bconsole.conf
186  do_next:
187
188   ; Create bconsole.conf and have the user edit it (skipped if silent)
189   IfSilent NoReminder
190   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
191   MessageBox MB_OK "Please edit the command line console configuration file $INSTDIR\bin\bconsole.conf to fit your installation. When you click the OK button Wordpad will open to allow you to do this. Be sure to save your changes before closing Wordpad."
192   Exec 'write "$INSTDIR\bin\bconsole.conf"'  ; spawn wordpad with the file to be edited
193  NoReminder:
194 SectionEnd
195
196 Section "Install wx-Console" SecWxConsole
197   SetOutPath "$INSTDIR\bin"
198   File wx-console\Release\wx-console.exe
199   IfFileExists "$INSTDIR\bin\wx-console.conf" newconf 
200   File wx-console\wx-console.conf
201   goto do_next
202  newconf:
203   File /oname=wx-console.conf.new wx-console\wx-console.conf
204  do_next:
205   ; Create Start Menu entry
206   SetShellVarContext all
207   CreateShortCut "$SMPROGRAMS\Bacula\WX-Console.lnk" "$INSTDIR\bin\wx-console.exe" "-c $INSTDIR\bin\wx-console.conf" "$INSTDIR\bin\wx-console.exe" 0
208
209   ; Create wx-console.conf and have the user edit it (skipped if silent)
210   IfSilent NoReminder
211   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
212   MessageBox MB_OK "Please edit the WX-console configuration file $INSTDIR\bin\wx-console.conf to fit your installation. When you click the OK button Wordpad will open to allow you to do this. Be sure to save your changes before closing Wordpad."
213   Exec 'write "$INSTDIR\bin\wx-console.conf"'  ; spawn wordpad with the file to be edited
214  NoReminder:
215 SectionEnd
216
217
218 Section "Install Documentation" SecDoc
219   SetOutPath "$INSTDIR\doc"
220   CreateDirectory "$INSTDIR\doc"
221   File ..\..\doc\html-manual\*.html
222   File ..\..\doc\html-manual\*.gif
223   File ..\..\doc\html-manual\*.jpg
224 SectionEnd
225
226 ;
227 ; Extra Page descriptions
228 ;
229
230   LangString DESC_SecService ${LANG_ENGLISH} "Install Bacula client on this system."
231   LangString DESC_SecConsole ${LANG_ENGLISH} "Install Console program on this system."
232   LangString DESC_SecWxConsole ${LANG_ENGLISH} "Install graphical console program on this system."
233   LangString DESC_SecDoc ${LANG_ENGLISH} "Install Documentation on this system."
234
235   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
236     !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
237     !insertmacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
238     !insertmacro MUI_DESCRIPTION_TEXT ${SecWxConsole} $(DESC_SecWxConsole)
239     !insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} $(DESC_SecDoc)
240   !insertmacro MUI_FUNCTION_DESCRIPTION_END
241
242
243
244 ; Uninstall section
245
246 UninstallText "This will uninstall the Bacula Client. Hit next to continue."
247
248 Section "Uninstall"
249
250   ; Shutdown any baculum that could be running
251   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
252
253   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
254   StrCmp $9 "" NoService
255   ; Remove bacula service
256   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /remove'
257   NoService:
258   
259   ; remove registry keys
260   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
261   DeleteRegKey HKLM "Software\Bacula"
262
263   ; remove start menu items
264   SetShellVarContext all
265   Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
266
267   ; remove files and uninstaller (preserving config for now)
268   CopyFiles /SILENT "$INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bacula-fd.conf"
269   IfFileExists "$INSTDIR\bin\bconsole.conf" save_bconsole nosave_bconsole
270   save_bconsole:
271   CopyFiles /SILENT "$INSTDIR\bin\bconsole.conf" "$INSTDIR\bconsole.conf"
272   nosave_bconsole:
273   IfFileExists "$INSTDIR\bin\wx-console.conf" save_wxconsole nosave_wxconsole
274   save_wxconsole:
275   CopyFiles /SILENT "$INSTDIR\bin\wx-console.conf" "$INSTDIR\wx-console.conf"
276   nosave_wxconsole:
277   Delete /REBOOTOK "$INSTDIR\bin\*.*"
278   Delete /REBOOTOK "$INSTDIR\doc\*.*"
279   CopyFiles /SILENT "$INSTDIR\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.conf"
280   CopyFiles /SILENT "$INSTDIR\bconsole.conf" "$INSTDIR\bin\bconsole.conf"
281   CopyFiles /SILENT "$INSTDIR\wx-console.conf" "$INSTDIR\bin\wx-console.conf"
282   Delete /REBOOTOK "$INSTDIR\*.conf"
283   Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
284
285   ; Check for existing installation
286   MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to delete the current configuration files and the working state file?" IDNO LeaveConfig
287   Delete /REBOOTOK "$INSTDIR\bin\*.conf"
288   Delete /REBOOTOK "$INSTDIR\working\*"
289   ; remove directories used
290   RMDir "$INSTDIR\bin"
291   RMDir "$INSTDIR\doc"
292   RMDir "$INSTDIR\working"
293   RMDir "$INSTDIR"
294   RMDir "C:\tmp"
295   LeaveConfig:
296   RMDir "$SMPROGRAMS\Bacula"
297   
298 SectionEnd
299
300 ; eof