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"
80 OutFile "${OUT_DIR}\bacula-win${WINVER}-${VERSION}.exe"
82 Caption "Bacula 64 bit Edition ${VERSION}"
83 VIProductVersion ${VERSION}.1
84 VIAddVersionKey CompanyName "Bacula Project"
85 VIAddVersionKey LegalCopyright "Kern Sibbald"
86 VIAddVersionKey FileDescription "Bacula network backup and restore"
87 VIAddVersionKey FileVersion win${WINVER}-${VERSION}
88 VIAddVersionKey ProductVersion win${WINVER}-${VERSION}
89 VIAddVersionKey ProductName "Bacula"
90 VIAddVersionKey InternalName "Bacula"
91 VIAddVersionKey LegalTrademarks "Bacula is a registered trademark of Kern Sibbald"
92 VIAddVersionKey OriginalFilename "bacula.exe"
94 InstallDir "C:\Program Files\Bacula"
95 InstallDirRegKey HKLM "Software\Bacula" "InstallLocation"
101 !insertmacro GetParent
112 !define MUI_COMPONENTSPAGE_SMALLDESC
114 !define MUI_HEADERIMAGE
115 !define MUI_BGCOLOR 739AB9
116 !define MUI_HEADERIMAGE_BITMAP "bacula-logo.bmp"
118 !InsertMacro MUI_PAGE_WELCOME
119 !InsertMacro MUI_PAGE_LICENSE "${SRC_DIR}\LICENSE"
120 Page custom EnterInstallType
121 !define MUI_PAGE_CUSTOMFUNCTION_SHOW PageComponentsShow
122 !InsertMacro MUI_PAGE_COMPONENTS
123 !define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
124 !InsertMacro MUI_PAGE_DIRECTORY
125 Page custom EnterConfigPage1 LeaveConfigPage1
126 Page custom EnterConfigPage2 LeaveConfigPage2
127 !Define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveInstallPage
128 !InsertMacro MUI_PAGE_INSTFILES
129 Page custom EnterWriteTemplates
130 !Define MUI_FINISHPAGE_SHOWREADME $INSTDIR\Readme.txt
131 !InsertMacro MUI_PAGE_FINISH
133 !InsertMacro MUI_UNPAGE_WELCOME
134 !InsertMacro MUI_UNPAGE_CONFIRM
135 !InsertMacro MUI_UNPAGE_INSTFILES
136 !InsertMacro MUI_UNPAGE_FINISH
138 !define MUI_ABORTWARNING
140 !InsertMacro MUI_LANGUAGE "English"
142 !InsertMacro GetParameters
143 !InsertMacro GetOptions
145 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."
147 !InsertMacro MUI_RESERVEFILE_INSTALLOPTIONS
163 Var ConfigClientMaxJobs
164 Var ConfigClientPassword
165 Var ConfigClientInstallService
166 Var ConfigClientStartService
168 Var ConfigStorageName
169 Var ConfigStoragePort
170 Var ConfigStorageMaxJobs
171 Var ConfigStoragePassword
172 Var ConfigStorageInstallService
173 Var ConfigStorageStartService
175 Var ConfigDirectorName
176 Var ConfigDirectorPort
177 Var ConfigDirectorMaxJobs
178 Var ConfigDirectorPassword
179 Var ConfigDirectorAddress
180 Var ConfigDirectorMailServer
181 Var ConfigDirectorMailAddress
183 Var ConfigDirectorInstallService
184 Var ConfigDirectorStartService
186 Var ConfigMonitorName
187 Var ConfigMonitorPassword
189 Var LocalDirectorPassword
195 Var PostgreSQLVersion
201 !define UpgradeInstall 1
202 !define MigrateInstall 2
205 Var PreviousComponents
208 ; Bit 0 = File Service
209 ; 1 = Storage Service
210 ; 2 = Director Service
211 ; 3 = Command Console
213 ; 5 = wxWidgits Console
214 ; 6 = Documentation (PDF)
215 ; 7 = Documentation (HTML)
216 ; 8 = alldrives Plugin
217 ; 9 = Old Exchange Plugin
219 ; 11 = winbmr Plugin (not implemented in community version)
221 !define ComponentFile 1
222 !define ComponentStorage 2
223 !define ComponentDirector 4
224 !define ComponentTextConsole 8
225 !define ComponentBatConsole 16
226 !define ComponentGUIConsole 32
227 !define ComponentPDFDocs 64
228 !define ComponentHTMLDocs 128
229 !define ComponentAllDrivesPlugin 256
230 !define ComponentOldExchangePlugin 512
231 !define ComponentTrayMonitor 1024
233 !define ComponentsRequiringUserConfig 63
234 !define ComponentsFileAndStorage 3
235 !define ComponentsFileAndStorageAndDirector 7
236 !define ComponentsDirectorAndTextGuiConsoles 60
237 !define ComponentsTextAndGuiConsoles 56
248 ; Process Command Line Options
252 StrCpy $CommonFilesDone 0
254 StrCpy $AutomaticInstall 0
255 StrCpy $InstallType ${NewInstall}
256 StrCpy $OldInstallDir ""
257 StrCpy $PreviousComponents 0
258 StrCpy $NewComponents 0
260 StrCpy $MySQLVersion ""
261 StrCpy $PostgreSQLPath ""
262 StrCpy $PostgreSQLVersion ""
263 StrCpy $LocalDirectorPassword ""
271 MessageBox MB_OK "This is a 64 bit installer, but the OS is not an x64 -- Aborting ..." /SD IDOK
275 ${GetOptions} $R0 "/noservice" $R1
280 ${GetOptions} $R0 "/nostart" $R1
287 ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
296 Pop $LocalHostAddress
300 ; Configuration Defaults
302 StrCpy $ConfigClientName "$HostName-fd"
303 StrCpy $ConfigClientPort 9102
304 StrCpy $ConfigClientMaxJobs 10
305 ;StrCpy $ConfigClientPassword
306 StrCpy $ConfigClientInstallService "$OptService"
307 StrCpy $ConfigClientStartService "$OptStart"
309 StrCpy $ConfigStorageName "$HostName-sd"
310 StrCpy $ConfigStoragePort 9103
311 StrCpy $ConfigStorageMaxJobs 10
312 ;StrCpy $ConfigStoragePassword
313 StrCpy $ConfigStorageInstallService "$OptService"
314 StrCpy $ConfigStorageStartService "$OptStart"
315 StrCpy $ConfigDirectorPort 9101
317 StrCpy $ConfigMonitorName "$HostName-mon"
318 ;StrCpy $ConfigMonitorPassword
320 ; TEMP refers to temporary helper programs and not Bacula plugins!
322 CreateDirectory "$INSTDIR"
323 CreateDirectory "$INSTDIR\working"
324 File "/oname=$INSTDIR\working\openssl.exe" "${SRC_DIR}\openssl.exe"
325 File "/oname=$INSTDIR\working\libeay32.dll" "${SRC_DIR}\libeay32.dll"
326 File "/oname=$INSTDIR\working\ssleay32.dll" "${SRC_DIR}\ssleay32.dll"
327 File "/oname=$INSTDIR\working\sed.exe" "${SRC_DIR}\sed.exe"
329 !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
330 !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
332 SetPluginUnload alwaysoff
334 ; Generate random File daemon password
335 nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
338 FileOpen $R1 "$INSTDIR\working\pw.txt" r
341 ${StrTrimNewLines} $ConfigClientPassword $R0
345 ; Generate random Storage daemon password
346 nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
349 FileOpen $R1 "$INSTDIR\working\pw.txt" r
352 ${StrTrimNewLines} $ConfigStoragePassword $R0
356 SetPluginUnload manual
358 ; Generate random monitor password
359 nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
362 FileOpen $R1 "$INSTDIR\working\pw.txt" r
365 ${StrTrimNewLines} $ConfigMonitorPassword $R0
373 Function .onSelChange
374 Call UpdateComponentUI
377 Function InstallCommonFiles
378 ${If} $CommonFilesDone = 0
379 SetOutPath "$INSTDIR"
382 SetOutPath "$INSTDIR"
383 !if "${BUILD_TOOLS}" == "MinGW32"
384 File "${SRC_DIR}\mingwm10.dll"
386 File "${SRC_DIR}\libwinpthread-1.dll"
387 File "${SRC_DIR}\pthreadGCE2.dll"
388 File "${SRC_DIR}\libgcc_s_seh-1.dll"
389 File "${SRC_DIR}\libstdc++-6.dll"
390 File "${SRC_DIR}\ssleay32.dll"
391 File "${SRC_DIR}\libeay32.dll"
392 File "${SRC_DIR}\zlib1.dll"
393 File "${SRC_DIR}\bacula.dll"
395 File "/oname=$INSTDIR\openssl.cnf" "${SRC_DIR}\openssl.cnf"
396 File "${SRC_DIR}\openssl.exe"
397 File "${SRC_DIR}\bsleep.exe"
398 File "${SRC_DIR}\bsmtp.exe"
399 File "${SRC_DIR}\expr64.exe"
400 File "${SRC_DIR}\snooze.exe"
402 CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
404 StrCpy $CommonFilesDone 1
408 Section "-Initialize"
410 WriteRegStr HKLM Software\Bacula InstallLocation "$INSTDIR"
412 Call GetSelectedComponents
414 WriteRegDWORD HKLM Software\Bacula Components $R2
416 ; remove start menu items
417 SetShellVarContext all
419 Delete /REBOOTOK "$SMPROGRAMS\Bacula\Configuration\*"
420 Delete /REBOOTOK "$SMPROGRAMS\Bacula\Documentation\*"
421 Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
422 RMDir "$SMPROGRAMS\Bacula\Configuration"
423 RMDir "$SMPROGRAMS\Bacula\Documentation"
424 RMDir "$SMPROGRAMS\Bacula"
425 CreateDirectory "$SMPROGRAMS\Bacula"
426 CreateDirectory "$SMPROGRAMS\Bacula\Configuration"
427 CreateDirectory "$SMPROGRAMS\Bacula\Documentation"
429 CreateDirectory "$INSTDIR"
430 CreateDirectory "$INSTDIR\working"
431 CreateDirectory "$INSTDIR\plugins"
433 SetOutPath "$INSTDIR"
434 File "${SRC_DIR}\LICENSE"
435 Delete /REBOOTOK "$INSTDIR\License.txt"
437 ; Output a series of SED commands to configure the .conf file(s)
438 FileOpen $R1 $INSTDIR\working\config.sed w
439 FileWrite $R1 "s;@VERSION@;${VERSION};g$\r$\n"
440 FileWrite $R1 "s;@DATE@;${__DATE__};g$\r$\n"
441 FileWrite $R1 "s;@DISTNAME@;Windows;g$\r$\n"
443 StrCpy $R2 ${BUILD_TOOLS}
449 FileWrite $R1 "s;@DISTVER@;$R2;g$\r$\n"
451 ${StrRep} $R2 "$INSTDIR\working" "\" "\\\\"
452 FileWrite $R1 's;@working_dir@;$R2;g$\r$\n'
454 ${StrRep} $R2 "$INSTDIR" "\" "\\\\"
455 FileWrite $R1 's;@bin_dir@;$R2;g$\r$\n'
456 ${StrRep} $R2 "$INSTDIR" "\" "\\"
457 FileWrite $R1 's;@bin_dir_cmd@;$R2;g$\r$\n'
459 ${StrRep} $R2 "$INSTDIR\plugins" "\" "\\\\"
460 FileWrite $R1 's;@fdplugins_dir@;$R2;g$\r$\n'
462 ${StrRep} $R2 "$INSTDIR" "\" "/"
463 FileWrite $R1 "s;@BUILD_DIR@;$R2;g$\r$\n"
465 FileWrite $R1 "s;@client_address@;$LocalHostAddress;g$\r$\n"
466 FileWrite $R1 "s;@client_name@;$ConfigClientName;g$\r$\n"
467 FileWrite $R1 "s;@client_port@;$ConfigClientPort;g$\r$\n"
468 FileWrite $R1 "s;@client_maxjobs@;$ConfigClientMaxJobs;g$\r$\n"
469 FileWrite $R1 "s;@client_password@;$ConfigClientPassword;g$\r$\n"
470 FileWrite $R1 "s;@storage_address@;$LocalHostAddress;g$\r$\n"
471 FileWrite $R1 "s;@storage_name@;$ConfigStorageName;g$\r$\n"
472 FileWrite $R1 "s;@storage_port@;$ConfigStoragePort;g$\r$\n"
473 FileWrite $R1 "s;@storage_maxjobs@;$ConfigStorageMaxJobs;g$\r$\n"
474 FileWrite $R1 "s;@storage_password@;$ConfigStoragePassword;g$\r$\n"
475 FileWrite $R1 "s;@director_name@;$ConfigDirectorName;g$\r$\n"
476 FileWrite $R1 "s;@director_port@;$ConfigDirectorPort;g$\r$\n"
477 FileWrite $R1 "s;@director_password@;$ConfigDirectorPassword;g$\r$\n"
478 FileWrite $R1 "s;@director_address@;$ConfigDirectorAddress;g$\r$\n"
479 FileWrite $R1 "s;@monitor_name@;$ConfigMonitorName;g$\r$\n"
480 FileWrite $R1 "s;@monitor_password@;$ConfigMonitorPassword;g$\r$\n"
484 ${If} ${FileExists} "$OldInstallDir\bacula-fd.exe"
485 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
486 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
488 nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /remove' ; Remove existing service
491 ${If} ${FileExists} "$INSTDIR\bacula-fd.exe"
492 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill' ; Shutdown any bacula that could be running
493 nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
496 ${If} ${FileExists} "$OldInstallDir\bin\bacula-sd.exe"
497 nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill' ; Shutdown any bacula that could be running
498 nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill' ; Shutdown any bacula that could be running
499 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
501 nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /remove' ; Remove existing service
504 ${If} ${FileExists} "$INSTDIR\bacula-sd.exe"
505 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill' ; Shutdown any bacula that could be running
506 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
513 SectionGroup "Client" SecGroupClient
515 Section "File Service" SecFileDaemon
518 SetOutPath "$INSTDIR"
520 File "${SRC_DIR}\bacula-fd.exe"
521 Delete "$INSTDIR\working\bacula-fd.conf.in"
522 File "/oname=$INSTDIR\working\bacula-fd.conf.in" "bacula-fd.conf.in"
525 StrCpy $1 bacula-fd.conf
526 Call ConfigEditAndCopy
529 StrCpy $1 "File Service"
530 StrCpy $2 $ConfigClientInstallService
531 StrCpy $3 $ConfigClientStartService
535 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Client Configuration.lnk" "write.exe" '"$INSTDIR\bacula-fd.conf"'
540 SectionGroup "Server" SecGroupServer
542 Section "Storage Service" SecStorageDaemon
545 SetOutPath "$INSTDIR"
547 File "${SRC_DIR}\bacula-sd.exe"
548 File "${SRC_DIR}\bcopy.exe"
549 File "${SRC_DIR}\bextract.exe"
550 File "${SRC_DIR}\bls.exe"
552 File "/oname=$INSTDIR\working\bacula-sd.conf.in" "bacula-sd.conf.in"
555 StrCpy $1 bacula-sd.conf
556 Call ConfigEditAndCopy
558 # File "${SRC_DIR}\loaderinfo.exe"
559 # File "${SRC_DIR}\mt.exe"
560 # File "${SRC_DIR}\mtx.exe"
561 # File "${SRC_DIR}\scsitape.exe"
562 # File "${SRC_DIR}\tapeinfo.exe"
563 # File "${SRC_DIR}\bscan.exe"
564 # File "${SRC_DIR}\btape.exe"
565 # File "${SRC_DIR}\scsilist.exe"
566 # File "${SRC_DIR}\mkisofs.exe"
567 # File "${SRC_DIR}\growisofs.exe"
569 # File "/oname=$INSTDIR\working\mtx-changer.cmd" "scripts\mtx-changer.cmd"
571 # StrCpy $0 "$INSTDIR\bin"
572 # StrCpy $1 mtx-changer.cmd
573 # Call ConfigEditAndCopy
575 # File "/oname=$INSTDIR\working\disk-changer.cmd" "scripts\disk-changer.cmd"
577 # StrCpy $0 "$INSTDIR"
578 # StrCpy $1 disk-changer.cmd
579 # Call ConfigEditAndCopy
582 StrCpy $1 "Storage Service"
583 StrCpy $2 $ConfigStorageInstallService
584 StrCpy $3 $ConfigStorageStartService
587 # CreateShortCut "$SMPROGRAMS\Bacula\Configuration\List Devices.lnk" "$INSTDIR\bin\scsilist.exe" "/pause"
588 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Storage Configuration.lnk" "write.exe" '"$INSTDIR\bacula-sd.conf"'
593 SectionGroup "Consoles" SecGroupConsoles
595 Section "Command Console" SecConsole
598 SetOutPath "$INSTDIR"
600 File "${SRC_DIR}\bconsole.exe"
601 Call InstallCommonFiles
603 File "/oname=$INSTDIR\working\bconsole.conf.in" "bconsole.conf.in"
605 StrCpy $1 bconsole.conf
606 Call ConfigEditAndCopy
608 CreateShortCut "$SMPROGRAMS\Bacula\bconsole.lnk" "$INSTDIR\bconsole.exe" '-c "$INSTDIR\bconsole.conf"' "$INSTDIR\bconsole.exe" 0
609 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Command Console Configuration.lnk" "write.exe" '"$INSTDIR\bconsole.conf"'
613 Section "Bat Console" SecBatConsole
616 SetOutPath "$INSTDIR"
618 !if "${BUILD_BAT}" == "yes"
619 Call InstallCommonFiles
620 File "${SRC64_DIR}\QtCore4.dll"
621 File "${SRC64_DIR}\QtGui4.dll"
622 File "${SRC64_DIR}\bat.exe"
624 File "/oname=$INSTDIR\working\bat.conf.in" "bat.conf.in"
627 Call ConfigEditAndCopy
629 SetOutPath "$INSTDIR\help"
630 File "${SRC64_DIR}\help\*"
631 SetOutPath "$INSTDIR"
633 ; Create Start Menu entry
634 CreateShortCut "$SMPROGRAMS\Bacula\Bat.lnk" "$INSTDIR\bat.exe" '-c "$INSTDIR\bat.conf"' "$INSTDIR\bat.exe" 0
635 CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Bat Configuration.lnk" "write.exe" '"$INSTDIR\bat.conf"'
636 SetOutPath "$INSTDIR"
641 Section "Tray Monitor" SecTrayMonitor
644 SetOutPath "$INSTDIR"
646 !if "${BUILD_BAT}" == "yes"
647 Call InstallCommonFiles
648 File "${SRC64_DIR}\QtCore4.dll"
649 File "${SRC64_DIR}\QtGui4.dll"
650 ;File "${SRC64_DIR}\bacula-tray-monitor.exe"
652 ;File "/oname=$INSTDIR\working\bacula-tray-monitor.conf.in" "bacula-tray-monitor.conf.in"
653 ;StrCpy $0 "$INSTDIR"
654 ;StrCpy $1 bacula-tray-monitor.conf
655 ;Call ConfigEditAndCopy
657 ; Create Start Menu entry
658 ;CreateShortCut "$SMPROGRAMS\Bacula\TrayMonitor.lnk" "$INSTDIR\bacula-tray-monitor.exe" "" "$INSTDIR\bacula-tray-monitor.exe" 0
659 SetOutPath "$INSTDIR"
666 SectionGroup "Plugins" SecGroupPlugins
668 Section "alldrives Plugin" SecAllDrivesPlugin
671 SetOutPath "$INSTDIR\plugins"
672 File "${SRC_DIR}\alldrives-fd.dll"
673 SetOutPath "$INSTDIR"
677 Section "Old (deprecated) Exchange Plugin" SecOldExchangePlugin
680 SetOutPath "$INSTDIR\plugins"
681 File "${SRC_DIR}\exchange-fd.dll"
682 SetOutPath "$INSTDIR"
692 nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bacula-fd.conf" /G SYSTEM:F Administrators:F'
693 nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bacula-sd.conf" /G SYSTEM:F Administrators:F'
694 nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bat.conf" /G SYSTEM:F Administrators:F'
697 ; Write the uninstall keys for Windows & create Start Menu entry
698 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula"
699 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "InstallLocation" "$INSTDIR"
700 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayVersion" "${VERSION}"
701 ${StrTok} $R0 "${VERSION}" "." 0 0
702 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMajor" $R0
703 ${StrTok} $R0 "${VERSION}" "." 1 0
704 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMinor" $R0
705 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoModify" 1
706 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoRepair" 1
707 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLUpdateInfo" "http://www.bacula.org"
708 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLInfoAbout" "http://www.bacula.org"
709 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "HelpLink" "http://www.bacula.org?page=support"
710 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
711 WriteUninstaller "$INSTDIR\Uninstall.exe"
712 CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
715 nsExec::ExecToLog 'net start bacula-fd'
716 nsExec::ExecToLog 'net start bacula-sd'
718 Exec '"$INSTDIR\bacula-fd.exe" /service -c "$INSTDIR\bacula-fd.conf"'
719 Exec '"$INSTDIR\bacula-sd.exe" /service -c "$INSTDIR\bacula-sd.conf"'
725 ; Extra Page descriptions
727 LangString DESC_SecFileDaemon ${LANG_ENGLISH} "Install Bacula 64 bit File Daemon on this system."
728 LangString DESC_SecStorageDaemon ${LANG_ENGLISH} "Install Bacula 64 bit Storage Daemon on this system."
729 LangString DESC_SecConsole ${LANG_ENGLISH} "Install command console program on this system."
730 LangString DESC_SecBatConsole ${LANG_ENGLISH} "Install Bat graphical console program on this system."
731 LangString DESC_SecTrayMonitor ${LANG_ENGLISH} "Install Tray Monitor graphical program on this system."
732 LangString DESC_SecAllDrivesPlugin ${LANG_ENGLISH} "Install alldrives Plugin on this system."
733 LangString DESC_SecOldExchangePlugin ${LANG_ENGLISH} "Install old (deprecated) Exchange Plugin on this system."
735 LangString TITLE_ConfigPage1 ${LANG_ENGLISH} "Configuration"
736 LangString SUBTITLE_ConfigPage1 ${LANG_ENGLISH} "Set installation configuration."
738 LangString TITLE_ConfigPage2 ${LANG_ENGLISH} "Configuration (continued)"
739 LangString SUBTITLE_ConfigPage2 ${LANG_ENGLISH} "Set installation configuration."
741 LangString TITLE_InstallType ${LANG_ENGLISH} "Installation Type"
742 LangString SUBTITLE_InstallType ${LANG_ENGLISH} "Choose installation type."
744 LangString TITLE_WriteTemplates ${LANG_ENGLISH} "Create Templates"
745 LangString SUBTITLE_WriteTemplates ${LANG_ENGLISH} "Create a resource template for inclusion in the Director's configuration file."
747 !InsertMacro MUI_FUNCTION_DESCRIPTION_BEGIN
748 !InsertMacro MUI_DESCRIPTION_TEXT ${SecFileDaemon} $(DESC_SecFileDaemon)
749 !InsertMacro MUI_DESCRIPTION_TEXT ${SecStorageDaemon} $(DESC_SecStorageDaemon)
750 !InsertMacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
751 !InsertMacro MUI_DESCRIPTION_TEXT ${SecBatConsole} $(DESC_SecBatConsole)
752 !InsertMacro MUI_DESCRIPTION_TEXT ${SecTrayMonitor} $(DESC_SecTrayMonitor)
753 !InsertMacro MUI_DESCRIPTION_TEXT ${SecAllDrivesPlugin} $(DESC_SecAllDrivesPlugin)
754 !InsertMacro MUI_DESCRIPTION_TEXT ${SecOldExchangePlugin} $(DESC_SecOldExchangePlugin)
755 !InsertMacro MUI_FUNCTION_DESCRIPTION_END
759 UninstallText "This will uninstall Bacula. Click Uninstall to continue."
762 ; Shutdown any baculum that could be running
763 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
764 nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
765 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill'
766 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
769 ; ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
770 ; Remove Bacula File Daemon service
771 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /remove'
773 ; Remove Bacula Storage Daemon service
774 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /remove'
776 nsExec::ExecToLog '"$INSTDIR\plugins\exchange-fd.dll" /remove'
778 ; remove registry keys
779 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
780 DeleteRegKey HKLM "Software\Bacula"
782 ; remove start menu items
783 SetShellVarContext all
784 Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
785 RMDir /REBOOTOK "$SMPROGRAMS\Bacula"
787 ; remove files and uninstaller (preserving config for now)
788 Delete /REBOOTOK "$INSTDIR\doc\*"
789 Delete /REBOOTOK "$INSTDIR\help\*"
790 Delete /REBOOTOK "$INSTDIR\plugins\*"
791 Delete /REBOOTOK "$INSTDIR\openssl.exe"
792 Delete /REBOOTOK "$INSTDIR\bacula-fd.exe"
793 Delete /REBOOTOK "$INSTDIR\bat.exe"
794 Delete /REBOOTOK "$INSTDIR\bacula-tray-monitor.exe"
795 Delete /REBOOTOK "$INSTDIR\bsleep.exe"
796 Delete /REBOOTOK "$INSTDIR\bsmtp.exe"
797 Delete /REBOOTOK "$INSTDIR\bconsole.exe"
798 Delete /REBOOTOK "$INSTDIR\expr64.exe"
799 Delete /REBOOTOK "$INSTDIR\snooze.exe"
800 Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
801 Delete /REBOOTOK "$INSTDIR\LICENSE"
802 Delete /REBOOTOK "$INSTDIR\Readme.txt"
803 Delete /REBOOTOK "$INSTDIR\*.dll"
804 Delete /REBOOTOK "$INSTDIR\plugins\alldrives-fd.dll"
805 Delete /REBOOTOK "$INSTDIR\plugins\exchange-fd.dll"
807 ; Check for existing installation
808 MessageBox MB_YESNO|MB_ICONQUESTION \
809 "Would you like to delete the current configuration files and the working state file?" IDNO NoDel
810 Delete /REBOOTOK "$INSTDIR\*"
811 Delete /REBOOTOK "$INSTDIR\bin32\*"
812 Delete /REBOOTOK "$INSTDIR\working\*"
813 Delete /REBOOTOK "$INSTDIR\plugins\*"
814 Delete /REBOOTOK "$INSTDIR\working\*"
815 Delete /REBOOTOK "$INSTDIR\*"
816 RMDir "$INSTDIR\plugins"
817 RMDir "$INSTDIR\working"
818 RMDir "$INSTDIR\bin32"
819 RMDir /REBOOTOK "$INSTDIR\plugins"
820 RMDir /REBOOTOK "$INSTDIR\working"
821 RMDir /REBOOTOK "$INSTDIR"
824 ; remove directories used
825 RMDir "$INSTDIR\plugins"
826 RMDir "$INSTDIR\working"
828 RMDir "$INSTDIR\help"
833 ; $0 - Service Name (ie Bacula-FD)
834 ; $1 - Service Description (ie Bacula File Daemon)
835 ; $2 - Install as Service
836 ; $3 - Start Service now
838 Function InstallDaemon
839 Call InstallCommonFiles
841 WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
844 nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
845 nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
846 nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill'
847 nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
849 nsExec::ExecToLog '"$INSTDIR\$0.exe" /remove'
850 nsExec::ExecToLog '"$INSTDIR\$0.exe" /install -c "$INSTDIR\$0.conf"'
861 nsExec::ExecToLog 'net start $0'
863 Exec '"$INSTDIR\$0.exe" /service -c "$INSTDIR\$0.conf"'
867 CreateShortCut "$SMPROGRAMS\Bacula\Start $1.lnk" "$INSTDIR\$0.exe" '-c "$INSTDIR\$0.conf"' "$INSTDIR\$0.exe" 0
871 Function GetComputerName
876 System::Call "kernel32::GetComputerNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2"
878 ${StrCase} $R0 $R0 "L"
885 !define ComputerNameDnsFullyQualified 3
893 System::Call "kernel32::GetComputerNameExA(i ${ComputerNameDnsFullyQualified}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
896 DetailPrint "GetComputerNameExA failed - LastError = $R2"
912 !define NameUserPrincipal 8
920 System::Call "secur32::GetUserNameExA(i ${NameUserPrincipal}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
923 DetailPrint "GetUserNameExA failed - LastError = $R2"
934 System::Call "advapi32::GetUserNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
937 DetailPrint "GetUserNameA failed - LastError = $R2"
949 Function ConfigEditAndCopy
952 ${If} ${FileExists} "$0\$1"
958 nsExec::ExecToLog '$INSTDIR\working\sed.exe -i.bak -f "$INSTDIR\working\config.sed" "$INSTDIR\working\$1.in"'
959 CopyFiles "$INSTDIR\working\$1.in" "$0\$1$R1"
964 Function GetSelectedComponents
967 ${If} ${SectionIsSelected} ${SecFileDaemon}
968 IntOp $R0 $R0 | ${ComponentFile}
970 ${If} ${SectionIsSelected} ${SecStorageDaemon}
971 IntOp $R0 $R0 | ${ComponentStorage}
973 ${If} ${SectionIsSelected} ${SecConsole}
974 IntOp $R0 $R0 | ${ComponentTextConsole}
976 ${If} ${SectionIsSelected} ${SecBatConsole}
977 IntOp $R0 $R0 | ${ComponentBatConsole}
979 ${If} ${SectionIsSelected} ${SecTrayMonitor}
980 ;IntOp $R0 $R0 | ${ComponentTrayMonitor}
982 ${If} ${SectionIsSelected} ${SecAllDrivesPlugin}
983 IntOp $R0 $R0 | ${ComponentAllDrivesPlugin}
985 ${If} ${SectionIsSelected} ${SecOldExchangePlugin}
986 IntOp $R0 $R0 | ${ComponentOldExchangePlugin}
991 Function PageComponentsShow
993 Call SelectPreviousComponents
994 Call UpdateComponentUI
997 Function PageDirectoryPre
998 ${If} $AutomaticInstall = 1
999 ${OrIf} $InstallType = ${UpgradeInstall}
1004 Function LeaveInstallPage
1005 Push "$INSTDIR\install.log"
1009 Function EnterWriteTemplates
1013 Call GetSelectedComponents
1016 IntOp $R0 $R0 & ${ComponentDirector}
1017 IntOp $R1 $NewComponents & ${ComponentsFileAndStorage}
1026 IntOp $R0 $NewComponents & ${ComponentFile}
1028 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" State 0
1029 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" Flags DISABLED
1030 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 3" State
1031 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 3" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1033 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" State 1
1034 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 2" Flags
1035 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 3" State "C:\$ConfigClientName.conf"
1038 IntOp $R0 $NewComponents & ${ComponentStorage}
1040 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" State 0
1041 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" Flags DISABLED
1042 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" State
1043 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1045 ;; TODO: See why this procedure causes a problem on Windows 2012
1046 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" State 0
1047 DeleteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 4" Flags
1048 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" State "$INSTDIR\$ConfigStorageName.conf"
1049 WriteINIStr "$INSTDIR\working\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST
1053 !InsertMacro MUI_HEADER_TEXT "$(TITLE_WriteTemplates)" "$(SUBTITLE_WriteTemplates)"
1054 !InsertMacro MUI_INSTALLOPTIONS_DISPLAY "WriteTemplates.ini"
1056 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 2" State
1058 File "/oname=$INSTDIR\working\client.conf.in" "client.conf.in"
1060 nsExec::ExecToLog '$INSTDIR\working\sed.exe -f "$INSTDIR\working\config.sed" "$INSTDIR\working\client.conf.in" "$INSTDIR\working\client.conf"'
1061 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 3" State
1063 CopyFiles "$INSTDIR\working\client.conf" "$R0"
1067 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 4" State
1069 File "/oname=$INSTDIR\working\storage.conf.in" "storage.conf.in"
1071 nsExec::ExecToLog '$INSTDIR\working\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\storage.conf.in"'
1072 !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 5" State
1074 CopyFiles "$INSTDIR\working\storage.conf.in" "$R0"
1083 Function SelectPreviousComponents
1084 ${If} $InstallType <> ${NewInstall}
1085 IntOp $R1 $PreviousComponents & ${ComponentFile}
1087 !InsertMacro SelectSection ${SecFileDaemon}
1088 !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_RO}
1090 !InsertMacro UnselectSection ${SecFileDaemon}
1091 !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_RO}
1093 IntOp $R1 $PreviousComponents & ${ComponentStorage}
1095 !InsertMacro SelectSection ${SecStorageDaemon}
1096 !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_RO}
1098 !InsertMacro UnselectSection ${SecStorageDaemon}
1099 !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_RO}
1101 IntOp $R1 $PreviousComponents & ${ComponentTextConsole}
1103 !InsertMacro SelectSection ${SecConsole}
1104 !InsertMacro SetSectionFlag ${SecConsole} ${SF_RO}
1106 !InsertMacro UnselectSection ${SecConsole}
1107 !InsertMacro ClearSectionFlag ${SecConsole} ${SF_RO}
1109 IntOp $R1 $PreviousComponents & ${ComponentBatConsole}
1111 !InsertMacro SelectSection ${SecBatConsole}
1112 !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_RO}
1114 !InsertMacro UnselectSection ${SecBatConsole}
1115 !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_RO}
1117 IntOp $R1 $PreviousComponents & ${ComponentTrayMonitor}
1119 !InsertMacro SelectSection ${SecTrayMonitor}
1120 ;!InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_RO}
1122 !InsertMacro UnselectSection ${SecTrayMonitor}
1123 !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_RO}
1125 IntOp $R1 $PreviousComponents & ${ComponentAllDrivesPlugin}
1127 !InsertMacro SelectSection ${SecAllDrivesPlugin}
1128 !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1130 !InsertMacro UnselectSection ${SecAllDrivesPlugin}
1131 !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1133 ; IntOp $R1 $PreviousComponents & ${ComponentWinBMRPlugin}
1135 ; !InsertMacro SelectSection ${SecWinBMRPlugin}
1136 ; !InsertMacro SetSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1138 ; !InsertMacro UnselectSection ${SecWinBMRPlugin}
1139 ; !InsertMacro ClearSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1141 ; IntOp $R1 $PreviousComponents & ${ComponentOldExchangePlugin}
1143 ; !InsertMacro SelectSection ${SecOldExchangePlugin}
1144 ; !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1146 ; !InsertMacro UnselectSection ${SecOldExchangePlugin}
1147 ; !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1152 Function UpdateComponentUI
1156 Call GetSelectedComponents
1159 IntOp $R1 $R0 ^ $PreviousComponents
1160 IntOp $NewComponents $R0 & $R1
1162 ${If} $InstallType <> ${NewInstall}
1163 IntOp $R1 $NewComponents & ${ComponentFile}
1165 !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_BOLD}
1167 !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_BOLD}
1169 IntOp $R1 $NewComponents & ${ComponentStorage}
1171 !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1173 !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1175 IntOp $R1 $NewComponents & ${ComponentTextConsole}
1177 !InsertMacro SetSectionFlag ${SecConsole} ${SF_BOLD}
1179 !InsertMacro ClearSectionFlag ${SecConsole} ${SF_BOLD}
1181 IntOp $R1 $NewComponents & ${ComponentBatConsole}
1183 !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_BOLD}
1185 !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_BOLD}
1187 IntOp $R1 $NewComponents & ${ComponentTrayMonitor}
1189 ;!InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1191 !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1193 IntOp $R1 $NewComponents & ${ComponentAllDrivesPlugin}
1195 !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1197 !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1199 IntOp $R1 $NewComponents & ${ComponentOldExchangePlugin}
1201 !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1203 !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1207 GetDlgItem $R0 $HWNDPARENT 1
1209 IntOp $R1 $NewComponents & ${ComponentsRequiringUserConfig}
1211 SendMessage $R0 ${WM_SETTEXT} 0 "STR:Install"
1213 SendMessage $R0 ${WM_SETTEXT} 0 "STR:&Next >"
1220 !include "InstallType.nsh"
1221 !include "ConfigPage1.nsh"
1222 !include "ConfigPage2.nsh"
1223 !include "DumpLog.nsh"