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