2 # Copyright (C) 2000-2018 Kern Sibbald
3 # License: BSD 2-Clause; see file LICENSE-FOSS
5 ##{{NSIS_PLUS_BEGIN_PROJECT_SETTINGS}}##
7 # CMD -DSRC_DIR=release64 -DSRC32_DIR=..\win32_installer\release32 -DSRC64_DIR=..\win64_installer\release64 -DOUT_DIR=release64 -DWINVER=64 -DVERSION=9.0.7 -DBUILD_TOOLS=NSIS-3.0b0
8 # EXE C:\Program Files (x86)\NSIS\makensis.exe
10 ##{{NSIS_PLUS_END_PROJECT_SETTINGS}}##
14 ; Began as a version written by Michel Meyers (michel@tcnnet.dyndns.org)
16 ; Adapted by Kern Sibbald for native Win32 Bacula
17 ; added a number of elements from Christopher Hull's installer
19 ; D. Scott Barninger Nov 13 2004
20 ; added configuration editing for bconsole.conf and bwx-console.conf
21 ; better explanation in dialog boxes for editing config files
22 ; added Start Menu items
23 ; fix uninstall of config files to do all not just bacula-fd.conf
25 ; D. Scott Barninger Dec 05 2004
26 ; added specification of default permissions for bacula-fd.conf
27 ; - thanks to Jamie Ffolliott for pointing me at cacls
28 ; added removal of working-dir files if user selects to remove config
29 ; uninstall is now 100% clean
31 ; D. Scott Barninger Apr 17 2005
32 ; 1.36.3 release docs update
33 ; add pdf manual and menu shortcut
35 ; Robert Nelson May 15 2006
36 ; Added server installs and implemented Microsoft install locations
38 ; Added Bacula-SD and Bacula-DIR
39 ; Replaced ParameterGiven with standard GetOptions
41 ; Kern Sibbald October 2008
42 ; Remove server installs
43 ; Install into single bacula directory
44 ; (i.e. undo a large part of what Robert Nelson did)
46 ; Eric Bollengier March 2009
47 ; Updated to handle Win64 installation
49 ; Kern Sibbald April 2009
50 ; Correct some Win64 install problems
51 ; It is mind boggling how many lines of this insane scripting language
52 ; have been written with absolutely no comments
54 ; Command line options:
59 ; netsh firewall add portopening protocol=tcp port=9102 name="Bacula-FD"
62 !define PRODUCT "Bacula"
65 ; Include the Modern UI
69 !include "LogicLib.nsh"
70 !include "FileFunc.nsh"
71 !include "Sections.nsh"
72 !include "StrFunc.nsh"
73 !include "WinMessages.nsh"
79 OutFile "${OUT_DIR}\bacula-win${WINVER}-${VERSION}.exe"
81 Caption "Bacula 64 bit Edition ${VERSION}"
82 VIProductVersion ${VERSION}.1
83 VIAddVersionKey CompanyName "Bacula Project"
84 VIAddVersionKey LegalCopyright "Kern Sibbald"
85 VIAddVersionKey FileDescription "Bacula network backup and restore"
86 VIAddVersionKey FileVersion win${WINVER}-${VERSION}
87 VIAddVersionKey ProductVersion win${WINVER}-${VERSION}
88 VIAddVersionKey ProductName "Bacula"
89 VIAddVersionKey InternalName "Bacula"
90 VIAddVersionKey LegalTrademarks "Bacula is a registered trademark of Kern Sibbald"
91 VIAddVersionKey OriginalFilename "bacula.exe"
93 InstallDir "C:\Program Files\Bacula"
94 InstallDirRegKey HKLM "Software\Bacula" "InstallLocation"
100 !insertmacro GetParent
111 !define MUI_COMPONENTSPAGE_SMALLDESC
113 !define MUI_HEADERIMAGE
114 !define MUI_BGCOLOR 739AB9
115 !define MUI_HEADERIMAGE_BITMAP "bacula-logo.bmp"
117 !InsertMacro MUI_PAGE_WELCOME
118 !InsertMacro MUI_PAGE_LICENSE "${SRC_DIR}\LICENSE"
119 Page custom EnterInstallType
120 !define MUI_PAGE_CUSTOMFUNCTION_SHOW PageComponentsShow
121 !InsertMacro MUI_PAGE_COMPONENTS
122 !define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
123 !InsertMacro MUI_PAGE_DIRECTORY
124 Page custom EnterConfigPage1 LeaveConfigPage1
125 Page custom EnterConfigPage2 LeaveConfigPage2
126 !Define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveInstallPage
127 !InsertMacro MUI_PAGE_INSTFILES
128 Page custom EnterWriteTemplates
129 !Define MUI_FINISHPAGE_SHOWREADME $INSTDIR\Readme.txt
130 !InsertMacro MUI_PAGE_FINISH
132 !InsertMacro MUI_UNPAGE_WELCOME
133 !InsertMacro MUI_UNPAGE_CONFIRM
134 !InsertMacro MUI_UNPAGE_INSTFILES
135 !InsertMacro MUI_UNPAGE_FINISH
137 !define MUI_ABORTWARNING
139 !InsertMacro MUI_LANGUAGE "English"
141 !InsertMacro GetParameters
142 !InsertMacro GetOptions
144 DirText "Setup will install Bacula 64 bit ${VERSION} to the directory specified below. To install in a different folder, click Browse and select another folder."
146 !InsertMacro MUI_RESERVEFILE_INSTALLOPTIONS
162 Var ConfigClientMaxJobs
163 Var ConfigClientPassword
164 Var ConfigClientInstallService
165 Var ConfigClientStartService
167 Var ConfigStorageName
168 Var ConfigStoragePort
169 Var ConfigStorageMaxJobs
170 Var ConfigStoragePassword
171 Var ConfigStorageInstallService
172 Var ConfigStorageStartService
174 Var ConfigDirectorName
175 Var ConfigDirectorPort
176 Var ConfigDirectorMaxJobs
177 Var ConfigDirectorPassword
178 Var ConfigDirectorAddress
179 Var ConfigDirectorMailServer
180 Var ConfigDirectorMailAddress
182 Var ConfigDirectorInstallService
183 Var ConfigDirectorStartService
185 Var ConfigMonitorName
186 Var ConfigMonitorPassword
188 Var LocalDirectorPassword
194 Var PostgreSQLVersion
200 !define UpgradeInstall 1
201 !define MigrateInstall 2
204 Var PreviousComponents
207 ; Bit 0 = File Service
208 ; 1 = Storage Service
209 ; 2 = Director Service
210 ; 3 = Command Console
212 ; 5 = wxWidgits Console
213 ; 6 = Documentation (PDF)
214 ; 7 = Documentation (HTML)
215 ; 8 = alldrives Plugin
216 ; 9 = Old Exchange Plugin
218 ; 11 = winbmr Plugin (not implemented in community version)
220 !define ComponentFile 1
221 !define ComponentStorage 2
222 !define ComponentDirector 4
223 !define ComponentTextConsole 8
224 !define ComponentBatConsole 16
225 !define ComponentGUIConsole 32
226 !define ComponentPDFDocs 64
227 !define ComponentHTMLDocs 128
228 !define ComponentAllDrivesPlugin 256
229 !define ComponentOldExchangePlugin 512
230 !define ComponentTrayMonitor 1024
232 !define ComponentsRequiringUserConfig 63
233 !define ComponentsFileAndStorage 3
234 !define ComponentsFileAndStorageAndDirector 7
235 !define ComponentsDirectorAndTextGuiConsoles 60
236 !define ComponentsTextAndGuiConsoles 56
245 ; Process Command Line Options
249 StrCpy $CommonFilesDone 0
251 StrCpy $AutomaticInstall 0
252 StrCpy $InstallType ${NewInstall}
253 StrCpy $OldInstallDir ""
254 StrCpy $PreviousComponents 0
255 StrCpy $NewComponents 0
257 StrCpy $MySQLVersion ""
258 StrCpy $PostgreSQLPath ""
259 StrCpy $PostgreSQLVersion ""
260 StrCpy $LocalDirectorPassword ""
268 MessageBox MB_OK "This is a 64 bit installer, but the OS is not an x64 -- Aborting ..." /SD IDOK
272 ${GetOptions} $R0 "/noservice" $R1
277 ${GetOptions} $R0 "/nostart" $R1
284 ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
293 Pop $LocalHostAddress
297 ; Configuration Defaults
299 StrCpy $ConfigClientName "$HostName-fd"
300 StrCpy $ConfigClientPort 9102
301 StrCpy $ConfigClientMaxJobs 10
302 ;StrCpy $ConfigClientPassword
303 StrCpy $ConfigClientInstallService "$OptService"
304 StrCpy $ConfigClientStartService "$OptStart"
306 StrCpy $ConfigStorageName "$HostName-sd"
307 StrCpy $ConfigStoragePort 9103
308 StrCpy $ConfigStorageMaxJobs 10
309 ;StrCpy $ConfigStoragePassword
310 StrCpy $ConfigStorageInstallService "$OptService"
311 StrCpy $ConfigStorageStartService "$OptStart"
312 StrCpy $ConfigDirectorPort 9101
314 StrCpy $ConfigMonitorName "$HostName-mon"
315 ;StrCpy $ConfigMonitorPassword
317 ; TEMP refers to temporary helper programs and not Bacula plugins!
319 CreateDirectory "$INSTDIR"
320 CreateDirectory "$INSTDIR\working"
321 File "/oname=$INSTDIR\working\openssl.exe" "${SRC_DIR}\openssl.exe"
322 File "/oname=$INSTDIR\working\libeay32.dll" "${SRC_DIR}\libeay32.dll"
323 File "/oname=$INSTDIR\working\ssleay32.dll" "${SRC_DIR}\ssleay32.dll"
324 File "/oname=$INSTDIR\working\sed.exe" "${SRC_DIR}\sed.exe"
326 !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
327 !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
329 SetPluginUnload alwaysoff
331 ; Generate random File daemon password
332 nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
335 FileOpen $R1 "$INSTDIR\working\pw.txt" r
338 ${StrTrimNewLines} $ConfigClientPassword $R0
342 ; Generate random Storage daemon password
343 nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
346 FileOpen $R1 "$INSTDIR\working\pw.txt" r
349 ${StrTrimNewLines} $ConfigStoragePassword $R0
353 SetPluginUnload manual
355 ; Generate random monitor password
356 nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
359 FileOpen $R1 "$INSTDIR\working\pw.txt" r
362 ${StrTrimNewLines} $ConfigMonitorPassword $R0
370 Function .onSelChange
371 Call UpdateComponentUI
374 Function InstallCommonFiles
375 ${If} $CommonFilesDone = 0
376 SetOutPath "$INSTDIR"
379 SetOutPath "$INSTDIR"
380 !if "${BUILD_TOOLS}" == "MinGW32"
381 File "${SRC_DIR}\mingwm10.dll"
383 File "${SRC_DIR}\libwinpthread-1.dll"
384 File "${SRC_DIR}\pthreadGCE2.dll"
385 File "${SRC_DIR}\libgcc_s_seh-1.dll"
386 File "${SRC_DIR}\libstdc++-6.dll"
387 File "${SRC_DIR}\ssleay32.dll"
388 File "${SRC_DIR}\libeay32.dll"
389 File "${SRC_DIR}\zlib1.dll"
390 File "${SRC_DIR}\bacula.dll"
392 File "/oname=$INSTDIR\openssl.cnf" "${SRC_DIR}\openssl.cnf"
393 File "${SRC_DIR}\openssl.exe"
394 File "${SRC_DIR}\bsleep.exe"
395 File "${SRC_DIR}\bsmtp.exe"
396 File "${SRC_DIR}\expr64.exe"
397 File "${SRC_DIR}\snooze.exe"
399 CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
401 StrCpy $CommonFilesDone 1
405 Section "-Initialize"
407 WriteRegStr HKLM Software\Bacula InstallLocation "$INSTDIR"
409 Call GetSelectedComponents
411 WriteRegDWORD HKLM Software\Bacula Components $R2
413 ; remove start menu items
414 SetShellVarContext all
416 Delete /REBOOTOK "$SMPROGRAMS\Bacula\Configuration\*"
417 Delete /REBOOTOK "$SMPROGRAMS\Bacula\Documentation\*"
418 Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
419 RMDir "$SMPROGRAMS\Bacula\Configuration"
420 RMDir "$SMPROGRAMS\Bacula\Documentation"
421 RMDir "$SMPROGRAMS\Bacula"
422 CreateDirectory "$SMPROGRAMS\Bacula"
423 CreateDirectory "$SMPROGRAMS\Bacula\Configuration"
424 CreateDirectory "$SMPROGRAMS\Bacula\Documentation"
426 CreateDirectory "$INSTDIR"
427 CreateDirectory "$INSTDIR\working"
428 CreateDirectory "$INSTDIR\plugins"
430 SetOutPath "$INSTDIR"
431 File "${SRC_DIR}\LICENSE"
432 Delete /REBOOTOK "$INSTDIR\License.txt"
434 ; Output a series of SED commands to configure the .conf file(s)
435 FileOpen $R1 $INSTDIR\working\config.sed w
436 FileWrite $R1 "s;@VERSION@;${VERSION};g$\r$\n"
437 FileWrite $R1 "s;@DATE@;${__DATE__};g$\r$\n"
438 FileWrite $R1 "s;@DISTNAME@;Windows;g$\r$\n"
440 StrCpy $R2 ${BUILD_TOOLS}
446 FileWrite $R1 "s;@DISTVER@;$R2;g$\r$\n"
448 ${StrRep} $R2 "$INSTDIR\working" "\" "\\\\"
449 FileWrite $R1 's;@working_dir@;$R2;g$\r$\n'
451 ${StrRep} $R2 "$INSTDIR" "\" "\\\\"
452 FileWrite $R1 's;@bin_dir@;$R2;g$\r$\n'
453 ${StrRep} $R2 "$INSTDIR" "\" "\\"
454 FileWrite $R1 's;@bin_dir_cmd@;$R2;g$\r$\n'
456 ${StrRep} $R2 "$INSTDIR\plugins" "\" "\\\\"
457 FileWrite $R1 's;@fdplugins_dir@;$R2;g$\r$\n'
459 ${StrRep} $R2 "$INSTDIR" "\" "/"
460 FileWrite $R1 "s;@BUILD_DIR@;$R2;g$\r$\n"
462 FileWrite $R1 "s;@client_address@;$LocalHostAddress;g$\r$\n"
463 FileWrite $R1 "s;@client_name@;$ConfigClientName;g$\r$\n"
464 FileWrite $R1 "s;@client_port@;$ConfigClientPort;g$\r$\n"
465 FileWrite $R1 "s;@client_maxjobs@;$ConfigClientMaxJobs;g$\r$\n"
466 FileWrite $R1 "s;@client_password@;$ConfigClientPassword;g$\r$\n"
467 FileWrite $R1 "s;@storage_address@;$LocalHostAddress;g$\r$\n"
468 FileWrite $R1 "s;@storage_name@;$ConfigStorageName;g$\r$\n"
469 FileWrite $R1 "s;@storage_port@;$ConfigStoragePort;g$\r$\n"
470 FileWrite $R1 "s;@storage_maxjobs@;$ConfigStorageMaxJobs;g$\r$\n"
471 FileWrite $R1 "s;@storage_password@;$ConfigStoragePassword;g$\r$\n"
472 FileWrite $R1 "s;@director_name@;$ConfigDirectorName;g$\r$\n"
473 FileWrite $R1 "s;@director_port@;$ConfigDirectorPort;g$\r$\n"
474 FileWrite $R1 "s;@director_password@;$ConfigDirectorPassword;g$\r$\n"
475 FileWrite $R1 "s;@director_address@;$ConfigDirectorAddress;g$\r$\n"
476 FileWrite $R1 "s;@monitor_name@;$ConfigMonitorName;g$\r$\n"
477 FileWrite $R1 "s;@monitor_password@;$ConfigMonitorPassword;g$\r$\n"
481 ${If} ${FileExists} "$OldInstallDir\bacula-fd.exe"
482 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
483 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
485 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /remove' ; Remove existing service
488 ${If} ${FileExists} "$INSTDIR\bacula-fd.exe"
489 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
490 nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
493 ${If} ${FileExists} "$OldInstallDir\bin\bacula-sd.exe"
494 nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill' ; Shutdown any bacula that could be running
495 nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill' ; Shutdown any bacula that could be running
496 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
498 nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /remove' ; Remove existing service
501 ${If} ${FileExists} "$INSTDIR\bacula-sd.exe"
502 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill' ; Shutdown any bacula that could be running
503 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
510 SectionGroup "Client" SecGroupClient
512 Section "File Service" SecFileDaemon
515 SetOutPath "$INSTDIR"
517 File "${SRC_DIR}\bacula-fd.exe"
518 Delete "$INSTDIR\working\bacula-fd.conf.in"
519 File "/oname=$INSTDIR\working\bacula-fd.conf.in" "bacula-fd.conf.in"
522 StrCpy $1 bacula-fd.conf
523 Call ConfigEditAndCopy
526 StrCpy $1 "File Service"
527 StrCpy $2 $ConfigClientInstallService
528 StrCpy $3 $ConfigClientStartService
532 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Client Configuration.lnk" "write.exe" '"$INSTDIR\bacula-fd.conf"'
537 SectionGroup "Server" SecGroupServer
539 Section "Storage Service" SecStorageDaemon
542 SetOutPath "$INSTDIR"
544 File "${SRC_DIR}\bacula-sd.exe"
545 File "${SRC_DIR}\bcopy.exe"
546 File "${SRC_DIR}\bextract.exe"
547 File "${SRC_DIR}\bls.exe"
549 File "/oname=$INSTDIR\working\bacula-sd.conf.in" "bacula-sd.conf.in"
552 StrCpy $1 bacula-sd.conf
553 Call ConfigEditAndCopy
555 # File "${SRC_DIR}\loaderinfo.exe"
556 # File "${SRC_DIR}\mt.exe"
557 # File "${SRC_DIR}\mtx.exe"
558 # File "${SRC_DIR}\scsitape.exe"
559 # File "${SRC_DIR}\tapeinfo.exe"
560 # File "${SRC_DIR}\bscan.exe"
561 # File "${SRC_DIR}\btape.exe"
562 # File "${SRC_DIR}\scsilist.exe"
563 # File "${SRC_DIR}\mkisofs.exe"
564 # File "${SRC_DIR}\growisofs.exe"
566 # File "/oname=$INSTDIR\working\mtx-changer.cmd" "scripts\mtx-changer.cmd"
568 # StrCpy $0 "$INSTDIR\bin"
569 # StrCpy $1 mtx-changer.cmd
570 # Call ConfigEditAndCopy
572 # File "/oname=$INSTDIR\working\disk-changer.cmd" "scripts\disk-changer.cmd"
574 # StrCpy $0 "$INSTDIR"
575 # StrCpy $1 disk-changer.cmd
576 # Call ConfigEditAndCopy
579 StrCpy $1 "Storage Service"
580 StrCpy $2 $ConfigStorageInstallService
581 StrCpy $3 $ConfigStorageStartService
584 # CreateShortCut "$SMPROGRAMS\Bacula\Configuration\List Devices.lnk" "$INSTDIR\bin\scsilist.exe" "/pause"
585 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Storage Configuration.lnk" "write.exe" '"$INSTDIR\bacula-sd.conf"'
590 SectionGroup "Consoles" SecGroupConsoles
592 Section "Command Console" SecConsole
595 SetOutPath "$INSTDIR"
597 File "${SRC_DIR}\bconsole.exe"
598 Call InstallCommonFiles
600 File "/oname=$INSTDIR\working\bconsole.conf.in" "bconsole.conf.in"
602 StrCpy $1 bconsole.conf
603 Call ConfigEditAndCopy
605 CreateShortCut "$SMPROGRAMS\Bacula\bconsole.lnk" "$INSTDIR\bconsole.exe" '-c "$INSTDIR\bconsole.conf"' "$INSTDIR\bconsole.exe" 0
606 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Command Console Configuration.lnk" "write.exe" '"$INSTDIR\bconsole.conf"'
610 Section "Bat Console" SecBatConsole
613 SetOutPath "$INSTDIR"
615 !if "${BUILD_BAT}" == "yes"
616 Call InstallCommonFiles
617 File "${SRC64_DIR}\QtCore4.dll"
618 File "${SRC64_DIR}\QtGui4.dll"
619 File "${SRC64_DIR}\bat.exe"
621 File "/oname=$INSTDIR\working\bat.conf.in" "bat.conf.in"
624 Call ConfigEditAndCopy
626 SetOutPath "$INSTDIR\help"
627 File "${SRC64_DIR}\help\*"
628 SetOutPath "$INSTDIR"
630 ; Create Start Menu entry
631 CreateShortCut "$SMPROGRAMS\Bacula\Bat.lnk" "$INSTDIR\bat.exe" '-c "$INSTDIR\bat.conf"' "$INSTDIR\bat.exe" 0
632 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Bat Configuration.lnk" "write.exe" '"$INSTDIR\bat.conf"'
633 SetOutPath "$INSTDIR"
638 Section "Tray Monitor" SecTrayMonitor
641 SetOutPath "$INSTDIR"
643 !if "${BUILD_BAT}" == "yes"
644 Call InstallCommonFiles
645 File "${SRC64_DIR}\QtCore4.dll"
646 File "${SRC64_DIR}\QtGui4.dll"
647 ;File "${SRC64_DIR}\bacula-tray-monitor.exe"
649 ;File "/oname=$INSTDIR\working\bacula-tray-monitor.conf.in" "bacula-tray-monitor.conf.in"
650 ;StrCpy $0 "$INSTDIR"
651 ;StrCpy $1 bacula-tray-monitor.conf
652 ;Call ConfigEditAndCopy
654 ; Create Start Menu entry
655 ;CreateShortCut "$SMPROGRAMS\Bacula\TrayMonitor.lnk" "$INSTDIR\bacula-tray-monitor.exe" "" "$INSTDIR\bacula-tray-monitor.exe" 0
656 SetOutPath "$INSTDIR"
663 SectionGroup "Plugins" SecGroupPlugins
665 Section "alldrives Plugin" SecAllDrivesPlugin
668 SetOutPath "$INSTDIR\plugins"
669 File "${SRC_DIR}\alldrives-fd.dll"
670 SetOutPath "$INSTDIR"
674 Section "Old (deprecated) Exchange Plugin" SecOldExchangePlugin
677 SetOutPath "$INSTDIR\plugins"
678 File "${SRC_DIR}\exchange-fd.dll"
679 SetOutPath "$INSTDIR"
689 nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bacula-fd.conf" /G SYSTEM:F Administrators:F'
690 nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bacula-sd.conf" /G SYSTEM:F Administrators:F'
691 nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bat.conf" /G SYSTEM:F Administrators:F'
694 ; Write the uninstall keys for Windows & create Start Menu entry
695 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula"
696 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "InstallLocation" "$INSTDIR"
697 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayVersion" "${VERSION}"
698 ${StrTok} $R0 "${VERSION}" "." 0 0
699 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMajor" $R0
700 ${StrTok} $R0 "${VERSION}" "." 1 0
701 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMinor" $R0
702 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoModify" 1
703 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoRepair" 1
704 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLUpdateInfo" "http://www.bacula.org"
705 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLInfoAbout" "http://www.bacula.org"
706 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "HelpLink" "http://www.bacula.org?page=support"
707 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
708 WriteUninstaller "$INSTDIR\Uninstall.exe"
709 CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
712 nsExec::ExecToLog 'net start bacula-fd'
713 nsExec::ExecToLog 'net start bacula-sd'
715 Exec '"$INSTDIR\bacula-fd.exe" /service -c "$INSTDIR\bacula-fd.conf"'
716 Exec '"$INSTDIR\bacula-sd.exe" /service -c "$INSTDIR\bacula-sd.conf"'
722 ; Extra Page descriptions
724 LangString DESC_SecFileDaemon ${LANG_ENGLISH} "Install Bacula 64 bit File Daemon on this system."
725 LangString DESC_SecStorageDaemon ${LANG_ENGLISH} "Install Bacula 64 bit Storage Daemon on this system."
726 LangString DESC_SecConsole ${LANG_ENGLISH} "Install command console program on this system."
727 LangString DESC_SecBatConsole ${LANG_ENGLISH} "Install Bat graphical console program on this system."
728 LangString DESC_SecTrayMonitor ${LANG_ENGLISH} "Install Tray Monitor graphical program on this system."
729 LangString DESC_SecAllDrivesPlugin ${LANG_ENGLISH} "Install alldrives Plugin on this system."
730 LangString DESC_SecOldExchangePlugin ${LANG_ENGLISH} "Install old (deprecated) Exchange Plugin on this system."
732 LangString TITLE_ConfigPage1 ${LANG_ENGLISH} "Configuration"
733 LangString SUBTITLE_ConfigPage1 ${LANG_ENGLISH} "Set installation configuration."
735 LangString TITLE_ConfigPage2 ${LANG_ENGLISH} "Configuration (continued)"
736 LangString SUBTITLE_ConfigPage2 ${LANG_ENGLISH} "Set installation configuration."
738 LangString TITLE_InstallType ${LANG_ENGLISH} "Installation Type"
739 LangString SUBTITLE_InstallType ${LANG_ENGLISH} "Choose installation type."
741 LangString TITLE_WriteTemplates ${LANG_ENGLISH} "Create Templates"
742 LangString SUBTITLE_WriteTemplates ${LANG_ENGLISH} "Create a resource template for inclusion in the Director's configuration file."
744 !InsertMacro MUI_FUNCTION_DESCRIPTION_BEGIN
745 !InsertMacro MUI_DESCRIPTION_TEXT ${SecFileDaemon} $(DESC_SecFileDaemon)
746 !InsertMacro MUI_DESCRIPTION_TEXT ${SecStorageDaemon} $(DESC_SecStorageDaemon)
747 !InsertMacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
748 !InsertMacro MUI_DESCRIPTION_TEXT ${SecBatConsole} $(DESC_SecBatConsole)
749 !InsertMacro MUI_DESCRIPTION_TEXT ${SecTrayMonitor} $(DESC_SecTrayMonitor)
750 !InsertMacro MUI_DESCRIPTION_TEXT ${SecAllDrivesPlugin} $(DESC_SecAllDrivesPlugin)
751 !InsertMacro MUI_DESCRIPTION_TEXT ${SecOldExchangePlugin} $(DESC_SecOldExchangePlugin)
752 !InsertMacro MUI_FUNCTION_DESCRIPTION_END
756 UninstallText "This will uninstall Bacula. Click Uninstall to continue."
759 ; Shutdown any baculum that could be running
760 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
761 nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
762 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill'
763 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
766 ; ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
767 ; Remove Bacula File Daemon service
768 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /remove'
770 ; Remove Bacula Storage Daemon service
771 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /remove'
773 nsExec::ExecToLog '"$INSTDIR\plugins\exchange-fd.dll" /remove'
775 ; remove registry keys
776 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
777 DeleteRegKey HKLM "Software\Bacula"
779 ; remove start menu items
780 SetShellVarContext all
781 Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
782 RMDir /REBOOTOK "$SMPROGRAMS\Bacula"
784 ; remove files and uninstaller (preserving config for now)
785 Delete /REBOOTOK "$INSTDIR\doc\*"
786 Delete /REBOOTOK "$INSTDIR\help\*"
787 Delete /REBOOTOK "$INSTDIR\plugins\*"
788 Delete /REBOOTOK "$INSTDIR\openssl.exe"
789 Delete /REBOOTOK "$INSTDIR\bacula-fd.exe"
790 Delete /REBOOTOK "$INSTDIR\bat.exe"
791 Delete /REBOOTOK "$INSTDIR\bacula-tray-monitor.exe"
792 Delete /REBOOTOK "$INSTDIR\bsleep.exe"
793 Delete /REBOOTOK "$INSTDIR\bsmtp.exe"
794 Delete /REBOOTOK "$INSTDIR\bconsole.exe"
795 Delete /REBOOTOK "$INSTDIR\expr64.exe"
796 Delete /REBOOTOK "$INSTDIR\snooze.exe"
797 Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
798 Delete /REBOOTOK "$INSTDIR\LICENSE"
799 Delete /REBOOTOK "$INSTDIR\Readme.txt"
800 Delete /REBOOTOK "$INSTDIR\*.dll"
801 Delete /REBOOTOK "$INSTDIR\plugins\alldrives-fd.dll"
802 Delete /REBOOTOK "$INSTDIR\plugins\exchange-fd.dll"
804 ; Check for existing installation
805 MessageBox MB_YESNO|MB_ICONQUESTION \
806 "Would you like to delete the current configuration files and the working state file?" IDNO NoDel
807 Delete /REBOOTOK "$INSTDIR\*"
808 Delete /REBOOTOK "$INSTDIR\bin32\*"
809 Delete /REBOOTOK "$INSTDIR\working\*"
810 Delete /REBOOTOK "$INSTDIR\plugins\*"
811 Delete /REBOOTOK "$INSTDIR\working\*"
812 Delete /REBOOTOK "$INSTDIR\*"
813 RMDir "$INSTDIR\plugins"
814 RMDir "$INSTDIR\working"
815 RMDir "$INSTDIR\bin32"
816 RMDir /REBOOTOK "$INSTDIR\plugins"
817 RMDir /REBOOTOK "$INSTDIR\working"
818 RMDir /REBOOTOK "$INSTDIR"
821 ; remove directories used
822 RMDir "$INSTDIR\plugins"
823 RMDir "$INSTDIR\working"
825 RMDir "$INSTDIR\help"
830 ; $0 - Service Name (ie Bacula-FD)
831 ; $1 - Service Description (ie Bacula File Daemon)
832 ; $2 - Install as Service
833 ; $3 - Start Service now
835 Function InstallDaemon
836 Call InstallCommonFiles
838 WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
841 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
842 nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
843 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill'
844 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
846 nsExec::ExecToLog '"$INSTDIR\$0.exe" /remove'
847 nsExec::ExecToLog '"$INSTDIR\$0.exe" /install -c "$INSTDIR\$0.conf"'
858 nsExec::ExecToLog 'net start $0'
860 Exec '"$INSTDIR\$0.exe" /service -c "$INSTDIR\$0.conf"'
864 CreateShortCut "$SMPROGRAMS\Bacula\Start $1.lnk" "$INSTDIR\$0.exe" '-c "$INSTDIR\$0.conf"' "$INSTDIR\$0.exe" 0
868 Function GetComputerName
873 System::Call "kernel32::GetComputerNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2"
875 ${StrCase} $R0 $R0 "L"
882 !define ComputerNameDnsFullyQualified 3
890 System::Call "kernel32::GetComputerNameExA(i ${ComputerNameDnsFullyQualified}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
893 DetailPrint "GetComputerNameExA failed - LastError = $R2"
909 !define NameUserPrincipal 8
917 System::Call "secur32::GetUserNameExA(i ${NameUserPrincipal}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
920 DetailPrint "GetUserNameExA failed - LastError = $R2"
931 System::Call "advapi32::GetUserNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
934 DetailPrint "GetUserNameA failed - LastError = $R2"
946 Function ConfigEditAndCopy
949 ${If} ${FileExists} "$0\$1"
955 nsExec::ExecToLog '$INSTDIR\working\sed.exe -i.bak -f "$INSTDIR\working\config.sed" "$INSTDIR\working\$1.in"'
956 CopyFiles "$INSTDIR\working\$1.in" "$0\$1$R1"
961 Function GetSelectedComponents
964 ${If} ${SectionIsSelected} ${SecFileDaemon}
965 IntOp $R0 $R0 | ${ComponentFile}
967 ${If} ${SectionIsSelected} ${SecStorageDaemon}
968 IntOp $R0 $R0 | ${ComponentStorage}
970 ${If} ${SectionIsSelected} ${SecConsole}
971 IntOp $R0 $R0 | ${ComponentTextConsole}
973 ${If} ${SectionIsSelected} ${SecBatConsole}
974 IntOp $R0 $R0 | ${ComponentBatConsole}
976 ${If} ${SectionIsSelected} ${SecTrayMonitor}
977 ;IntOp $R0 $R0 | ${ComponentTrayMonitor}
979 ${If} ${SectionIsSelected} ${SecAllDrivesPlugin}
980 IntOp $R0 $R0 | ${ComponentAllDrivesPlugin}
982 ${If} ${SectionIsSelected} ${SecOldExchangePlugin}
983 IntOp $R0 $R0 | ${ComponentOldExchangePlugin}
988 Function PageComponentsShow
990 Call SelectPreviousComponents
991 Call UpdateComponentUI
994 Function PageDirectoryPre
995 ${If} $AutomaticInstall = 1
996 ${OrIf} $InstallType = ${UpgradeInstall}
1001 Function LeaveInstallPage
1002 Push "$INSTDIR\install.log"
1006 Function EnterWriteTemplates
1010 Call GetSelectedComponents
1013 IntOp $R0 $R0 & ${ComponentDirector}
1014 IntOp $R1 $NewComponents & ${ComponentsFileAndStorage}
1023 IntOp $R0 $NewComponents & ${ComponentFile}
1025 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" State 0
1026 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" Flags DISABLED
1027 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 3" State
1028 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 3" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1030 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" State 1
1031 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" Flags
1032 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 3" State "C:\$ConfigClientName.conf"
1035 IntOp $R0 $NewComponents & ${ComponentStorage}
1037 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" State 0
1038 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" Flags DISABLED
1039 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" State
1040 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1042 ;; TODO: See why this procedure causes a problem on Windows 2012
1043 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" State 0
1044 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" Flags
1045 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" State "$INSTDIR\$ConfigStorageName.conf"
1046 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST
1050 !InsertMacro MUI_HEADER_TEXT "$(TITLE_WriteTemplates)" "$(SUBTITLE_WriteTemplates)"
1051 !InsertMacro MUI_INSTALLOPTIONS_DISPLAY "WriteTemplates.ini"
1053 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 2" State
1055 File "/oname=$INSTDIR\working\client.conf.in" "client.conf.in"
1057 nsExec::ExecToLog '$INSTDIR\working\sed.exe -f "$INSTDIR\working\config.sed" "$INSTDIR\working\client.conf.in" "$INSTDIR\working\client.conf"'
1058 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 3" State
1060 CopyFiles "$INSTDIR\working\client.conf" "$R0"
1064 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 4" State
1066 File "/oname=$INSTDIR\working\storage.conf.in" "storage.conf.in"
1068 nsExec::ExecToLog '$INSTDIR\working\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\storage.conf.in"'
1069 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 5" State
1071 CopyFiles "$INSTDIR\working\storage.conf.in" "$R0"
1080 Function SelectPreviousComponents
1081 ${If} $InstallType <> ${NewInstall}
1082 IntOp $R1 $PreviousComponents & ${ComponentFile}
1084 !InsertMacro SelectSection ${SecFileDaemon}
1085 !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_RO}
1087 !InsertMacro UnselectSection ${SecFileDaemon}
1088 !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_RO}
1090 IntOp $R1 $PreviousComponents & ${ComponentStorage}
1092 !InsertMacro SelectSection ${SecStorageDaemon}
1093 !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_RO}
1095 !InsertMacro UnselectSection ${SecStorageDaemon}
1096 !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_RO}
1098 IntOp $R1 $PreviousComponents & ${ComponentTextConsole}
1100 !InsertMacro SelectSection ${SecConsole}
1101 !InsertMacro SetSectionFlag ${SecConsole} ${SF_RO}
1103 !InsertMacro UnselectSection ${SecConsole}
1104 !InsertMacro ClearSectionFlag ${SecConsole} ${SF_RO}
1106 IntOp $R1 $PreviousComponents & ${ComponentBatConsole}
1108 !InsertMacro SelectSection ${SecBatConsole}
1109 !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_RO}
1111 !InsertMacro UnselectSection ${SecBatConsole}
1112 !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_RO}
1114 IntOp $R1 $PreviousComponents & ${ComponentTrayMonitor}
1116 !InsertMacro SelectSection ${SecTrayMonitor}
1117 ;!InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_RO}
1119 !InsertMacro UnselectSection ${SecTrayMonitor}
1120 !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_RO}
1122 IntOp $R1 $PreviousComponents & ${ComponentAllDrivesPlugin}
1124 !InsertMacro SelectSection ${SecAllDrivesPlugin}
1125 !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1127 !InsertMacro UnselectSection ${SecAllDrivesPlugin}
1128 !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1130 ; IntOp $R1 $PreviousComponents & ${ComponentWinBMRPlugin}
1132 ; !InsertMacro SelectSection ${SecWinBMRPlugin}
1133 ; !InsertMacro SetSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1135 ; !InsertMacro UnselectSection ${SecWinBMRPlugin}
1136 ; !InsertMacro ClearSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1138 ; IntOp $R1 $PreviousComponents & ${ComponentOldExchangePlugin}
1140 ; !InsertMacro SelectSection ${SecOldExchangePlugin}
1141 ; !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1143 ; !InsertMacro UnselectSection ${SecOldExchangePlugin}
1144 ; !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1149 Function UpdateComponentUI
1153 Call GetSelectedComponents
1156 IntOp $R1 $R0 ^ $PreviousComponents
1157 IntOp $NewComponents $R0 & $R1
1159 ${If} $InstallType <> ${NewInstall}
1160 IntOp $R1 $NewComponents & ${ComponentFile}
1162 !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_BOLD}
1164 !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_BOLD}
1166 IntOp $R1 $NewComponents & ${ComponentStorage}
1168 !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1170 !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1172 IntOp $R1 $NewComponents & ${ComponentTextConsole}
1174 !InsertMacro SetSectionFlag ${SecConsole} ${SF_BOLD}
1176 !InsertMacro ClearSectionFlag ${SecConsole} ${SF_BOLD}
1178 IntOp $R1 $NewComponents & ${ComponentBatConsole}
1180 !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_BOLD}
1182 !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_BOLD}
1184 IntOp $R1 $NewComponents & ${ComponentTrayMonitor}
1186 ;!InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1188 !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1190 IntOp $R1 $NewComponents & ${ComponentAllDrivesPlugin}
1192 !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1194 !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1196 IntOp $R1 $NewComponents & ${ComponentOldExchangePlugin}
1198 !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1200 !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1204 GetDlgItem $R0 $HWNDPARENT 1
1206 IntOp $R1 $NewComponents & ${ComponentsRequiringUserConfig}
1208 SendMessage $R0 ${WM_SETTEXT} 0 "STR:Install"
1210 SendMessage $R0 ${WM_SETTEXT} 0 "STR:&Next >"
1217 !include "InstallType.nsh"
1218 !include "ConfigPage1.nsh"
1219 !include "ConfigPage2.nsh"
1220 !include "DumpLog.nsh"