3 ; Began as a version written by Michel Meyers (michel@tcnnet.dyndns.org)
5 ; Adapted by Kern Sibbald for native Win32 Bacula
6 ; added a number of elements from Christopher Hull's installer
8 ; D. Scott Barninger Nov 13 2004
9 ; added configuration editing for bconsole.conf and bwx-console.conf
10 ; better explanation in dialog boxes for editing config files
11 ; added Start Menu items
12 ; fix uninstall of config files to do all not just bacula-fd.conf
14 ; D. Scott Barninger Dec 05 2004
15 ; added specification of default permissions for bacula-fd.conf
16 ; - thanks to Jamie Ffolliott for pointing me at cacls
17 ; added removal of working-dir files if user selects to remove config
18 ; uninstall is now 100% clean
20 ; D. Scott Barninger Apr 17 2005
21 ; 1.36.3 release docs update
22 ; add pdf manual and menu shortcut
24 ; Robert Nelson May 15 2006
25 ; Added server installs and implemented Microsoft install locations
27 ; Added Bacula-SD and Bacula-DIR
28 ; Replaced ParameterGiven with standard GetOptions
30 ; Kern Sibbald October 2008
31 ; Remove server installs
32 ; Install into single bacula directory
33 ; (i.e. undo a large part of what Robert Nelson did)
35 ; Eric Bollengier March 2009
36 ; Updated to handle Win64 installation
38 ; Kern Sibbald April 2009
39 ; Correct some Win64 install problems
40 ; It is mind boggling how many lines of this insane scripting language
41 ; have been written with absolutely no comments
43 ; Command line options:
48 ; netsh firewall add portopening protocol=tcp port=9102 name="Bacula-FD"
51 !define PRODUCT "Bacula"
54 ; Include the Modern UI
58 !include "LogicLib.nsh"
59 !include "FileFunc.nsh"
60 !include "Sections.nsh"
61 !include "StrFunc.nsh"
62 !include "WinMessages.nsh"
67 OutFile "${OUT_DIR}\bacula-win${WINVER}-${VERSION}.exe"
70 InstallDir "C:\Program Files\Bacula"
71 InstallDirRegKey HKLM "Software\Bacula" "InstallLocation"
77 !insertmacro GetParent
88 !define MUI_COMPONENTSPAGE_SMALLDESC
90 !define MUI_HEADERIMAGE
91 !define MUI_BGCOLOR 739AB9
92 !define MUI_HEADERIMAGE_BITMAP "bacula-logo.bmp"
94 !InsertMacro MUI_PAGE_WELCOME
95 !InsertMacro MUI_PAGE_LICENSE "..\..\..\LICENSE"
96 Page custom EnterInstallType
97 !define MUI_PAGE_CUSTOMFUNCTION_SHOW PageComponentsShow
98 !InsertMacro MUI_PAGE_COMPONENTS
99 !define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
100 !InsertMacro MUI_PAGE_DIRECTORY
101 Page custom EnterConfigPage1 LeaveConfigPage1
102 Page custom EnterConfigPage2 LeaveConfigPage2
103 !Define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveInstallPage
104 !InsertMacro MUI_PAGE_INSTFILES
105 Page custom EnterWriteTemplates
106 !Define MUI_FINISHPAGE_SHOWREADME $INSTDIR\Readme.txt
107 !InsertMacro MUI_PAGE_FINISH
109 !InsertMacro MUI_UNPAGE_WELCOME
110 !InsertMacro MUI_UNPAGE_CONFIRM
111 !InsertMacro MUI_UNPAGE_INSTFILES
112 !InsertMacro MUI_UNPAGE_FINISH
114 !define MUI_ABORTWARNING
116 !InsertMacro MUI_LANGUAGE "English"
118 !InsertMacro GetParameters
119 !InsertMacro GetOptions
121 DirText "Setup will install Bacula ${VERSION} to the directory specified below. To install in a different folder, click Browse and select another folder."
123 !InsertMacro MUI_RESERVEFILE_INSTALLOPTIONS
139 Var ConfigClientMaxJobs
140 Var ConfigClientPassword
141 Var ConfigClientInstallService
142 Var ConfigClientStartService
144 Var ConfigStorageName
145 Var ConfigStoragePort
146 Var ConfigStorageMaxJobs
147 Var ConfigStoragePassword
148 Var ConfigStorageInstallService
149 Var ConfigStorageStartService
151 Var ConfigDirectorName
152 Var ConfigDirectorPort
153 Var ConfigDirectorMaxJobs
154 Var ConfigDirectorPassword
155 Var ConfigDirectorAddress
156 Var ConfigDirectorMailServer
157 Var ConfigDirectorMailAddress
159 Var ConfigDirectorInstallService
160 Var ConfigDirectorStartService
162 Var ConfigMonitorName
163 Var ConfigMonitorPassword
165 Var LocalDirectorPassword
171 Var PostgreSQLVersion
177 !define UpgradeInstall 1
178 !define MigrateInstall 2
181 Var PreviousComponents
184 ; Bit 0 = File Service
185 ; 1 = Storage Service
186 ; 2 = Director Service
187 ; 3 = Command Console
189 ; 5 = wxWidgits Console
190 ; 6 = Documentation (PDF)
191 ; 7 = Documentation (HTML)
194 !define ComponentFile 1
195 !define ComponentStorage 2
196 !define ComponentDirector 4
197 !define ComponentTextConsole 8
198 !define ComponentBatConsole 16
199 !define ComponentGUIConsole 32
200 !define ComponentPDFDocs 64
201 !define ComponentHTMLDocs 128
202 !define ComponentTrayMonitor 1024
204 !define ComponentsRequiringUserConfig 63
205 !define ComponentsFileAndStorage 3
206 !define ComponentsFileAndStorageAndDirector 7
207 !define ComponentsDirectorAndTextGuiConsoles 60
208 !define ComponentsTextAndGuiConsoles 56
217 ; Process Command Line Options
221 StrCpy $CommonFilesDone 0
223 StrCpy $AutomaticInstall 0
224 StrCpy $InstallType ${NewInstall}
225 StrCpy $OldInstallDir ""
226 StrCpy $PreviousComponents 0
227 StrCpy $NewComponents 0
229 StrCpy $MySQLVersion ""
230 StrCpy $PostgreSQLPath ""
231 StrCpy $PostgreSQLVersion ""
232 StrCpy $LocalDirectorPassword ""
237 ${GetOptions} $R0 "/noservice" $R1
242 ${GetOptions} $R0 "/nostart" $R1
249 ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
258 Pop $LocalHostAddress
262 ; Configuration Defaults
264 StrCpy $ConfigClientName "$HostName-fd"
265 StrCpy $ConfigClientPort 9102
266 StrCpy $ConfigClientMaxJobs 10
267 ;StrCpy $ConfigClientPassword
268 StrCpy $ConfigClientInstallService "$OptService"
269 StrCpy $ConfigClientStartService "$OptStart"
271 StrCpy $ConfigDirectorPort 9101
273 StrCpy $ConfigMonitorName "$HostName-mon"
274 ;StrCpy $ConfigMonitorPassword
276 ; PLUGINSDIR refers to temporary helper programs and not Bacula plugins!
278 File "/oname=$PLUGINSDIR\openssl.exe" "${SRC_DIR}\openssl.exe"
279 File "/oname=$PLUGINSDIR\ssleay32-0.9.8.dll" "${SRC_DIR}\ssleay32-0.9.8.dll"
280 File "/oname=$PLUGINSDIR\cryptoeay32-0.9.8.dll" "${SRC_DIR}\cryptoeay32-0.9.8.dll"
281 ; File "/oname=$PLUGINSDIR\libeay32.dll" "${SRC_DIR}\libeay32.dll"
282 ; File "/oname=$PLUGINSDIR\ssleay32.dll" "${SRC_DIR}\ssleay32.dll"
283 File "/oname=$PLUGINSDIR\sed.exe" "${SRC_DIR}\sed.exe"
285 !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
286 !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
288 SetPluginUnload alwaysoff
290 ; Set client password
291 nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
294 FileOpen $R1 "$PLUGINSDIR\pw.txt" r
297 ${StrTrimNewLines} $ConfigClientPassword $R0
301 SetPluginUnload manual
303 ; Set monitor password
304 nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
307 FileOpen $R1 "$PLUGINSDIR\pw.txt" r
310 ${StrTrimNewLines} $ConfigMonitorPassword $R0
318 Function .onSelChange
319 Call UpdateComponentUI
322 Function InstallCommonFiles
323 ${If} $CommonFilesDone = 0
324 SetOutPath "$INSTDIR"
327 SetOutPath "$INSTDIR"
328 !if "${BUILD_TOOLS}" == "MinGW32"
329 File "${SRC_DIR}\mingwm10.dll"
330 File "${SRC_DIR}\pthreadGCE.dll"
331 File "${SRC_DIR}\zlib1.dll"
332 File "${SRC_DIR}\ssleay32.dll"
333 File "${SRC_DIR}\libeay32.dll"
335 !if "${BUILD_TOOLS}" == "MinGW64"
336 File "${SRC_DIR}\pthreadGCE.dll"
337 File "${SRC_DIR}\cryptoeay32-0.9.8.dll"
338 File "${SRC_DIR}\ssleay32-0.9.8.dll"
339 File "${SRC_DIR}\zlib1.dll"
341 File "${SRC_DIR}\bacula.dll"
342 File "/oname=$INSTDIR\openssl.cnf" "${SRC_DIR}\openssl.cnf"
343 File "${SRC_DIR}\openssl.exe"
344 File "${SRC_DIR}\bsleep.exe"
345 File "${SRC_DIR}\bsmtp.exe"
346 File "${SRC_DIR}\expr64.exe"
347 File "${SRC_DIR}\snooze.exe"
349 CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
351 StrCpy $CommonFilesDone 1
355 Section "-Initialize"
357 WriteRegStr HKLM Software\Bacula InstallLocation "$INSTDIR"
359 Call GetSelectedComponents
361 WriteRegDWORD HKLM Software\Bacula Components $R2
363 ; remove start menu items
364 SetShellVarContext all
366 Delete /REBOOTOK "$SMPROGRAMS\Bacula\Configuration\*"
367 Delete /REBOOTOK "$SMPROGRAMS\Bacula\Documentation\*"
368 Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
369 RMDir "$SMPROGRAMS\Bacula\Configuration"
370 RMDir "$SMPROGRAMS\Bacula\Documentation"
371 RMDir "$SMPROGRAMS\Bacula"
372 CreateDirectory "$SMPROGRAMS\Bacula"
373 CreateDirectory "$SMPROGRAMS\Bacula\Configuration"
374 CreateDirectory "$SMPROGRAMS\Bacula\Documentation"
376 CreateDirectory "$INSTDIR"
377 CreateDirectory "$INSTDIR\working"
379 SetOutPath "$INSTDIR"
380 File "..\..\..\LICENSE"
381 Delete /REBOOTOK "$INSTDIR\License.txt"
383 ; Output a series of SED commands to configure the .conf file(s)
384 FileOpen $R1 $PLUGINSDIR\config.sed w
385 FileWrite $R1 "s;@VERSION@;${VERSION};g$\r$\n"
386 FileWrite $R1 "s;@DATE@;${__DATE__};g$\r$\n"
387 FileWrite $R1 "s;@DISTNAME@;Windows;g$\r$\n"
389 StrCpy $R2 ${BUILD_TOOLS}
395 FileWrite $R1 "s;@DISTVER@;$R2;g$\r$\n"
397 ${StrRep} $R2 "$INSTDIR\working" "\" "\\\\"
398 FileWrite $R1 's;@working_dir@;$R2;g$\r$\n'
399 ${StrRep} $R2 "$INSTDIR\working" "\" "\\"
400 FileWrite $R1 's;@working_dir_cmd@;$R2;g$\r$\n'
402 ${StrRep} $R2 "$INSTDIR" "\" "\\\\"
403 FileWrite $R1 's;@bin_dir@;$R2;g$\r$\n'
404 ${StrRep} $R2 "$INSTDIR" "\" "\\"
405 FileWrite $R1 's;@bin_dir_cmd@;$R2;g$\r$\n'
407 ${StrRep} $R2 "$INSTDIR\plugins" "\" "\\\\"
408 FileWrite $R1 's;@fdplugins_dir@;$R2;g$\r$\n'
410 ${StrRep} $R2 "$INSTDIR" "\" "/"
411 FileWrite $R1 "s;@BUILD_DIR@;$R2;g$\r$\n"
413 FileWrite $R1 "s;@client_address@;$LocalHostAddress;g$\r$\n"
415 ${If} "$ConfigClientName" != ""
416 FileWrite $R1 "s;@client_name@;$ConfigClientName;g$\r$\n"
418 ${If} "$ConfigClientPort" != ""
419 FileWrite $R1 "s;@client_port@;$ConfigClientPort;g$\r$\n"
421 ${If} "$ConfigClientMaxJobs" != ""
422 FileWrite $R1 "s;@client_maxjobs@;$ConfigClientMaxJobs;g$\r$\n"
424 ${If} "$ConfigClientPassword" != ""
425 FileWrite $R1 "s;@client_password@;$ConfigClientPassword;g$\r$\n"
427 ${If} "$ConfigDirectorName" != ""
428 FileWrite $R1 "s;@director_name@;$ConfigDirectorName;g$\r$\n"
430 ${If} "$ConfigDirectorPort" != ""
431 FileWrite $R1 "s;@director_port@;$ConfigDirectorPort;g$\r$\n"
433 ${If} "$ConfigDirectorPassword" != ""
434 FileWrite $R1 "s;@director_password@;$ConfigDirectorPassword;g$\r$\n"
436 ${If} "$ConfigDirectorAddress" != ""
437 FileWrite $R1 "s;@director_address@;$ConfigDirectorAddress;g$\r$\n"
439 ${If} "$ConfigMonitorName" != ""
440 FileWrite $R1 "s;@monitor_name@;$ConfigMonitorName;g$\r$\n"
442 ${If} "$ConfigMonitorPassword" != ""
443 FileWrite $R1 "s;@monitor_password@;$ConfigMonitorPassword;g$\r$\n"
448 ${If} ${FileExists} "$OldInstallDir\bacula-fd.exe"
449 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
451 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /remove' ; Remove existing service
456 SectionGroup "Client" SecGroupClient
458 Section "File Service" SecFileDaemon
461 SetOutPath "$INSTDIR\plugins"
462 File "${SRC_DIR}\exchange-fd.dll"
464 SetOutPath "$INSTDIR"
466 File "${SRC_DIR}\bacula-fd.exe"
468 File "/oname=$PLUGINSDIR\bacula-fd.conf" "bacula-fd.conf.in"
471 StrCpy $1 bacula-fd.conf
472 Call ConfigEditAndCopy
475 StrCpy $1 "File Service"
476 StrCpy $2 $ConfigClientInstallService
477 StrCpy $3 $ConfigClientStartService
481 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Client Configuration.lnk" "write.exe" '"$INSTDIR\bacula-fd.conf"'
486 SectionGroup "Consoles" SecGroupConsoles
488 Section "Command Console" SecConsole
491 SetOutPath "$INSTDIR"
493 File "${SRC_DIR}\bconsole.exe"
494 Call InstallCommonFiles
496 File "/oname=$PLUGINSDIR\bconsole.conf" "bconsole.conf.in"
498 StrCpy $1 bconsole.conf
499 Call ConfigEditAndCopy
501 CreateShortCut "$SMPROGRAMS\Bacula\bconsole.lnk" "$INSTDIR\bconsole.exe" '-c "$INSTDIR\bconsole.conf"' "$INSTDIR\bconsole.exe" 0
502 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Command Console Configuration.lnk" "write.exe" '"$INSTDIR\bconsole.conf"'
506 Section "Bat Console" SecBatConsole
509 SetOutPath "$INSTDIR\bin32"
511 Call InstallCommonFiles
512 File "${SRC_DIR}\QtCore4.dll"
513 File "${SRC_DIR}\QtGui4.dll"
514 File "${SRC_DIR}\libgcc_s_dw2-1.dll"
515 File "${SRC_DIR}\mingwm10.dll"
516 File "${SRC_DIR}\ssleay32.dll"
517 File "${SRC_DIR}\libeay32.dll"
518 File "${SRC_DIR}\bat.exe"
519 File "/oname=$INSTDIR\bin32\bacula.dll" "${SRC_DIR}\bacula32.dll"
520 File "/oname=$INSTDIR\bin32\pthreadGCE.dll" "${SRC_DIR}\pthreadGCE32.dll"
521 File "/oname=$INSTDIR\bin32\zlib1.dll" "${SRC_DIR}\zlib132.dll"
523 File "/oname=$PLUGINSDIR\bat.conf" "bat.conf.in"
524 StrCpy $0 "$INSTDIR\bin32"
526 Call ConfigEditAndCopy
528 SetOutPath "$INSTDIR\help"
529 File "${SRC_DIR}\help\*"
530 SetOutPath "$INSTDIR"
533 ; Create Start Menu entry
534 CreateShortCut "$SMPROGRAMS\Bacula\Bat.lnk" "$INSTDIR\bin32\bat.exe" '-c "$INSTDIR\bin32\bat.conf"' "$INSTDIR\bin32\bat.exe" 0
535 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Bat Configuration.lnk" "write.exe" '"$INSTDIR\bin32\bat.conf"'
536 SetOutPath "$INSTDIR"
539 Section "Tray Monitor" SecTrayMonitor
542 SetOutPath "$INSTDIR\bin32"
544 Call InstallCommonFiles
545 File "${SRC_DIR}\QtCore4.dll"
546 File "${SRC_DIR}\QtGui4.dll"
547 File "${SRC_DIR}\libgcc_s_dw2-1.dll"
548 File "${SRC_DIR}\mingwm10.dll"
549 File "${SRC_DIR}\ssleay32.dll"
550 File "${SRC_DIR}\libeay32.dll"
551 File "${SRC_DIR}\bacula-tray-monitor.exe"
552 File "/oname=$INSTDIR\bin32\bacula.dll" "${SRC_DIR}\bacula32.dll"
553 File "/oname=$INSTDIR\bin32\pthreadGCE.dll" "${SRC_DIR}\pthreadGCE32.dll"
554 File "/oname=$INSTDIR\bin32\zlib1.dll" "${SRC_DIR}\zlib132.dll"
556 File "/oname=$PLUGINSDIR\tray-monitor.conf" "tray-monitor.conf.in"
557 StrCpy $0 "$INSTDIR\bin32"
558 StrCpy $1 tray-monitor.conf
559 Call ConfigEditAndCopy
561 ; Create Start Menu entry
562 CreateShortCut "$SMPROGRAMS\Bacula\TrayMonitor.lnk" "$INSTDIR\bin32\bacula-tray-monitor.exe" '-c "$INSTDIR\bin32\tray-monitor.conf"' "$INSTDIR\bin32\bacula-tray-monitor.exe" 0
563 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Tray Monitor Configuration.lnk" "write.exe" '"$INSTDIR\bin32\tray-monitor.conf"'
564 SetOutPath "$INSTDIR"
568 ; Deleted because wxconsole is deprecated
569 ;Section "Graphical Console" SecWxConsole
572 ; SetOutPath "$INSTDIR"
583 ; nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR" /T /G SYSTEM:F Administrators:F'
586 ; Write the uninstall keys for Windows & create Start Menu entry
587 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula"
588 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "InstallLocation" "$INSTDIR"
589 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayVersion" "${VERSION}"
590 ${StrTok} $R0 "${VERSION}" "." 0 0
591 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMajor" $R0
592 ${StrTok} $R0 "${VERSION}" "." 1 0
593 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMinor" $R0
594 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoModify" 1
595 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoRepair" 1
596 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLUpdateInfo" "http://www.bacula.org"
597 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLInfoAbout" "http://www.bacula.org"
598 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "HelpLink" "http://www.bacula.org?page=support"
599 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
600 WriteUninstaller "$INSTDIR\Uninstall.exe"
601 CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
605 ; Extra Page descriptions
607 LangString DESC_SecFileDaemon ${LANG_ENGLISH} "Install Bacula File Daemon on this system."
608 LangString DESC_SecConsole ${LANG_ENGLISH} "Install command console program on this system."
609 LangString DESC_SecBatConsole ${LANG_ENGLISH} "Install Bat graphical console program on this system."
610 LangString DESC_SecTrayMonitor ${LANG_ENGLISH} "Install Tray Monitor graphical program on this system."
612 LangString TITLE_ConfigPage1 ${LANG_ENGLISH} "Configuration"
613 LangString SUBTITLE_ConfigPage1 ${LANG_ENGLISH} "Set installation configuration."
615 LangString TITLE_ConfigPage2 ${LANG_ENGLISH} "Configuration (continued)"
616 LangString SUBTITLE_ConfigPage2 ${LANG_ENGLISH} "Set installation configuration."
618 LangString TITLE_InstallType ${LANG_ENGLISH} "Installation Type"
619 LangString SUBTITLE_InstallType ${LANG_ENGLISH} "Choose installation type."
621 LangString TITLE_WriteTemplates ${LANG_ENGLISH} "Create Templates"
622 LangString SUBTITLE_WriteTemplates ${LANG_ENGLISH} "Create a resource template for inclusion in the Director's configuration file."
624 !InsertMacro MUI_FUNCTION_DESCRIPTION_BEGIN
625 !InsertMacro MUI_DESCRIPTION_TEXT ${SecFileDaemon} $(DESC_SecFileDaemon)
626 !InsertMacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
627 !InsertMacro MUI_DESCRIPTION_TEXT ${SecBatConsole} $(DESC_SecBatConsole)
628 !InsertMacro MUI_DESCRIPTION_TEXT ${SecTrayMonitor} $(DESC_SecTrayMonitor)
629 !InsertMacro MUI_FUNCTION_DESCRIPTION_END
633 UninstallText "This will uninstall Bacula. Click Uninstall to continue."
636 ; Shutdown any baculum that could be running
637 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
640 ; ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
641 ; Remove bacula service
642 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /remove'
643 nsExec::ExecToLog '"$INSTDIR\plugins\exchange-fd.dll" /remove'
645 ; remove registry keys
646 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
647 DeleteRegKey HKLM "Software\Bacula"
649 ; remove start menu items
650 SetShellVarContext all
651 Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
652 RMDir "$SMPROGRAMS\Bacula"
654 ; remove files and uninstaller (preserving config for now)
655 Delete /REBOOTOK "$INSTDIR\doc\*"
656 Delete /REBOOTOK "$INSTDIR\*"
657 Delete /REBOOTOK "$INSTDIR\help\*"
659 ; Check for existing installation
660 MessageBox MB_YESNO|MB_ICONQUESTION \
661 "Would you like to delete the current configuration files and the working state file?" IDNO NoDel
662 Delete /REBOOTOK "$INSTDIR\*"
663 Delete /REBOOTOK "$INSTDIR\bin32\*"
664 Delete /REBOOTOK "$INSTDIR\working\*"
665 Delete /REBOOTOK "$INSTDIR\plugins\*"
666 Delete /REBOOTOK "$PLUGINSDIR\bacula-*.conf"
667 Delete /REBOOTOK "$PLUGINSDIR\*console.conf"
668 Delete /REBOOTOK "$PLUGINSDIR\*conf.in"
669 Delete /REBOOTOK "$PLUGINSDIR\openssl.exe"
670 Delete /REBOOTOK "$PLUGINSDIR\libeay32.dll"
671 Delete /REBOOTOK "$PLUGINSDIR\ssleay32.dll"
672 Delete /REBOOTOK "$PLUGINSDIR\sed.exe"
673 Delete /REBOOTOK "$PLUGINSDIR\pw.txt"
674 Delete /REBOOTOK "$PLUGINSDIR\*.sed"
675 Delete /REBOOTOK "$PLUGINSDIR\*.cmd"
676 Delete /REBOOTOK "$PLUGINSDIR\*.sql"
677 RMDir "$INSTDIR\plugins"
678 RMDir "$INSTDIR\working"
679 RMDir "$INSTDIR\bin32"
683 ; remove directories used
685 RMDir "$INSTDIR\help"
690 ; $0 - Service Name (ie Bacula-FD)
691 ; $1 - Service Description (ie Bacula File Daemon)
692 ; $2 - Install as Service
693 ; $3 - Start Service now
695 Function InstallDaemon
696 Call InstallCommonFiles
698 WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
701 nsExec::ExecToLog '"$INSTDIR\$0.exe" /kill'
703 nsExec::ExecToLog '"$INSTDIR\$0.exe" /remove'
704 nsExec::ExecToLog '"$INSTDIR\$0.exe" /install -c "$INSTDIR\$0.conf"'
715 nsExec::ExecToLog 'net start $0'
717 Exec '"$INSTDIR\$0.exe" /service -c "$INSTDIR\$0.conf"'
721 CreateShortCut "$SMPROGRAMS\Bacula\Start $1.lnk" "$INSTDIR\$0.exe" '-c "$INSTDIR\$0.conf"' "$INSTDIR\$0.exe" 0
725 Function GetComputerName
730 System::Call "kernel32::GetComputerNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2"
732 ${StrCase} $R0 $R0 "L"
739 !define ComputerNameDnsFullyQualified 3
747 System::Call "kernel32::GetComputerNameExA(i ${ComputerNameDnsFullyQualified}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
750 DetailPrint "GetComputerNameExA failed - LastError = $R2"
766 !define NameUserPrincipal 8
774 System::Call "secur32::GetUserNameExA(i ${NameUserPrincipal}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
777 DetailPrint "GetUserNameExA failed - LastError = $R2"
788 System::Call "advapi32::GetUserNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
791 DetailPrint "GetUserNameA failed - LastError = $R2"
803 Function ConfigEditAndCopy
806 ${If} ${FileExists} "$0\$1"
812 nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\$1"'
813 CopyFiles "$PLUGINSDIR\$1" "$0\$1$R1"
818 Function GetSelectedComponents
821 ${If} ${SectionIsSelected} ${SecFileDaemon}
822 IntOp $R0 $R0 | ${ComponentFile}
824 ${If} ${SectionIsSelected} ${SecConsole}
825 IntOp $R0 $R0 | ${ComponentTextConsole}
827 ${If} ${SectionIsSelected} ${SecBatConsole}
828 IntOp $R0 $R0 | ${ComponentBatConsole}
830 ${If} ${SectionIsSelected} ${SecTrayMonitor}
831 IntOp $R0 $R0 | ${ComponentTrayMonitor}
836 Function PageComponentsShow
838 Call SelectPreviousComponents
839 Call UpdateComponentUI
842 Function PageDirectoryPre
843 ${If} $AutomaticInstall = 1
844 ${OrIf} $InstallType = ${UpgradeInstall}
849 Function LeaveInstallPage
850 Push "$INSTDIR\install.log"
854 Function EnterWriteTemplates
858 Call GetSelectedComponents
861 IntOp $R0 $R0 & ${ComponentDirector}
862 IntOp $R1 $NewComponents & ${ComponentsFileAndStorage}
871 IntOp $R0 $NewComponents & ${ComponentFile}
873 WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" State 0
874 WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" Flags DISABLED
875 DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" State
876 WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
878 WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" State 1
879 DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" Flags
880 WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" State "C:\$ConfigClientName.conf"
884 !InsertMacro MUI_HEADER_TEXT "$(TITLE_WriteTemplates)" "$(SUBTITLE_WriteTemplates)"
885 !InsertMacro MUI_INSTALLOPTIONS_DISPLAY "WriteTemplates.ini"
887 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 2" State
889 File "/oname=$PLUGINSDIR\client.conf.in" "client.conf.in"
891 nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\client.conf.in"'
892 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 3" State
894 CopyFiles "$PLUGINSDIR\client.conf.in" "$R0"
903 Function SelectPreviousComponents
904 ${If} $InstallType <> ${NewInstall}
905 IntOp $R1 $PreviousComponents & ${ComponentFile}
907 !InsertMacro SelectSection ${SecFileDaemon}
908 !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_RO}
910 !InsertMacro UnselectSection ${SecFileDaemon}
911 !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_RO}
913 IntOp $R1 $PreviousComponents & ${ComponentTextConsole}
915 !InsertMacro SelectSection ${SecConsole}
916 !InsertMacro SetSectionFlag ${SecConsole} ${SF_RO}
918 !InsertMacro UnselectSection ${SecConsole}
919 !InsertMacro ClearSectionFlag ${SecConsole} ${SF_RO}
921 IntOp $R1 $PreviousComponents & ${ComponentBatConsole}
923 !InsertMacro SelectSection ${SecBatConsole}
924 !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_RO}
926 !InsertMacro UnselectSection ${SecBatConsole}
927 !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_RO}
929 IntOp $R1 $PreviousComponents & ${ComponentTrayMonitor}
931 !InsertMacro SelectSection ${SecTrayMonitor}
932 !InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_RO}
934 !InsertMacro UnselectSection ${SecTrayMonitor}
935 !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_RO}
940 Function UpdateComponentUI
944 Call GetSelectedComponents
947 IntOp $R1 $R0 ^ $PreviousComponents
948 IntOp $NewComponents $R0 & $R1
950 ${If} $InstallType <> ${NewInstall}
951 IntOp $R1 $NewComponents & ${ComponentFile}
953 !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_BOLD}
955 !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_BOLD}
957 IntOp $R1 $NewComponents & ${ComponentTextConsole}
959 !InsertMacro SetSectionFlag ${SecConsole} ${SF_BOLD}
961 !InsertMacro ClearSectionFlag ${SecConsole} ${SF_BOLD}
963 IntOp $R1 $NewComponents & ${ComponentBatConsole}
965 !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_BOLD}
967 !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_BOLD}
969 IntOp $R1 $NewComponents & ${ComponentTrayMonitor}
971 !InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_BOLD}
973 !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_BOLD}
977 GetDlgItem $R0 $HWNDPARENT 1
979 IntOp $R1 $NewComponents & ${ComponentsRequiringUserConfig}
981 SendMessage $R0 ${WM_SETTEXT} 0 "STR:Install"
983 SendMessage $R0 ${WM_SETTEXT} 0 "STR:&Next >"
990 !include "InstallType.nsh"
991 !include "ConfigPage1.nsh"
992 !include "ConfigPage2.nsh"
993 !include "DumpLog.nsh"