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