]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/winbacula.nsi.in
- Return HARDEOF status from bnet_recv() if bsock NULL rather
[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\bin\cygwin1.dll" 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 bacula that could be running
94     ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
95     ; give it some time to shutdown
96     Sleep 3000
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 c:\windows\system32\msvcr71.dll
108   File ..\..\..\depkgs-win32\pthreads\pthreadVCE.dll
109   File License.txt
110   IfFileExists "$INSTDIR\bin\bacula-fd.conf" newconf 
111   File baculafd\bacula-fd.conf
112   goto do_service
113  newconf:
114   File /oname=bacula-fd.conf.new baculafd\bacula-fd.conf
115        
116   ; If /service was given jump to the service install part
117  do_service:
118   Push "/service"
119   Call ParameterGiven
120   Pop $5
121   StrCmp $5 1 Service
122   
123   ; If silent install and not /service don't ask questions and goto NoService...
124   IfSilent NoService
125
126   ; If already installed as service skip it too
127   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
128   StrCmp $9 "1" NoService  
129
130   ; Install as service?
131   MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to install the Bacula Client as a service (automatically starts with your PC)?" IDNO NoService
132  Service:
133     ExecWait '"$INSTDIR\bin\bacula-fd.exe" /install'
134     StrCpy $9 "1"
135     WriteRegDWORD HKLM "Software\Bacula" "InstalledService" "1"
136  NoService:
137
138   ; Create Start Menu Directory
139   SetShellVarContext all
140   CreateDirectory "$SMPROGRAMS\Bacula"
141   ; If not installed as service create Start Menu link
142   StrCmp $9 "1" Uninstall
143   CreateShortCut "$SMPROGRAMS\Bacula\Start Bacula Client.lnk" "$INSTDIR\bin\bacula-fd.exe" "-c $INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.exe" 0
144
145   Uninstall:
146   ; Write the uninstall keys for Windows & create Start Menu entry
147   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula Client"
148   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
149   WriteUninstaller "$INSTDIR\Uninstall.exe"
150   CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
151
152   ; Create bacula-fd.conf and have the user edit it (skipped if silent)
153   IfSilent NoReminder
154   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
155   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."
156   Exec 'write "$INSTDIR\bin\bacula-fd.conf"'  ; spawn wordpad with the file to be edited
157  NoReminder:
158
159   ; Start the client? (default skipped if silent, use /start to force starting)
160   Push "/start"
161   Call ParameterGiven
162   Pop $8
163   StrCmp $8 "1" Start
164   IfSilent NoStart
165   Call IsNt
166   Pop $R0
167   StrCmp $R0 "false" do_win98
168   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO SetPerms
169   Exec 'net start bacula'
170   Sleep 3000
171  SetPerms:
172   ; set default permissions on config file so it's not world readable
173   Exec 'cmd /C echo Y|cacls "$INSTDIR\bin\bacula-fd.conf" /G SYSTEM:F Administrators:F'
174   goto NoStart 
175  do_win98:
176   File Start.bat
177   File Stop.bat
178   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO NoStart
179  Start:
180   Exec '"$INSTDIR\bin\bacula-fd.exe" -c "$INSTDIR\bin\bacula-fd.conf"'
181   Sleep 3000
182  NoStart:
183 SectionEnd
184
185 Section "Install Console" SecConsole
186   SetOutPath "$INSTDIR\bin"
187   File console\Release\bconsole.exe
188   IfFileExists "$INSTDIR\bin\pthreadVCE.dll" msvcr711
189   File ..\..\..\depkgs-win32\pthreads\pthreadVCE.dll
190  msvcr711:
191   IfFileExists "$INSTDIR\bin\msvcr71.dll" testconf1
192   File c:\windows\system32\msvcr71.dll
193  testconf1:
194   IfFileExists "$INSTDIR\bin\bconsole.conf" newconf 
195   File console\bconsole.conf
196   goto do_next
197  newconf:
198   File /oname=bconsole.conf.new console\bconsole.conf
199  do_next:
200
201   ; Create bconsole.conf and have the user edit it (skipped if silent)
202   IfSilent NoReminder
203   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
204   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."
205   Exec 'write "$INSTDIR\bin\bconsole.conf"'  ; spawn wordpad with the file to be edited
206  NoReminder:
207 SectionEnd
208
209 Section "Install wx-Console" SecWxConsole
210   SetOutPath "$INSTDIR\bin"
211   File wx-console\Release\wx-console.exe
212   IfFileExists "$INSTDIR\bin\pthreadVCE.dll" msvcr712
213   File ..\..\..\depkgs-win32\pthreads\pthreadVCE.dll
214  msvcr712:
215   IfFileExists "$INSTDIR\bin\msvcr71.dll" testconf2
216   File c:\windows\system32\msvcr71.dll
217  testconf2:
218   IfFileExists "$INSTDIR\bin\wx-console.conf" newconf 
219   File wx-console\wx-console.conf
220   goto do_next
221  newconf:
222   File /oname=wx-console.conf.new wx-console\wx-console.conf
223  do_next:
224   ; Create Start Menu entry
225   SetShellVarContext all
226   CreateShortCut "$SMPROGRAMS\Bacula\WX-Console.lnk" "$INSTDIR\bin\wx-console.exe" "-c $INSTDIR\bin\wx-console.conf" "$INSTDIR\bin\wx-console.exe" 0
227
228   ; Create wx-console.conf and have the user edit it (skipped if silent)
229   IfSilent NoReminder
230   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
231   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."
232   Exec 'write "$INSTDIR\bin\wx-console.conf"'  ; spawn wordpad with the file to be edited
233  NoReminder:
234 SectionEnd
235
236
237 Section "Install Documentation" SecDoc
238   SetOutPath "$INSTDIR\doc"
239   CreateDirectory "$INSTDIR\doc"
240   File ..\..\..\docs\manual\bacula\*.html
241   File ..\..\..\docs\manual\bacula\*.png
242   File ..\..\..\docs\manual\bacula\*.css
243   File ..\..\..\docs\manual\bacula.pdf
244   ; Create Start Menu entry
245   SetShellVarContext all
246   CreateShortCut "$SMPROGRAMS\Bacula\Manual.lnk" "$INSTDIR\doc\bacula.pdf"
247 SectionEnd
248
249 ;
250 ; Extra Page descriptions
251 ;
252
253   LangString DESC_SecService ${LANG_ENGLISH} "Install Bacula client on this system."
254   LangString DESC_SecConsole ${LANG_ENGLISH} "Install Console program on this system."
255   LangString DESC_SecWxConsole ${LANG_ENGLISH} "Install graphical console program on this system."
256   LangString DESC_SecDoc ${LANG_ENGLISH} "Install Documentation on this system."
257
258   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
259     !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
260     !insertmacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
261     !insertmacro MUI_DESCRIPTION_TEXT ${SecWxConsole} $(DESC_SecWxConsole)
262     !insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} $(DESC_SecDoc)
263   !insertmacro MUI_FUNCTION_DESCRIPTION_END
264
265
266
267 ; Uninstall section
268
269 UninstallText "This will uninstall the Bacula Client. Hit next to continue."
270
271 Section "Uninstall"
272
273   ; Shutdown any baculum that could be running
274   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
275
276   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
277   StrCmp $9 "" NoService
278   ; Remove bacula service
279   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /remove'
280   NoService:
281   
282   ; remove registry keys
283   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
284   DeleteRegKey HKLM "Software\Bacula"
285
286   ; remove start menu items
287   SetShellVarContext all
288   Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
289
290   ; remove files and uninstaller (preserving config for now)
291   CopyFiles /SILENT "$INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bacula-fd.conf"
292   IfFileExists "$INSTDIR\bin\bconsole.conf" save_bconsole nosave_bconsole
293   save_bconsole:
294   CopyFiles /SILENT "$INSTDIR\bin\bconsole.conf" "$INSTDIR\bconsole.conf"
295   nosave_bconsole:
296   IfFileExists "$INSTDIR\bin\wx-console.conf" save_wxconsole nosave_wxconsole
297   save_wxconsole:
298   CopyFiles /SILENT "$INSTDIR\bin\wx-console.conf" "$INSTDIR\wx-console.conf"
299   nosave_wxconsole:
300   Delete /REBOOTOK "$INSTDIR\bin\*.*"
301   Delete /REBOOTOK "$INSTDIR\doc\*.*"
302   CopyFiles /SILENT "$INSTDIR\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.conf"
303   CopyFiles /SILENT "$INSTDIR\bconsole.conf" "$INSTDIR\bin\bconsole.conf"
304   CopyFiles /SILENT "$INSTDIR\wx-console.conf" "$INSTDIR\bin\wx-console.conf"
305   Delete /REBOOTOK "$INSTDIR\*.conf"
306   Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
307
308   ; Check for existing installation
309   MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to delete the current configuration files and the working state file?" IDNO LeaveConfig
310   Delete /REBOOTOK "$INSTDIR\bin\*.conf"
311   Delete /REBOOTOK "$INSTDIR\working\*"
312   ; remove directories used
313   RMDir "$INSTDIR\bin"
314   RMDir "$INSTDIR\doc"
315   RMDir "$INSTDIR\working"
316   RMDir "$INSTDIR"
317   RMDir "C:\tmp"
318   LeaveConfig:
319   RMDir "$SMPROGRAMS\Bacula"
320   
321 SectionEnd
322
323 ; eof