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