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