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