1#
2# Copyright (C) 2000-2018 Kern Sibbald
3# License: BSD 2-Clause; see file LICENSE-FOSS
4#
5##{{NSIS_PLUS_BEGIN_PROJECT_SETTINGS}}##
6#NAME "Release"
7#       CMD -DSRC_DIR=release32 -DSRC32_DIR=..\win32_installer\release32 -DSRC64_DIR=..\win64_installer\release64 -DOUT_DIR=release32 -DWINVER=32 -DVERSION=6.7.9 -DBUILD_TOOLS=NSIS-3.0b0
8#       EXE C:\Program Files (x86)\NSIS\makensis.exe
9#       FLAGS 2
10##{{NSIS_PLUS_END_PROJECT_SETTINGS}}##
11
12; winbacula.nsi
13;
14; Began as a version written by Michel Meyers (michel@tcnnet.dyndns.org)
15;
16; Adapted by Kern Sibbald for native Win32 Bacula
17;    added a number of elements from Christopher Hull's installer
18;
19; D. Scott Barninger Nov 13 2004
20; D. Scott Barninger Dec 05 2004
21; D. Scott Barninger Apr 17 2005
22; Robert Nelson May 15 2006
23;
24; Kern Sibbald October 2010
25; Remove server installs and
26;   install into a single bacula directory
27;
28;
29; Command line options:
30;
31; /service    -
32; /start
33;
34; netsh firewall add portopening protocol=tcp port=9102 name="Bacula-FD"
35
36
37!define PRODUCT "Bacula"
38
39;
40; Include the Modern UI
41;
42
43!include "MUI.nsh"
44!include "LogicLib.nsh"
45!include "FileFunc.nsh"
46!include "Sections.nsh"
47!include "StrFunc.nsh"
48!include "WinMessages.nsh"
49!include "x64.nsh"
50
51;
52; Basics
53;
54; Name in Welcome screen
55Name "Bacula 32 bit"
56OutFile "${OUT_DIR}\bacula-win${WINVER}-${VERSION}.exe"
57SetCompressor lzma
58Caption "Bacula 32 bit Edition ${VERSION}"
59VIProductVersion ${VERSION}.1
60VIAddVersionKey CompanyName "Bacula Project"
61VIAddVersionKey LegalCopyright "Kern Sibbald"
62VIAddVersionKey FileDescription "Bacula network backup and restore"
63VIAddVersionKey FileVersion win${WINVER}-${VERSION}
64VIAddVersionKey ProductVersion win${WINVER}-${VERSION}
65VIAddVersionKey ProductName "Bacula"
66VIAddVersionKey InternalName "Bacula"
67VIAddVersionKey LegalTrademarks "Bacula is a registered trademark of Kern Sibbald"
68VIAddVersionKey OriginalFilename "bacula.exe"
69
70InstallDir "C:\Program Files\Bacula"
71InstallDirRegKey HKLM "Software\Bacula" "InstallLocation"
72
73InstType "Client"
74InstType "Server"
75;InstType "Full"
76
77!insertmacro GetParent
78
79${StrCase}
80${StrRep}
81${StrTok}
82${StrTrimNewLines}
83
84;
85; Pull in pages
86;
87
88!define      MUI_COMPONENTSPAGE_SMALLDESC
89
90!define      MUI_HEADERIMAGE
91!define      MUI_BGCOLOR                739AB9
92!define      MUI_HEADERIMAGE_BITMAP     "bacula-logo.bmp"
93!define      MUI_HEADERIMAGE_LEFT
94!define      MUI_HEADERIMAGE_BITMAP_NOSTRETCH
95
96!InsertMacro MUI_PAGE_WELCOME
97!InsertMacro MUI_PAGE_LICENSE "${SRC_DIR}\LICENSE"
98Page custom EnterInstallType
99!define      MUI_PAGE_CUSTOMFUNCTION_SHOW PageComponentsShow
100!InsertMacro MUI_PAGE_COMPONENTS
101!define      MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
102!InsertMacro MUI_PAGE_DIRECTORY
103Page custom EnterConfigPage1 LeaveConfigPage1
104Page custom EnterConfigPage2 LeaveConfigPage2
105!Define      MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveInstallPage
106!InsertMacro MUI_PAGE_INSTFILES
107Page custom EnterWriteTemplates
108!Define      MUI_FINISHPAGE_SHOWREADME $INSTDIR\Readme.txt
109!InsertMacro MUI_PAGE_FINISH
110
111!InsertMacro MUI_UNPAGE_WELCOME
112!InsertMacro MUI_UNPAGE_CONFIRM
113!InsertMacro MUI_UNPAGE_INSTFILES
114!InsertMacro MUI_UNPAGE_FINISH
115
116!define      MUI_ABORTWARNING
117
118!InsertMacro MUI_LANGUAGE "English"
119
120!InsertMacro GetParameters
121!InsertMacro GetOptions
122
123DirText "Setup will install Bacula 32 bit ${VERSION} to the directory specified below. To install in a different folder, click Browse and select another folder."
124
125!InsertMacro MUI_RESERVEFILE_INSTALLOPTIONS
126;
127; Global Variables
128;
129Var OptService
130Var OptStart
131Var OptSilent
132
133Var CommonFilesDone
134
135Var OsIsNT
136
137Var HostName
138
139Var ConfigClientName
140Var ConfigClientPort
141Var ConfigClientMaxJobs
142Var ConfigClientPassword
143Var ConfigClientInstallService
144Var ConfigClientStartService
145
146Var ConfigStorageName
147Var ConfigStoragePort
148Var ConfigStorageMaxJobs
149Var ConfigStoragePassword
150Var ConfigStorageInstallService
151Var ConfigStorageStartService
152
153Var ConfigDirectorName
154Var ConfigDirectorPort
155Var ConfigDirectorMaxJobs
156Var ConfigDirectorPassword
157Var ConfigDirectorAddress
158Var ConfigDirectorMailServer
159Var ConfigDirectorMailAddress
160Var ConfigDirectorDB
161Var ConfigDirectorInstallService
162Var ConfigDirectorStartService
163
164Var ConfigMonitorName
165Var ConfigMonitorPassword
166
167Var LocalDirectorPassword
168Var LocalHostAddress
169
170Var MySQLPath
171Var MySQLVersion
172Var PostgreSQLPath
173Var PostgreSQLVersion
174
175Var AutomaticInstall
176Var InstallType
177
178!define NewInstall      0
179!define UpgradeInstall  1
180!define MigrateInstall  2
181
182Var OldInstallDir
183Var PreviousComponents
184Var NewComponents
185
186; Bit 0 = File Service
187;     1 = Storage Service
188;     2 = Director Service
189;     3 = Command Console
190;     4 = Bat Console
191;     5 = wxWidgits Console
192;     6 = Documentation (PDF)
193;     7 = Documentation (HTML)
194;     8 = alldrives Plugin
195;     9 = Old Exchange Plugin
196;    10 = Tray Monitor
197;    11 = winbmr Plugin
198
199!define ComponentFile                   1
200!define ComponentStorage                2
201!define ComponentDirector               4
202!define ComponentTextConsole            8
203!define ComponentBatConsole             16
204!define ComponentGUIConsole             32
205!define ComponentPDFDocs                64
206!define ComponentHTMLDocs               128
207!define MUI_PAGE_LICENSE "${SRC_DIR}\INSTALL"
208!define ComponentAllDrivesPlugin        256
209!define ComponentOldExchangePlugin      512
210!define ComponentTrayMonitor            1024
211; !define ComponentWinBMRPlugin           2048
212
213!define ComponentsRequiringUserConfig           63
214!define ComponentsFileAndStorage                3
215!define ComponentsFileAndStorageAndDirector     7
216!define ComponentsDirectorAndTextGuiConsoles    60
217!define ComponentsTextAndGuiConsoles            56
218
219Var HDLG
220Var HCTL
221
222Function .onInit
223  Push $R0
224  Push $R1
225
226  ; Process Command Line Options
227  StrCpy $OptService 1
228  StrCpy $OptStart 1
229  StrCpy $OptSilent 0
230  StrCpy $CommonFilesDone 0
231  StrCpy $OsIsNT 0
232  StrCpy $AutomaticInstall 0
233  StrCpy $InstallType ${NewInstall}
234  StrCpy $OldInstallDir ""
235  StrCpy $PreviousComponents 0
236  StrCpy $NewComponents 0
237  StrCpy $MySQLPath ""
238  StrCpy $MySQLVersion ""
239  StrCpy $PostgreSQLPath ""
240  StrCpy $PostgreSQLVersion ""
241  StrCpy $LocalDirectorPassword ""
242
243  ${GetParameters} $R0
244
245  ClearErrors
246  ${If} ${RunningX64}
247     MessageBox MB_OK "This is a 32 bit program, but the OS is an x64. Aborting ..." /SD IDOK
248     Abort
249  ${EndIf}
250
251
252  ${GetOptions} $R0 "/noservice" $R1
253  IfErrors +2
254    StrCpy $OptService 0
255
256  ClearErrors
257  ${GetOptions} $R0 "/nostart" $R1
258  IfErrors +2
259    StrCpy $OptStart 0
260
261  IfSilent 0 +2
262    StrCpy $OptSilent 1
263
264  ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
265  ${If} $R0 != ""
266    StrCpy $OsIsNT 1
267  ${EndIf}
268
269  Call GetComputerName
270  Pop $HostName
271
272  Call GetHostName
273  Pop $LocalHostAddress
274
275  Call GetUserName
276
277  ; Configuration Defaults
278
279  StrCpy $ConfigClientName               "$HostName-fd"
280  StrCpy $ConfigClientPort               9102
281  StrCpy $ConfigClientMaxJobs            10
282  ;StrCpy $ConfigClientPassword
283  StrCpy $ConfigClientInstallService     "$OptService"
284  StrCpy $ConfigClientStartService       "$OptStart"
285
286  StrCpy $ConfigStorageName              "$HostName-sd"
287  StrCpy $ConfigStoragePort              9103
288  StrCpy $ConfigStorageMaxJobs           10
289  ;StrCpy $ConfigStoragePassword
290  StrCpy $ConfigStorageInstallService    "$OptService"
291  StrCpy $ConfigStorageStartService      "$OptStart"
292
293  StrCpy $ConfigDirectorPort             9101
294
295  StrCpy $ConfigMonitorName              "$HostName-mon"
296  ;StrCpy $ConfigMonitorPassword
297
298; PLUGINSDIR refers to temporary helper programs and not Bacula plugins!
299  InitPluginsDir
300  File "/oname=$PLUGINSDIR\openssl.exe"  "${SRC_DIR}\openssl.exe"
301  File "/oname=$PLUGINSDIR\libeay32.dll" "${SRC_DIR}\libeay32.dll"
302  File "/oname=$PLUGINSDIR\ssleay32.dll" "${SRC_DIR}\ssleay32.dll"
303  File "/oname=$PLUGINSDIR\sed.exe"      "${SRC_DIR}\sed.exe"
304
305  !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
306  !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
307
308  SetPluginUnload alwaysoff
309
310; Generate random client password
311  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
312  pop $R0
313  ${If} $R0 = 0
314   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
315   IfErrors +4
316     FileRead $R1 $R0
317     ${StrTrimNewLines} $ConfigClientPassword $R0
318     FileClose $R1
319  ${EndIf}
320
321  SetPluginUnload manual
322
323; Generate random Storage daemon password
324  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
325  pop $R0
326  ${If} $R0 = 0
327   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
328   IfErrors +4
329     FileRead $R1 $R0
330     ${StrTrimNewLines} $ConfigStoragePassword $R0
331     FileClose $R1
332  ${EndIf}
333
334; Generate random monitor password
335  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
336  pop $R0
337  ${If} $R0 = 0
338   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
339   IfErrors +4
340     FileRead $R1 $R0
341     ${StrTrimNewLines} $ConfigMonitorPassword $R0
342     FileClose $R1
343  ${EndIf}
344
345  Pop $R1
346  Pop $R0
347FunctionEnd
348
349Function .onSelChange
350  Call UpdateComponentUI
351FunctionEnd
352
353Function InstallCommonFiles
354  ${If} $CommonFilesDone = 0
355    SetOutPath "$INSTDIR"
356    File "Readme.txt"
357
358    SetOutPath "$INSTDIR"
359!if "${BUILD_TOOLS}" == "MinGW32"
360    File "${SRC_DIR}\pthreadGCE2.dll"
361    File "${SRC_DIR}\ssleay32.dll"
362    File "${SRC_DIR}\libeay32.dll"
363    File "${SRC_DIR}\libwinpthread-1.dll"
364    File "${SRC_DIR}\libgcc_s_sjlj-1.dll"
365    File "${SRC_DIR}\libstdc++-6.dll"
366!endif
367!if "${BUILD_TOOLS}" == "MinGW64"
368    File "${SRC_DIR}\pthreadGCE.dll"
369    File "${SRC_DIR}\cryptoeay32-0.9.8.dll"
370    File "${SRC_DIR}\ssleay32-0.9.8.dll"
371!endif
372    File "${SRC_DIR}\zlib1.dll"
373    File "${SRC_DIR}\bacula.dll"
374
375    File "/oname=$INSTDIR\openssl.cnf" "${SRC_DIR}\openssl.cnf"
376    File "${SRC_DIR}\openssl.exe"
377    File "${SRC_DIR}\bsleep.exe"
378    File "${SRC_DIR}\bsmtp.exe"
379    File "${SRC_DIR}\expr64.exe"
380    File "${SRC_DIR}\snooze.exe"
381
382    CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
383
384    StrCpy $CommonFilesDone 1
385  ${EndIf}
386FunctionEnd
387
388Section "-Initialize"
389
390  WriteRegStr   HKLM Software\Bacula InstallLocation "$INSTDIR"
391
392  Call GetSelectedComponents
393  Pop $R2
394  WriteRegDWORD HKLM Software\Bacula Components $R2
395
396  ; remove start menu items
397  SetShellVarContext all
398
399  Delete /REBOOTOK "$SMPROGRAMS\Bacula\Configuration\*"
400  Delete /REBOOTOK "$SMPROGRAMS\Bacula\Documentation\*"
401  Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
402  RMDir "$SMPROGRAMS\Bacula\Configuration"
403  RMDir "$SMPROGRAMS\Bacula\Documentation"
404  RMDir "$SMPROGRAMS\Bacula"
405  CreateDirectory "$SMPROGRAMS\Bacula"
406  CreateDirectory "$SMPROGRAMS\Bacula\Configuration"
407  CreateDirectory "$SMPROGRAMS\Bacula\Documentation"
408
409  CreateDirectory "$INSTDIR"
410  CreateDirectory "$INSTDIR\working"
411  CreateDirectory "$INSTDIR\plugins"
412
413  SetOutPath "$INSTDIR"
414  File "${SRC_DIR}\LICENSE"
415  Delete /REBOOTOK "$INSTDIR\License.txt"
416
417; Output a series of SED commands to configure the .conf file(s)
418  FileOpen $R1 $PLUGINSDIR\config.sed w
419  FileWrite $R1 "s;@VERSION@;${VERSION};g$\r$\n"
420  FileWrite $R1 "s;@DATE@;${__DATE__};g$\r$\n"
421  FileWrite $R1 "s;@DISTNAME@;Windows;g$\r$\n"
422
423  StrCpy $R2 ${BUILD_TOOLS}
424
425  Call GetHostName
426  Exch $R3
427  Pop $R3
428
429  FileWrite $R1 "s;@DISTVER@;$R2;g$\r$\n"
430
431  ${StrRep} $R2 "$INSTDIR\working" "\" "\\\\"
432  FileWrite $R1 's;@working_dir@;$R2;g$\r$\n'
433;  ${StrRep} $R2 "$INSTDIR\working" "\" "\\"
434;  FileWrite $R1 's;@working_dir_cmd@;$R2;g$\r$\n'
435
436  ${StrRep} $R2 "$INSTDIR\plugins" "\" "\\\\"
437  FileWrite $R1 's;@fdplugins_dir@;$R2;g$\r$\n'
438
439  ${StrRep} $R2 "$INSTDIR" "\" "/"
440  FileWrite $R1 "s;@BUILD_DIR@;$R2;g$\r$\n"
441
442  FileWrite $R1 "s;@client_address@;$LocalHostAddress;g$\r$\n"
443  FileWrite $R1 "s;@client_name@;$ConfigClientName;g$\r$\n"
444  FileWrite $R1 "s;@client_port@;$ConfigClientPort;g$\r$\n"
445  FileWrite $R1 "s;@client_maxjobs@;$ConfigClientMaxJobs;g$\r$\n"
446  FileWrite $R1 "s;@client_password@;$ConfigClientPassword;g$\r$\n"
447  FileWrite $R1 "s;@storage_address@;$LocalHostAddress;g$\r$\n"
448  FileWrite $R1 "s;@storage_name@;$ConfigStorageName;g$\r$\n"
449  FileWrite $R1 "s;@storage_port@;$ConfigStoragePort;g$\r$\n"
450  FileWrite $R1 "s;@storage_maxjobs@;$ConfigStorageMaxJobs;g$\r$\n"
451  FileWrite $R1 "s;@storage_password@;$ConfigStoragePassword;g$\r$\n"
452  FileWrite $R1 "s;@director_name@;$ConfigDirectorName;g$\r$\n"
453  FileWrite $R1 "s;@director_port@;$ConfigDirectorPort;g$\r$\n"
454  FileWrite $R1 "s;@director_password@;$ConfigDirectorPassword;g$\r$\n"
455  FileWrite $R1 "s;@director_address@;$ConfigDirectorAddress;g$\r$\n"
456  FileWrite $R1 "s;@monitor_name@;$ConfigMonitorName;g$\r$\n"
457  FileWrite $R1 "s;@monitor_password@;$ConfigMonitorPassword;g$\r$\n"
458
459  FileClose $R1
460
461  ${If} ${FileExists} "$OldInstallDir\bacula-fd.exe"
462    nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /kill'     ; Shutdown any bacula that could be running
463    nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
464    Sleep 1000
465    nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /remove'   ; Remove existing service
466  ${EndIf}
467
468  ${If} ${FileExists} "$INSTDIR\bacula-fd.exe"
469    nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'     ; Shutdown any bacula that could be running
470    nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
471  ${EndIf}
472
473  ${If} ${FileExists} "$OldInstallDir\bin\bacula-sd.exe"
474    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill'     ; Shutdown any bacula that could be running
475    nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
476    Sleep 1000
477    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /remove'   ; Remove existing service
478  ${EndIf}
479
480  ${If} ${FileExists} "$INSTDIR\bacula-sd.exe"
481    nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill'     ; Shutdown any bacula that could be running
482    nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
483  ${EndIf}
484  Sleep 1000
485
486
487SectionEnd
488
489SectionGroup "Client" SecGroupClient
490
491Section "File Service" SecFileDaemon
492  SectionIn 1 2 3
493
494  SetOutPath "$INSTDIR"
495
496  File "${SRC_DIR}\bacula-fd.exe"
497  File "/oname=$PLUGINSDIR\bacula-fd.conf" "bacula-fd.conf.in"
498
499  StrCpy $0 "$INSTDIR"
500  StrCpy $1 bacula-fd.conf
501  Call ConfigEditAndCopy
502
503  StrCpy $0 bacula-fd
504  StrCpy $1 "File Service"
505  StrCpy $2 $ConfigClientInstallService
506  StrCpy $3 $ConfigClientStartService
507
508  Call InstallDaemon
509
510  CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Client Configuration.lnk" "write.exe" '"$INSTDIR\bacula-fd.conf"'
511SectionEnd
512
513SectionGroupEnd
514
515SectionGroup "Server" SecGroupServer
516
517Section "Storage Service" SecStorageDaemon
518  SectionIn 2 3
519
520  SetOutPath "$INSTDIR"
521
522  File "${SRC_DIR}\bacula-sd.exe"
523  File "${SRC_DIR}\bcopy.exe"
524  File "${SRC_DIR}\bextract.exe"
525  File "${SRC_DIR}\bls.exe"
526
527  File "/oname=$PLUGINSDIR\bacula-sd.conf" "bacula-sd.conf.in"
528
529  StrCpy $0 "$INSTDIR"
530  StrCpy $1 bacula-sd.conf
531  Call ConfigEditAndCopy
532
533  StrCpy $0 bacula-sd
534  StrCpy $1 "Storage Service"
535  StrCpy $2 $ConfigStorageInstallService
536  StrCpy $3 $ConfigStorageStartService
537  Call InstallDaemon
538
539  CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Storage Configuration.lnk" "write.exe" '"$INSTDIR\bacula-sd.conf"'
540SectionEnd
541
542SectionGroupEnd
543
544
545SectionGroup "Consoles" SecGroupConsoles
546
547Section "Command Console" SecConsole
548  SectionIn 1 2 3
549
550  SetOutPath "$INSTDIR"
551
552  File "${SRC_DIR}\bconsole.exe"
553  Call InstallCommonFiles
554
555  File "/oname=$PLUGINSDIR\bconsole.conf" "bconsole.conf.in"
556  StrCpy $0 "$INSTDIR"
557  StrCpy $1 bconsole.conf
558  Call ConfigEditAndCopy
559
560  CreateShortCut "$SMPROGRAMS\Bacula\bconsole.lnk" "$INSTDIR\bconsole.exe" '-c "$INSTDIR\bconsole.conf"' "$INSTDIR\bconsole.exe" 0
561  CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Command Console Configuration.lnk" "write.exe" '"$INSTDIR\bconsole.conf"'
562
563SectionEnd
564
565Section "Bat Console" SecBatConsole
566  SectionIn 1 2 3
567
568  SetOutPath "$INSTDIR"
569
570!if "${BUILD_BAT}" == "yes"
571  Call InstallCommonFiles
572  File "${SRC_DIR}\QtCore4.dll"
573  File "${SRC_DIR}\QtGui4.dll"
574  File "${SRC_DIR}\libgcc_s_sjlj-1.dll"
575
576  File "${SRC_DIR}\bat.exe"
577
578  File "/oname=$PLUGINSDIR\bat.conf" "bat.conf.in"
579  StrCpy $0 "$INSTDIR"
580  StrCpy $1 bat.conf
581  Call ConfigEditAndCopy
582
583  SetOutPath "$INSTDIR\help"
584  File "${SRC_DIR}\help\*"
585  SetOutPath "$INSTDIR"
586
587  ; Create Start Menu entry
588  CreateShortCut "$SMPROGRAMS\Bacula\Bat.lnk" "$INSTDIR\bat.exe" '-c "$INSTDIR\bat.conf"' "$INSTDIR\bat.exe" 0
589  CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Bat Configuration.lnk" "write.exe" '"$INSTDIR\bat.conf"'
590!endif
591
592SectionEnd
593
594Section "Bacula Tray Monitor" SecTrayMonitor
595  SectionIn 1 2 3
596
597  SetOutPath "$INSTDIR"
598
599!if "${BUILD_BAT}" == "yes"
600  Call InstallCommonFiles
601  File "${SRC_DIR}\QtCore4.dll"
602  File "${SRC_DIR}\QtGui4.dll"
603  File "${SRC_DIR}\libgcc_s_sjlj-1.dll"
604  File "${SRC_DIR}\bacula-tray-monitor.exe"
605
606  ;File "/oname=$PLUGINSDIR\bacula-tray-monitor.conf" "bacula-tray-monitor.conf.in"
607  StrCpy $0 "$INSTDIR"
608  StrCpy $1 bacula-tray-monitor.conf
609  ;Call ConfigEditAndCopy
610
611  ; Create Start Menu entry
612   CreateShortCut "$SMPROGRAMS\Bacula\TrayMonitor.lnk" "$INSTDIR\bacula-tray-monitor.exe" "" "$INSTDIR\bacula-tray-monitor.exe" 0
613!endif
614
615SectionEnd
616
617
618; Deleted because wxconsole is deprecated
619;Section "Graphical Console" SecWxConsole
620;  SectionIn 1 2 3
621
622;  SetOutPath "$INSTDIR"
623;
624;SectionEnd
625
626SectionGroupEnd
627
628
629SectionGroup "Plugins" SecGroupPlugins
630
631Section "alldrives Plugin" SecAllDrivesPlugin
632  SectionIn 1 2 3
633
634  SetOutPath "$INSTDIR\plugins"
635  File "${SRC_DIR}\alldrives-fd.dll"
636  SetOutPath "$INSTDIR"
637
638SectionEnd
639
640;Section "winbmr Plugin" SecWinBMRPlugin
641;  SectionIn 1 2 3
642
643;  SetOutPath "$INSTDIR\plugins"
644;  File "${SRC_DIR}\winbmr-fd.dll"
645;  SetOutPath "$INSTDIR"
646
647;SectionEnd
648
649Section "Old (deprecated) Exchange Plugin" SecOldExchangePlugin
650  SectionIn 1 2 3
651
652  SetOutPath "$INSTDIR\plugins"
653  File "${SRC_DIR}\exchange-fd.dll"
654  SetOutPath "$INSTDIR"
655
656SectionEnd
657
658SectionGroupEnd
659
660
661
662SectionGroup "Documentation" SecGroupDocumentation
663
664Section "Documentation (Acrobat Format)" SecDocPdf
665  SectionIn 1 2 3
666
667  SetOutPath "$INSTDIR\doc"
668  CreateDirectory "$INSTDIR\doc"
669
670  File "${SRC_DIR}\docs\manuals\en\console\console.pdf"
671  File "${SRC_DIR}\docs\manuals\en\misc\misc.pdf"
672  File "${SRC_DIR}\docs\manuals\en\main\main.pdf"
673  File "${SRC_DIR}\docs\manuals\en\utility\utility.pdf"
674  File "${SRC_DIR}\docs\manuals\en\problems\problems.pdf"
675  CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Console.lnk" '"$INSTDIR\doc\console.pdf"'
676  CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Main.lnk" '"$INSTDIR\doc\main.pdf"'
677  CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Misc.lnk" '"$INSTDIR\doc\misc.pdf"'
678  CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Utility.lnk" '"$INSTDIR\doc\utility.pdf"'
679  CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Problems.lnk" '"$INSTDIR\doc\problems.pdf"'
680  SetOutPath "$INSTDIR"
681SectionEnd
682
683;Section "Documentation (HTML Format)" SecDocHtml
684;  SectionIn 3
685
686; SetOutPath "$INSTDIR\doc"
687; CreateDirectory "$INSTDIR\doc"
688
689; File "${SRC_DIR}\manual\bacula\*.html"
690; File "${SRC_DIR}\manual\bacula\*.png"
691; File "${SRC_DIR}\manual\bacula\*.css"
692; CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Manual (HTML).lnk" '"$INSTDIR\doc\index.html"'
693;SectionEnd
694
695SectionGroupEnd
696
697Section "-Finish"
698  Push $R0
699
700  ${If} $OsIsNT = 1
701    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bacula-fd.conf" /G SYSTEM:F Administrators:F'
702    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bacula-sd.conf" /G SYSTEM:F Administrators:F'
703    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR\bat.conf" /G SYSTEM:F Administrators:F'
704  ${EndIf}
705
706  ; Write the uninstall keys for Windows & create Start Menu entry
707  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula"
708  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "InstallLocation" "$INSTDIR"
709  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayVersion" "${VERSION}"
710  ${StrTok} $R0 "${VERSION}" "." 0 0
711  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMajor" $R0
712  ${StrTok} $R0 "${VERSION}" "." 1 0
713  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMinor" $R0
714  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoModify" 1
715  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoRepair" 1
716  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLUpdateInfo" "http://www.bacula.org"
717  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLInfoAbout" "http://www.bacula.org"
718  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "HelpLink" "http://www.baculas.org"
719  WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
720  WriteUninstaller "$INSTDIR\Uninstall.exe"
721  CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
722
723  ${If} $OsIsNT = 1
724     nsExec::ExecToLog 'net start bacula-fd'
725     nsExec::ExecToLog 'net start bacula-sd'
726  ${Else}
727     Exec '"$INSTDIR\bacula-fd.exe" /service -c "$INSTDIR\bacula-fd.conf"'
728     Exec '"$INSTDIR\bacula-sd.exe" /service -c "$INSTDIR\bacula-sd.conf"'
729  ${EndIf}
730
731  Pop $R0
732SectionEnd
733
734; Extra Page descriptions
735
736LangString DESC_SecFileDaemon ${LANG_ENGLISH} "Install Bacula 32 bit File Daemon on this system."
737LangString DESC_SecStorageDaemon ${LANG_ENGLISH} "Install Bacula 32 bit Storage Daemon on this system."
738LangString DESC_SecConsole ${LANG_ENGLISH} "Install bconsole program on this system."
739LangString DESC_SecBatConsole ${LANG_ENGLISH} "Install Bat graphical console program on this system."
740LangString DESC_SecTrayMonitor ${LANG_ENGLISH} "Install Tray Monitor graphical program on this system."
741LangString DESC_SecAllDrivesPlugin ${LANG_ENGLISH} "Install alldrives Plugin on this system."
742; LangString DESC_SecWinBMRPlugin ${LANG_ENGLISH} "Install winbmr Plugin on this system."
743LangString DESC_SecOldExchangePlugin ${LANG_ENGLISH} "Install old (deprecated) Exchange Plugin on this system."
744
745
746LangString TITLE_ConfigPage1 ${LANG_ENGLISH} "Configuration"
747LangString SUBTITLE_ConfigPage1 ${LANG_ENGLISH} "Set installation configuration."
748
749LangString TITLE_ConfigPage2 ${LANG_ENGLISH} "Configuration (continued)"
750LangString SUBTITLE_ConfigPage2 ${LANG_ENGLISH} "Set installation configuration."
751
752LangString TITLE_InstallType ${LANG_ENGLISH} "Installation Type"
753LangString SUBTITLE_InstallType ${LANG_ENGLISH} "Choose installation type."
754
755LangString TITLE_WriteTemplates ${LANG_ENGLISH} "Create Templates"
756LangString SUBTITLE_WriteTemplates ${LANG_ENGLISH} "Create a resource template for inclusion in the Director's configuration file."
757
758!InsertMacro MUI_FUNCTION_DESCRIPTION_BEGIN
759  !InsertMacro MUI_DESCRIPTION_TEXT ${SecFileDaemon} $(DESC_SecFileDaemon)
760  !InsertMacro MUI_DESCRIPTION_TEXT ${SecStorageDaemon} $(DESC_SecStorageDaemon)
761  !InsertMacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
762  !InsertMacro MUI_DESCRIPTION_TEXT ${SecBatConsole} $(DESC_SecBatConsole)
763  !InsertMacro MUI_DESCRIPTION_TEXT ${SecTrayMonitor} $(DESC_SecTrayMonitor)
764  !InsertMacro MUI_DESCRIPTION_TEXT ${SecAllDrivesPlugin} $(DESC_SecAllDrivesPlugin)
765;  !InsertMacro MUI_DESCRIPTION_TEXT ${SecWinBMRPlugin} $(DESC_SecWinBMRPlugin)
766  !InsertMacro MUI_DESCRIPTION_TEXT ${SecOldExchangePlugin} $(DESC_SecOldExchangePlugin)
767!InsertMacro MUI_FUNCTION_DESCRIPTION_END
768
769; Uninstall section
770
771UninstallText "This will uninstall Bacula. Click Uninstall to continue."
772
773Section "Uninstall"
774  ; Shutdown any baculum that could be running
775  nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
776  nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
777  Sleep 3000
778
779; ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
780  ; Remove Bacula File Daemon service
781  nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /remove'
782
783  ; Remove Bacula Storage Daemon service
784  nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /remove'
785
786  ; remove registry keys
787  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
788  DeleteRegKey HKLM "Software\Bacula"
789
790  ; remove start menu items
791  SetShellVarContext all
792  Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
793  RMDir "$SMPROGRAMS\Bacula"
794
795  ; remove files and uninstaller (preserving config for now)
796  Delete /REBOOTOK "$INSTDIR\doc\*"
797  Delete /REBOOTOK "$INSTDIR\openssl.exe"
798  Delete /REBOOTOK "$INSTDIR\bacula-fd.exe"
799  Delete /REBOOTOK "$INSTDIR\bsleep.exe"
800  Delete /REBOOTOK "$INSTDIR\bsmtp.exe"
801  Delete /REBOOTOK "$INSTDIR\bconsole.exe"
802  Delete /REBOOTOK "$INSTDIR\expr64.exe"
803  Delete /REBOOTOK "$INSTDIR\snooze.exe"
804  Delete /REBOOTOK "$INSTDIR\LICENSE"
805  Delete /REBOOTOK "$INSTDIR\Readme.txt"
806  Delete /REBOOTOK "$INSTDIR\*.dll"
807  Delete /REBOOTOK "$INSTDIR\*.cnf"
808  Delete /REBOOTOK "$INSTDIR\*.sed"
809  Delete /REBOOTOK "$INSTDIR\*.cmd"
810  Delete /REBOOTOK "$INSTDIR\*.sql"
811  Delete /REBOOTOK "$INSTDIR\help\*"
812  Delete /REBOOTOK "$INSTDIR\plugins\alldrives-fd.dll"
813  Delete /REBOOTOK "$INSTDIR\plugins\exchange-fd.dll"
814;  Delete /REBOOTOK "$INSTDIR\plugins\winbmr-fd.dll"
815
816  ; Check for existing installation
817  IfSilent +2
818     MessageBox MB_YESNO|MB_ICONQUESTION \
819     "Would you like to delete the current configuration files and the working state file?" /SD IDNO IDNO NoDel
820
821
822  Delete /REBOOTOK "$INSTDIR\*"
823  Delete /REBOOTOK "$INSTDIR\working\*"
824  Delete /REBOOTOK "$PLUGINSDIR\bacula-*.conf"
825  Delete /REBOOTOK "$PLUGINSDIR\*console.conf"
826  Delete /REBOOTOK "$PLUGINSDIR\*conf.in"
827  RMDir /REBOOTOK "$INSTDIR\plugins"
828  RMDir /REBOOTOK "$INSTDIR\working"
829  RMDir /REBOOTOK "$INSTDIR"
830NoDel:
831  ; remove directories used
832
833  RMDir "$INSTDIR\plugins"
834  RMDir "$INSTDIR\working"
835  RMDir "$INSTDIR\doc"
836  RMDir "$INSTDIR\help"
837  RMDir "$INSTDIR"
838SectionEnd
839
840;
841; $0 - Service Name (ie Bacula-FD)
842; $1 - Service Description (ie Bacula File Daemon)
843; $2 - Install as Service
844; $3 - Start Service now
845;
846Function InstallDaemon
847  Call InstallCommonFiles
848
849  WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
850
851  ${If} $2 = 1
852    nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /kill'
853    nsExec::Exec /TIMEOUT=200 'net stop bacula-fd'
854    nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /kill'
855    nsExec::Exec /TIMEOUT=200 'net stop bacula-sd'
856    nsExec::ExecToLog '"$INSTDIR\$0.exe" /remove'
857    nsExec::ExecToLog '"$INSTDIR\$0.exe" /install -c "$INSTDIR\$0.conf"'
858
859    ${If} $OsIsNT <> 1
860      File "Start.bat"
861      File "Stop.bat"
862    ${EndIf}
863
864  ${EndIf}
865
866FunctionEnd
867
868Function GetComputerName
869  Push $R0
870  Push $R1
871  Push $R2
872
873  System::Call "kernel32::GetComputerNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2"
874
875  ${StrCase} $R0 $R0 "L"
876
877  Pop $R2
878  Pop $R1
879  Exch $R0
880FunctionEnd
881
882!define ComputerNameDnsFullyQualified   3
883
884Function GetHostName
885  Push $R0
886  Push $R1
887  Push $R2
888
889  ${If} $OsIsNT = 1
890    System::Call "kernel32::GetComputerNameExA(i ${ComputerNameDnsFullyQualified}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
891    ${If} $R2 = 0
892      Pop $R2
893      DetailPrint "GetComputerNameExA failed - LastError = $R2"
894      Call GetComputerName
895      Pop $R0
896    ${Else}
897      Pop $R2
898    ${EndIf}
899  ${Else}
900    Call GetComputerName
901    Pop $R0
902  ${EndIf}
903
904  Pop $R2
905  Pop $R1
906  Exch $R0
907FunctionEnd
908
909!define NameUserPrincipal 8
910
911Function GetUserName
912  Push $R0
913  Push $R1
914  Push $R2
915
916  ${If} $OsIsNT = 1
917    System::Call "secur32::GetUserNameExA(i ${NameUserPrincipal}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
918    ${If} $R2 = 0
919      Pop $R2
920      DetailPrint "GetUserNameExA failed - LastError = $R2"
921      Pop $R0
922      StrCpy $R0 ""
923    ${Else}
924      Pop $R2
925    ${EndIf}
926  ${Else}
927      StrCpy $R0 ""
928  ${EndIf}
929
930  ${If} $R0 == ""
931    System::Call "advapi32::GetUserNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
932    ${If} $R2 = 0
933      Pop $R2
934      DetailPrint "GetUserNameA failed - LastError = $R2"
935      StrCpy $R0 ""
936    ${Else}
937      Pop $R2
938    ${EndIf}
939  ${EndIf}
940
941  Pop $R2
942  Pop $R1
943  Exch $R0
944FunctionEnd
945
946Function ConfigEditAndCopy
947  Push $R1
948
949  ${If} ${FileExists} "$0\$1"
950    StrCpy $R1 ".new"
951  ${Else}
952    StrCpy $R1 ""
953  ${EndIf}
954
955  nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\$1"'
956  CopyFiles "$PLUGINSDIR\$1" "$0\$1$R1"
957
958  Pop $R1
959FunctionEnd
960
961Function GetSelectedComponents
962  Push $R0
963  StrCpy $R0 0
964  ${If} ${SectionIsSelected} ${SecFileDaemon}
965    IntOp $R0 $R0 | ${ComponentFile}
966  ${EndIf}
967  ${If} ${SectionIsSelected} ${SecStorageDaemon}
968    IntOp $R0 $R0 | ${ComponentStorage}
969  ${EndIf}
970  ${If} ${SectionIsSelected} ${SecConsole}
971    IntOp $R0 $R0 | ${ComponentTextConsole}
972  ${EndIf}
973  ${If} ${SectionIsSelected} ${SecBatConsole}
974    IntOp $R0 $R0 | ${ComponentBatConsole}
975  ${EndIf}
976   ${If} ${SectionIsSelected} ${SecTrayMonitor}
977     IntOp $R0 $R0 | ${ComponentTrayMonitor}
978   ${EndIf}
979  ${If} ${SectionIsSelected} ${SecAllDrivesPlugin}
980    IntOp $R0 $R0 | ${ComponentAllDrivesPlugin}
981  ${EndIf}
982;  ${If} ${SectionIsSelected} ${SecWinBMRPlugin}
983;    IntOp $R0 $R0 | ${ComponentWinBMRPlugin}
984;  ${EndIf}
985  ${If} ${SectionIsSelected} ${SecOldExchangePlugin}
986    IntOp $R0 $R0 | ${ComponentOldExchangePlugin}
987  ${EndIf}
988  ${If} ${SectionIsSelected} ${SecDocPdf}
989    IntOp $R0 $R0 | ${ComponentPDFDocs}
990  ${EndIf}
991  Exch $R0
992FunctionEnd
993
994Function PageComponentsShow
995  Call SelectPreviousComponents
996  Call UpdateComponentUI
997FunctionEnd
998
999Function PageDirectoryPre
1000  ${If} $AutomaticInstall = 1
1001  ${OrIf} $InstallType = ${UpgradeInstall}
1002    Abort
1003  ${EndIf}
1004FunctionEnd
1005
1006Function LeaveInstallPage
1007  Push "$INSTDIR\install.log"
1008  Call DumpLog
1009FunctionEnd
1010
1011Function EnterWriteTemplates
1012  Push $R0
1013  Push $R1
1014
1015  Call GetSelectedComponents
1016  Pop $R0
1017
1018  IntOp $R0 $R0 & ${ComponentDirector}
1019  IntOp $R1 $NewComponents & ${ComponentsFileAndStorage}
1020
1021  ${If} $R0 <> 0
1022  ${OrIf} $R1 = 0
1023    Pop $R1
1024    Pop $R0
1025    Abort
1026  ${EndIf}
1027
1028  IntOp $R0 $NewComponents & ${ComponentFile}
1029  ${If} $R0 = 0
1030    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" State 0
1031    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" Flags DISABLED
1032    DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" State
1033    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1034  ${Else}
1035    ;; TODO: See why this procedure causes a problem on Windows 2012
1036    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" State 0
1037    DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" Flags
1038    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" State "$INSTDIR\$ConfigClientName.conf"
1039    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST
1040
1041  ${EndIf}
1042
1043  IntOp $R0 $NewComponents & ${ComponentStorage}
1044  ${If} $R0 = 0
1045    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" State 0
1046    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" Flags DISABLED
1047    DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" State
1048    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1049  ${Else}
1050    ;; TODO: See why this procedure causes a problem on Windows 2012
1051    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" State 0
1052    DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" Flags
1053    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" State "$INSTDIR\$ConfigStorageName.conf"
1054    WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST
1055  ${EndIf}
1056
1057  !InsertMacro MUI_HEADER_TEXT "$(TITLE_WriteTemplates)" "$(SUBTITLE_WriteTemplates)"
1058  !InsertMacro MUI_INSTALLOPTIONS_DISPLAY "WriteTemplates.ini"
1059
1060  !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 2" State
1061  ${If} $R0 <> 0
1062    File "/oname=$PLUGINSDIR\client.conf.in" "client.conf.in"
1063
1064    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\client.conf.in"'
1065    !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 3" State
1066    ${If} $R0 != ""
1067      CopyFiles "$PLUGINSDIR\client.conf.in" "$R0"
1068    ${EndIf}
1069  ${EndIf}
1070
1071
1072  !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 4" State
1073  ${If} $R0 <> 0
1074    File "/oname=$PLUGINSDIR\storage.conf.in" "storage.conf.in"
1075
1076    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\storage.conf.in"'
1077    !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 5" State
1078    ${If} $R0 != ""
1079      CopyFiles "$PLUGINSDIR\storage.conf.in" "$R0"
1080    ${EndIf}
1081  ${EndIf}
1082
1083  Pop $R1
1084  Pop $R0
1085FunctionEnd
1086
1087Function SelectPreviousComponents
1088  ${If} $InstallType <> ${NewInstall}
1089    IntOp $R1 $PreviousComponents & ${ComponentFile}
1090    ${If} $R1 <> 0
1091      !InsertMacro SelectSection ${SecFileDaemon}
1092      !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_RO}
1093    ${Else}
1094      !InsertMacro UnselectSection ${SecFileDaemon}
1095      !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_RO}
1096    ${EndIf}
1097        IntOp $R1 $PreviousComponents & ${ComponentStorage}
1098    ${If} $R1 <> 0
1099      !InsertMacro SelectSection ${SecStorageDaemon}
1100      !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_RO}
1101    ${Else}
1102      !InsertMacro UnselectSection ${SecStorageDaemon}
1103      !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_RO}
1104    ${EndIf}
1105    IntOp $R1 $PreviousComponents & ${ComponentTextConsole}
1106    ${If} $R1 <> 0
1107      !InsertMacro SelectSection ${SecConsole}
1108      !InsertMacro SetSectionFlag ${SecConsole} ${SF_RO}
1109    ${Else}
1110      !InsertMacro UnselectSection ${SecConsole}
1111      !InsertMacro ClearSectionFlag ${SecConsole} ${SF_RO}
1112    ${EndIf}
1113    IntOp $R1 $PreviousComponents & ${ComponentBatConsole}
1114    ${If} $R1 <> 0
1115      !InsertMacro SelectSection ${SecBatConsole}
1116      !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_RO}
1117    ${Else}
1118      !InsertMacro UnselectSection ${SecBatConsole}
1119      !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_RO}
1120    ${EndIf}
1121     IntOp $R1 $PreviousComponents & ${ComponentTrayMonitor}
1122     ${If} $R1 <> 0
1123       !InsertMacro SelectSection ${SecTrayMonitor}
1124       !InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_RO}
1125     ${Else}
1126       !InsertMacro UnselectSection ${SecTrayMonitor}
1127       !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_RO}
1128     ${EndIf}
1129    IntOp $R1 $PreviousComponents & ${ComponentAllDrivesPlugin}
1130    ${If} $R1 <> 0
1131      !InsertMacro SelectSection ${SecAllDrivesPlugin}
1132      !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1133    ${Else}
1134      !InsertMacro UnselectSection ${SecAllDrivesPlugin}
1135      !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1136    ${EndIf}
1137;    IntOp $R1 $PreviousComponents & ${ComponentWinBMRPlugin}
1138;    ${If} $R1 <> 0
1139;      !InsertMacro SelectSection ${SecWinBMRPlugin}
1140;      !InsertMacro SetSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1141;    ${Else}
1142;      !InsertMacro UnselectSection ${SecWinBMRPlugin}
1143;      !InsertMacro ClearSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1144;    ${EndIf}
1145    IntOp $R1 $PreviousComponents & ${ComponentOldExchangePlugin}
1146    ${If} $R1 <> 0
1147      !InsertMacro SelectSection ${SecOldExchangePlugin}
1148      !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1149    ${Else}
1150      !InsertMacro UnselectSection ${SecOldExchangePlugin}
1151      !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1152    ${EndIf}
1153    IntOp $R1 $PreviousComponents & ${ComponentPDFDocs}
1154    ${If} $R1 <> 0
1155      !InsertMacro SelectSection ${SecDocPdf}
1156      !InsertMacro SetSectionFlag ${SecDocPdf} ${SF_RO}
1157    ${Else}
1158      !InsertMacro UnselectSection ${SecDocPdf}
1159      !InsertMacro ClearSectionFlag ${SecDocPdf} ${SF_RO}
1160    ${EndIf}
1161  ${EndIf}
1162FunctionEnd
1163
1164Function UpdateComponentUI
1165  Push $R0
1166  Push $R1
1167
1168  Call GetSelectedComponents
1169  Pop $R0
1170
1171  IntOp $R1 $R0 ^ $PreviousComponents
1172  IntOp $NewComponents $R0 & $R1
1173
1174  ${If} $InstallType <> ${NewInstall}
1175    IntOp $R1 $NewComponents & ${ComponentFile}
1176    ${If} $R1 <> 0
1177      !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_BOLD}
1178    ${Else}
1179      !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_BOLD}
1180    ${EndIf}
1181        IntOp $R1 $NewComponents & ${ComponentStorage}
1182    ${If} $R1 <> 0
1183      !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1184    ${Else}
1185      !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1186    ${EndIf}
1187    IntOp $R1 $NewComponents & ${ComponentTextConsole}
1188    ${If} $R1 <> 0
1189      !InsertMacro SetSectionFlag ${SecConsole} ${SF_BOLD}
1190    ${Else}
1191      !InsertMacro ClearSectionFlag ${SecConsole} ${SF_BOLD}
1192    ${EndIf}
1193    IntOp $R1 $NewComponents & ${ComponentBatConsole}
1194    ${If} $R1 <> 0
1195      !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_BOLD}
1196    ${Else}
1197      !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_BOLD}
1198    ${EndIf}
1199     IntOp $R1 $NewComponents & ${ComponentTrayMonitor}
1200     ${If} $R1 <> 0
1201       !InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1202     ${Else}
1203       !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1204     ${EndIf}
1205    IntOp $R1 $NewComponents & ${ComponentAllDrivesPlugin}
1206    ${If} $R1 <> 0
1207      !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1208    ${Else}
1209      !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1210    ${EndIf}
1211    IntOp $R1 $NewComponents & ${ComponentOldExchangePlugin}
1212    ${If} $R1 <> 0
1213      !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1214    ${Else}
1215      !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1216    ${EndIf}
1217    IntOp $R1 $NewComponents & ${ComponentPDFDocs}
1218    ${If} $R1 <> 0
1219      !InsertMacro SetSectionFlag ${SecDocPdf} ${SF_BOLD}
1220    ${Else}
1221      !InsertMacro ClearSectionFlag ${SecDocPdf} ${SF_BOLD}
1222    ${EndIf}
1223  ${EndIf}
1224
1225  GetDlgItem $R0 $HWNDPARENT 1
1226
1227  IntOp $R1 $NewComponents & ${ComponentsRequiringUserConfig}
1228  ${If} $R1 = 0
1229    SendMessage $R0 ${WM_SETTEXT} 0 "STR:Install"
1230  ${Else}
1231    SendMessage $R0 ${WM_SETTEXT} 0 "STR:&Next >"
1232  ${EndIf}
1233
1234  Pop $R1
1235  Pop $R0
1236FunctionEnd
1237
1238!include "InstallType.nsh"
1239!include "ConfigPage1.nsh"
1240!include "ConfigPage2.nsh"
1241!include "DumpLog.nsh"
1242