3 ; written by Michel Meyers (michel@tcnnet.dyndns.org)
6 ; v0.1 - initial release (still a lot to do)
8 ;!define TEMP1 $R0 ;Temp variable
9 !define VERSION '@VERSION@-@LSMDATE@'
12 SetCompressorDictSize 32
14 ; The name of the installer
18 OutFile "winbacula-${VERSION}.exe"
20 ; The default installation directory
21 InstallDir "c:\bacula"
23 DirText "Setup will install the Bacula Client v${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."
26 UninstPage uninstConfirm
29 ;Icon "${NSISDIR}\Contrib\Icons\modern-install.ico"
30 ;UninstallIcon "${NSISDIR}\Contrib\Icons\modern-uninstall.ico"
31 ;CheckBitmap "${NSISDIR}\Contrib\Icons\modern.bmp"
33 ; The text to prompt the user to enter a directory
34 ;ComponentText "This will extract the temporary files needed for controlling your PC remotely."
35 ; The stuff to install
37 ; -- written by Alexis de Valence --
41 ; Push 3 ; to get the 3rd parameter of the command line
42 ; Call GetONEParameter
43 ; Pop $R0 ; saves the result in $R0
44 ; returns an empty string if not found
46 Function GetONEParameter
61 loop3: ; looking for a char that's not a space
63 StrCpy $R0 $CMDLINE 1 $R2
65 StrCpy $R3 $R2 ; found the begining of the current parameter
68 loop: ; scanning for the end of the current parameter
70 StrCpy $R0 $CMDLINE 1 $R2
76 last: ; there will be no other parameter to extract
79 loop2: ; found the end of the current parameter
81 IntCmp $R4 $R5 0 NextParam end
82 StrCpy $R6 1 ; to quit after this process
84 IntOp $R1 $R2 - $R3 ;number of letter of current parameter
85 StrCpy $R0 $CMDLINE $R1 $R3 ; stores the result in R0
88 IntCmp $R6 1 end ; leave if found or if not enough parameters
90 ; process the next parameter
97 Pop $R6 ; restore R0 - R6 to their initial value
104 Exch $R0 ;Puts the result on the stack
108 ; -- written by Michel Meyers --
109 ; ParameterGiven - checks first 9 parameters on the command line
111 ; Push "/parameter" ; to check command line for /parameter
112 ; Call ParameterGiven
113 ; Pop $R0 ; saves the result in $R0 (result = true or false)
115 Function ParameterGiven
124 StrCmp $R1 9 AllChecked
128 Pop $R2 ; saves the result in $R2
143 ; /cygwin on command line forces install dir to c:\cygwin\bacula (useful for silent install)
148 StrCpy $INSTDIR "c:\cygwin\bacula"
151 ; Check for existing installation
153 IfFileExists "$INSTDIR\bin\bacula-fd.conf" Upgrade NoUpgrade
156 ; Shutdown any baculas that could be running
157 ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
160 ; Set output path to the installation directory.
161 SetOutPath "$INSTDIR\bin"
162 CreateDirectory "$INSTDIR"
163 CreateDirectory "$INSTDIR\bin"
164 CreateDirectory "$INSTDIR\working"
165 CreateDirectory "c:\tmp"
167 File baculafd\Release\bacula-fd.exe
168 File pthreads\pthreadVCE.dll
169 IfFileExists "$INSTDIR\bacula-fd.conf" newconf
173 File /oname=bacula-fd.conf.new bacula-fd.conf
176 ; If /service was given jump to the service install part
183 ; If silent install and not /service don't ask questions and goto NoService...
186 ; If already installed as service skip it too
187 ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
188 StrCmp $9 "1" NoService
190 ; Install as service?
191 MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to install the Bacula Client as a service (automatically starts with your PC)?" IDNO NoService
193 ExecWait '"$INSTDIR\bin\bacula-fd.exe" /install'
195 WriteRegDWORD HKLM "Software\Bacula" "InstalledService" "1"
198 ; Write the uninstall keys for Windows
199 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula Client"
200 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
201 SetOutPath "$INSTDIR"
202 WriteUninstaller "uninstall.exe"
204 ; Create bacula-fd.conf and have the user edit it (skipped if silent)
206 StrCmp $7 "1" NoReminder ; skip if it is an upgrade
207 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."
208 CopyFiles /SILENT "$INSTDIR\bin\bacula-fd.conf.new" "$INSTDIR\bin\bacula-fd.conf"
209 Exec 'write "$INSTDIR\bin\bacula-fd.conf"' ; spawn wordpad with the file to be edited
212 ; Start the client? (default skipped if silent, use /start to force starting)
218 MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to start the Bacula Client now?" IDNO NoStart
220 Exec '"$INSTDIR\bin\bacula-fd.exe" -c "$INSTDIR\bin\bacula-fd.conf"'
228 UninstallText "This will uninstall the Bacula Client. Hit next to continue."
232 ; Shutdown any baculas that could be running
233 ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
235 ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
236 StrCmp $9 "" NoService
237 ; Remove bacula service
238 ExecWait '"$INSTDIR\bin\bacula-fd.exe" /remove'
241 ; remove registry keys
242 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
243 DeleteRegKey HKLM "Software\Bacula"
245 ; remove files and uninstaller (preserving config for now)
246 CopyFiles /SILENT "$INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bacula-fd.conf"
247 Delete /REBOOTOK "$INSTDIR\bin\*.*"
248 CopyFiles /SILENT "$INSTDIR\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.conf"
249 Delete /REBOOTOK "$INSTDIR\bacula-fd.conf"
250 Delete /REBOOTOK "$INSTDIR\uninstall.exe"
252 ; Check for existing installation
253 MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to delete the current configuration file ($INSTDIR\bin\bacula-fd.conf)?" IDNO LeaveConfig
254 Delete /REBOOTOK "$INSTDIR\bin\bacula-fd.conf"
255 ; remove directories used
257 RMDir "$INSTDIR\working"
262 ; If we need to reboot we'll ask
263 IfRebootFlag Reboot Continue
265 MessageBox MB_YESNO|MB_ICONQUESTION "Some files will only be deleted after restarting. Reboot now?" IDNO Continue