]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/winbacula.nsi.in
Setup production build of wx-console on Win32
[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   ; Write the uninstall keys for Windows
122   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula Client"
123   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
124   WriteUninstaller "$INSTDIR\Uninstall.exe"
125
126   ; Create bacula-fd.conf and have the user edit it (skipped if silent)
127   IfSilent NoReminder
128   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
129   MessageBox MB_OK "Please edit $INSTDIR\bin\bacula-fd.conf according to your requirements/installation! Also remember to put a shortcut into your start menu if you didn't install the client as a service."
130   Exec 'write "$INSTDIR\bin\bacula-fd.conf"'  ; spawn wordpad with the file to be edited
131  NoReminder:
132
133   ; Start the client? (default skipped if silent, use /start to force starting)
134   Push "/start"
135   Call ParameterGiven
136   Pop $8
137   StrCmp $8 "1" Start
138   IfSilent NoStart
139   Call IsNt
140   Pop $R0
141   StrCmp $R0 "false" do_win98
142   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO NoStart
143   Exec 'net start bacula'
144   goto NoStart 
145  do_win98:
146   File Start.bat
147   File Stop.bat
148   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO NoStart
149  Start:
150   Exec '"$INSTDIR\bin\bacula-fd.exe" -c "$INSTDIR\bin\bacula-fd.conf"'
151  NoStart:
152 SectionEnd
153
154 Section "Install Console" SecConsole
155   SetOutPath "$INSTDIR\bin"
156   File console\Release\bconsole.exe
157   IfFileExists "$INSTDIR\bin\bconsole.conf" newconf 
158   File console\bconsole.conf
159   goto do_next
160  newconf:
161   File /oname=bconsole.conf.new console\bconsole.conf
162        
163   ; If /service was given jump to the service install part
164  do_next:
165 SectionEnd
166
167 Section "Install wx-Console" SecWxConsole
168   SetOutPath "$INSTDIR\bin"
169   File wx-console\Release\wx-console.exe
170   IfFileExists "$INSTDIR\bin\wx-console.conf" newconf 
171   File wx-console\wx-console.conf
172   goto do_next
173  newconf:
174   File /oname=wx-console.conf.new wx-console\wx-console.conf
175        
176   ; If /service was given jump to the service install part
177  do_next:
178 SectionEnd
179
180
181 Section "Install Documentation" SecDoc
182   SetOutPath "$INSTDIR\doc"
183   CreateDirectory "$INSTDIR\doc"
184   File ..\..\doc\html-manual\*.html
185   File ..\..\doc\html-manual\*.gif
186   File ..\..\doc\html-manual\*.jpg
187 SectionEnd
188
189 ;
190 ; Extra Page descriptions
191 ;
192
193   LangString DESC_SecService ${LANG_ENGLISH} "Install Bacula client on this system."
194   LangString DESC_SecConsole ${LANG_ENGLISH} "Install Console program on this system."
195   LangString DESC_SecWxConsole ${LANG_ENGLISH} "Install graphical console program on this system."
196   LangString DESC_SecDoc ${LANG_ENGLISH} "Install Documenation on this system."
197
198   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
199     !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
200     !insertmacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
201     !insertmacro MUI_DESCRIPTION_TEXT ${SecWxConsole} $(DESC_SecWxConsole)
202     !insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} $(DESC_SecDoc)
203   !insertmacro MUI_FUNCTION_DESCRIPTION_END
204
205
206
207 ; Uninstall section
208
209 UninstallText "This will uninstall the Bacula Client. Hit next to continue."
210
211 Section "Uninstall"
212
213   ; Shutdown any baculum that could be running
214   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
215
216   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
217   StrCmp $9 "" NoService
218   ; Remove bacula service
219   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /remove'
220   NoService:
221   
222   ; remove registry keys
223   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
224   DeleteRegKey HKLM "Software\Bacula"
225
226   ; remove files and uninstaller (preserving config for now)
227   CopyFiles /SILENT "$INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bacula-fd.conf"
228   Delete /REBOOTOK "$INSTDIR\bin\*.*"
229   Delete /REBOOTOK "$INSTDIR\doc\*.*"
230   CopyFiles /SILENT "$INSTDIR\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.conf"
231   CopyFiles /SILENT "$INSTDIR\bconsole.conf" "$INSTDIR\bin\bconsole.conf"
232   Delete /REBOOTOK "$INSTDIR\bacula-fd.conf"
233   Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
234
235   ; Check for existing installation
236   MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to delete the current configuration file ($INSTDIR\bin\bacula-fd.conf)?" IDNO LeaveConfig
237   Delete /REBOOTOK "$INSTDIR\bin\bacula-fd.conf"
238   ; remove directories used
239   RMDir "$INSTDIR\bin"
240   RMDir "$INSTDIR\doc"
241   RMDir "$INSTDIR\working"
242   RMDir "$INSTDIR"
243   RMDir "C:\tmp"
244   LeaveConfig:
245   
246 SectionEnd
247
248 ; eof