]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/win64_installer/winbacula.nsi
Remove NSIS debug
[bacula/bacula] / bacula / src / win32 / win64_installer / winbacula.nsi
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=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
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 ; 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
24 ;
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
30 ;
31 ; D. Scott Barninger Apr 17 2005
32 ; 1.36.3 release docs update
33 ; add pdf manual and menu shortcut
34 ;
35 ; Robert Nelson May 15 2006
36 ; Added server installs and implemented Microsoft install locations
37 ; Use LogicLib.nsh
38 ; Added Bacula-SD and Bacula-DIR
39 ; Replaced ParameterGiven with standard GetOptions
40 ;
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)
45 ;
46 ; Eric Bollengier March 2009
47 ; Updated to handle Win64 installation
48 ;
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
53 ;
54 ; Command line options:
55 ;
56 ; /service    - 
57 ; /start
58 ;
59 ; netsh firewall add portopening protocol=tcp port=9102 name="Bacula-FD"
60
61
62 !define PRODUCT "Bacula"
63
64 ;
65 ; Include the Modern UI
66 ;
67
68 !include "MUI.nsh"
69 !include "LogicLib.nsh"
70 !include "FileFunc.nsh"
71 !include "Sections.nsh"
72 !include "StrFunc.nsh"
73 !include "WinMessages.nsh"
74 !include "x64.nsh"
75
76 ;
77 ; Basics
78 ;
79 Name "Bacula"
80 OutFile "${OUT_DIR}\bacula-win${WINVER}-${VERSION}.exe"
81 SetCompressor lzma
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"
93
94 InstallDir "C:\Program Files\Bacula"
95 InstallDirRegKey HKLM "Software\Bacula" "InstallLocation"
96
97 InstType "Client"
98 InstType "Server"
99 ;InstType "Full"
100
101 !insertmacro GetParent
102
103 ${StrCase}
104 ${StrRep}
105 ${StrTok}
106 ${StrTrimNewLines}
107
108 ;
109 ; Pull in pages
110 ;
111
112 !define      MUI_COMPONENTSPAGE_SMALLDESC
113
114 !define      MUI_HEADERIMAGE
115 !define      MUI_BGCOLOR                739AB9
116 !define      MUI_HEADERIMAGE_BITMAP     "bacula-logo.bmp"
117
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
132
133 !InsertMacro MUI_UNPAGE_WELCOME
134 !InsertMacro MUI_UNPAGE_CONFIRM
135 !InsertMacro MUI_UNPAGE_INSTFILES
136 !InsertMacro MUI_UNPAGE_FINISH
137
138 !define      MUI_ABORTWARNING
139
140 !InsertMacro MUI_LANGUAGE "English"
141
142 !InsertMacro GetParameters
143 !InsertMacro GetOptions
144
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."
146
147 !InsertMacro MUI_RESERVEFILE_INSTALLOPTIONS
148 ;
149 ; Global Variables
150 ;
151 Var OptService
152 Var OptStart
153 Var OptSilent
154
155 Var CommonFilesDone
156
157 Var OsIsNT
158
159 Var HostName
160
161 Var ConfigClientName
162 Var ConfigClientPort
163 Var ConfigClientMaxJobs
164 Var ConfigClientPassword
165 Var ConfigClientInstallService
166 Var ConfigClientStartService
167
168 Var ConfigStorageName
169 Var ConfigStoragePort
170 Var ConfigStorageMaxJobs
171 Var ConfigStoragePassword
172 Var ConfigStorageInstallService
173 Var ConfigStorageStartService
174
175 Var ConfigDirectorName
176 Var ConfigDirectorPort
177 Var ConfigDirectorMaxJobs
178 Var ConfigDirectorPassword
179 Var ConfigDirectorAddress
180 Var ConfigDirectorMailServer
181 Var ConfigDirectorMailAddress
182 Var ConfigDirectorDB
183 Var ConfigDirectorInstallService
184 Var ConfigDirectorStartService
185
186 Var ConfigMonitorName
187 Var ConfigMonitorPassword
188
189 Var LocalDirectorPassword
190 Var LocalHostAddress
191
192 Var MySQLPath
193 Var MySQLVersion
194 Var PostgreSQLPath
195 Var PostgreSQLVersion
196
197 Var AutomaticInstall
198 Var InstallType
199
200 !define NewInstall      0
201 !define UpgradeInstall  1
202 !define MigrateInstall  2
203
204 Var OldInstallDir
205 Var PreviousComponents
206 Var NewComponents
207
208 ; Bit 0 = File Service
209 ;     1 = Storage Service
210 ;     2 = Director Service
211 ;     3 = Command Console
212 ;     4 = Bat Console
213 ;     5 = wxWidgits Console
214 ;     6 = Documentation (PDF)
215 ;     7 = Documentation (HTML)
216 ;     8 = alldrives Plugin
217 ;     9 = Old Exchange Plugin
218 ;    10 = Tray Monitor
219 ;    11 = winbmr Plugin  (not implemented in community version)
220
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
232
233 !define ComponentsRequiringUserConfig           63
234 !define ComponentsFileAndStorage                3
235 !define ComponentsFileAndStorageAndDirector     7
236 !define ComponentsDirectorAndTextGuiConsoles    60
237 !define ComponentsTextAndGuiConsoles            56
238
239 Var HDLG
240 Var HCTL
241
242 Function .onInit
243   Push $R0
244   Push $R1
245
246   ;LogSet on
247
248   ; Process Command Line Options
249   StrCpy $OptService 1
250   StrCpy $OptStart 1
251   StrCpy $OptSilent 0
252   StrCpy $CommonFilesDone 0
253   StrCpy $OsIsNT 0
254   StrCpy $AutomaticInstall 0
255   StrCpy $InstallType ${NewInstall}
256   StrCpy $OldInstallDir ""
257   StrCpy $PreviousComponents 0
258   StrCpy $NewComponents 0
259   StrCpy $MySQLPath ""
260   StrCpy $MySQLVersion ""
261   StrCpy $PostgreSQLPath ""
262   StrCpy $PostgreSQLVersion ""
263   StrCpy $LocalDirectorPassword ""
264
265   ${GetParameters} $R0
266
267   ClearErrors
268
269   ${If} ${RunningX64}
270   ${Else}
271      MessageBox MB_OK "This is a 64 bit installer, but the OS is not an x64 -- Aborting ..." /SD IDOK
272      Abort
273   ${EndIf}
274
275   ${GetOptions} $R0 "/noservice" $R1
276   IfErrors +2
277     StrCpy $OptService 0
278
279   ClearErrors
280   ${GetOptions} $R0 "/nostart" $R1
281   IfErrors +2
282     StrCpy $OptStart 0
283
284   IfSilent 0 +2
285     StrCpy $OptSilent 1
286
287   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
288   ${If} $R0 != ""
289     StrCpy $OsIsNT 1
290   ${EndIf}
291
292   Call GetComputerName
293   Pop $HostName
294
295   Call GetHostName
296   Pop $LocalHostAddress
297
298   Call GetUserName
299
300   ; Configuration Defaults
301
302   StrCpy $ConfigClientName               "$HostName-fd"
303   StrCpy $ConfigClientPort               9102
304   StrCpy $ConfigClientMaxJobs            10
305   ;StrCpy $ConfigClientPassword
306   StrCpy $ConfigClientInstallService     "$OptService"
307   StrCpy $ConfigClientStartService       "$OptStart"
308
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
316
317   StrCpy $ConfigMonitorName              "$HostName-mon"
318   ;StrCpy $ConfigMonitorPassword
319
320 ; TEMP refers to temporary helper programs and not Bacula plugins!
321 ;  InitTEMP
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"
328
329   !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
330   !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
331
332   SetPluginUnload alwaysoff
333
334 ; Generate random File daemon password
335   nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
336   pop $R0
337   ${If} $R0 = 0
338    FileOpen $R1 "$INSTDIR\working\pw.txt" r
339    IfErrors +4
340      FileRead $R1 $R0
341      ${StrTrimNewLines} $ConfigClientPassword $R0
342      FileClose $R1
343   ${EndIf}
344
345 ; Generate random Storage daemon password
346   nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
347   pop $R0
348   ${If} $R0 = 0
349    FileOpen $R1 "$INSTDIR\working\pw.txt" r
350    IfErrors +4
351      FileRead $R1 $R0
352      ${StrTrimNewLines} $ConfigStoragePassword $R0
353      FileClose $R1
354   ${EndIf}
355
356   SetPluginUnload manual
357
358 ; Generate random monitor password
359   nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
360   pop $R0
361   ${If} $R0 = 0
362    FileOpen $R1 "$INSTDIR\working\pw.txt" r
363    IfErrors +4
364      FileRead $R1 $R0
365      ${StrTrimNewLines} $ConfigMonitorPassword $R0
366      FileClose $R1
367   ${EndIf}
368
369   Pop $R1
370   Pop $R0
371 FunctionEnd
372
373 Function .onSelChange
374   Call UpdateComponentUI
375 FunctionEnd
376
377 Function InstallCommonFiles
378   ${If} $CommonFilesDone = 0
379     SetOutPath "$INSTDIR"
380     File "Readme.txt"
381
382     SetOutPath "$INSTDIR"
383 !if "${BUILD_TOOLS}" == "MinGW32"
384     File "${SRC_DIR}\mingwm10.dll"
385 !endif
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"
394
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"
401
402     CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
403
404     StrCpy $CommonFilesDone 1
405   ${EndIf}
406 FunctionEnd
407
408 Section "-Initialize"
409
410   WriteRegStr   HKLM Software\Bacula InstallLocation "$INSTDIR"
411
412   Call GetSelectedComponents
413   Pop $R2
414   WriteRegDWORD HKLM Software\Bacula Components $R2
415
416   ; remove start menu items
417   SetShellVarContext all
418
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"
428
429   CreateDirectory "$INSTDIR"
430   CreateDirectory "$INSTDIR\working"
431   CreateDirectory "$INSTDIR\plugins"
432
433   SetOutPath "$INSTDIR"
434   File "${SRC_DIR}\LICENSE"
435   Delete /REBOOTOK "$INSTDIR\License.txt"
436
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"
442
443   StrCpy $R2 ${BUILD_TOOLS}
444
445   Call GetHostName
446   Exch $R3
447   Pop $R3
448
449   FileWrite $R1 "s;@DISTVER@;$R2;g$\r$\n"
450
451   ${StrRep} $R2 "$INSTDIR\working" "\" "\\\\"
452   FileWrite $R1 's;@working_dir@;$R2;g$\r$\n'
453
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'
458
459   ${StrRep} $R2 "$INSTDIR\plugins" "\" "\\\\"
460   FileWrite $R1 's;@fdplugins_dir@;$R2;g$\r$\n'
461
462   ${StrRep} $R2 "$INSTDIR" "\" "/"
463   FileWrite $R1 "s;@BUILD_DIR@;$R2;g$\r$\n"
464
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"
481
482   FileClose $R1
483
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
487     Sleep 1000
488     nsExec::ExecToLog '"$OldInstallDir\bacula-fd.exe" /remove'   ; Remove existing service
489   ${EndIf}
490
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'
494   ${EndIf}
495
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'
500     Sleep 1000
501     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /remove'   ; Remove existing service
502   ${EndIf}
503
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'
507   ${EndIf}
508   Sleep 1000
509
510
511 SectionEnd
512
513 SectionGroup "Client" SecGroupClient
514
515 Section "File Service" SecFileDaemon
516   SectionIn 1 2 3
517
518   SetOutPath "$INSTDIR"
519
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"
523
524   StrCpy $0 "$INSTDIR"
525   StrCpy $1 bacula-fd.conf
526   Call ConfigEditAndCopy
527
528   StrCpy $0 bacula-fd
529   StrCpy $1 "File Service"
530   StrCpy $2 $ConfigClientInstallService
531   StrCpy $3 $ConfigClientStartService
532
533   Call InstallDaemon
534
535   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Client Configuration.lnk" "write.exe" '"$INSTDIR\bacula-fd.conf"'
536 SectionEnd
537
538 SectionGroupEnd
539
540 SectionGroup "Server" SecGroupServer
541
542 Section "Storage Service" SecStorageDaemon
543   SectionIn 2 3
544
545   SetOutPath "$INSTDIR"
546
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"
551
552   File "/oname=$INSTDIR\working\bacula-sd.conf.in" "bacula-sd.conf.in"
553
554   StrCpy $0 "$INSTDIR"
555   StrCpy $1 bacula-sd.conf
556   Call ConfigEditAndCopy
557
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"
568
569 #  File "/oname=$INSTDIR\working\mtx-changer.cmd" "scripts\mtx-changer.cmd"
570
571 #  StrCpy $0 "$INSTDIR\bin"
572 #  StrCpy $1 mtx-changer.cmd
573 #  Call ConfigEditAndCopy
574
575 #  File "/oname=$INSTDIR\working\disk-changer.cmd" "scripts\disk-changer.cmd"
576
577 #  StrCpy $0 "$INSTDIR"
578 #  StrCpy $1 disk-changer.cmd
579 #  Call ConfigEditAndCopy
580
581   StrCpy $0 bacula-sd
582   StrCpy $1 "Storage Service"
583   StrCpy $2 $ConfigStorageInstallService
584   StrCpy $3 $ConfigStorageStartService
585   Call InstallDaemon
586
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"'
589 SectionEnd
590
591 SectionGroupEnd
592
593 SectionGroup "Consoles" SecGroupConsoles
594
595 Section "Command Console" SecConsole
596   SectionIn 1 2 3
597
598   SetOutPath "$INSTDIR"
599
600   File "${SRC_DIR}\bconsole.exe"
601   Call InstallCommonFiles
602
603   File "/oname=$INSTDIR\working\bconsole.conf.in" "bconsole.conf.in"
604   StrCpy $0 "$INSTDIR"
605   StrCpy $1 bconsole.conf
606   Call ConfigEditAndCopy
607
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"'
610
611 SectionEnd
612
613 Section "Bat Console" SecBatConsole
614   SectionIn 1 2 3
615
616   SetOutPath "$INSTDIR"
617
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"
623
624   File "/oname=$INSTDIR\working\bat.conf.in" "bat.conf.in"
625   StrCpy $0 "$INSTDIR"
626   StrCpy $1 bat.conf
627   Call ConfigEditAndCopy
628
629   SetOutPath "$INSTDIR\help"
630   File "${SRC64_DIR}\help\*"
631   SetOutPath "$INSTDIR"
632
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"
637 !endif
638
639 SectionEnd
640
641 Section "Tray Monitor" SecTrayMonitor
642   SectionIn 1 2 3
643
644   SetOutPath "$INSTDIR"
645
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"
651
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
656
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"
660 !endif
661
662 SectionEnd
663
664 SectionGroupEnd
665
666 SectionGroup "Plugins" SecGroupPlugins
667
668 Section "alldrives Plugin" SecAllDrivesPlugin
669   SectionIn 1 2 3
670
671   SetOutPath "$INSTDIR\plugins"
672   File "${SRC_DIR}\alldrives-fd.dll"
673   SetOutPath "$INSTDIR"
674
675 SectionEnd
676
677 Section "Old (deprecated) Exchange Plugin" SecOldExchangePlugin
678   SectionIn 1 2 3
679
680   SetOutPath "$INSTDIR\plugins"
681   File "${SRC_DIR}\exchange-fd.dll"
682   SetOutPath "$INSTDIR"
683
684 SectionEnd
685
686 SectionGroupEnd
687
688 Section "-Finish"
689   Push $R0
690
691   ${If} $OsIsNT = 1
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'
695   ${EndIf}
696
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
713
714   ${If} $OsIsNT = 1
715      nsExec::ExecToLog 'net start bacula-fd'
716      nsExec::ExecToLog 'net start bacula-sd'
717   ${Else}
718      Exec '"$INSTDIR\bacula-fd.exe" /service -c "$INSTDIR\bacula-fd.conf"'
719      Exec '"$INSTDIR\bacula-sd.exe" /service -c "$INSTDIR\bacula-sd.conf"'
720   ${EndIf}
721
722   Pop $R0
723 SectionEnd
724
725 ; Extra Page descriptions
726
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."
734
735 LangString TITLE_ConfigPage1 ${LANG_ENGLISH} "Configuration"
736 LangString SUBTITLE_ConfigPage1 ${LANG_ENGLISH} "Set installation configuration."
737
738 LangString TITLE_ConfigPage2 ${LANG_ENGLISH} "Configuration (continued)"
739 LangString SUBTITLE_ConfigPage2 ${LANG_ENGLISH} "Set installation configuration."
740
741 LangString TITLE_InstallType ${LANG_ENGLISH} "Installation Type"
742 LangString SUBTITLE_InstallType ${LANG_ENGLISH} "Choose installation type."
743
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."
746
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
756
757 ; Uninstall section
758
759 UninstallText "This will uninstall Bacula. Click Uninstall to continue."
760
761 Section "Uninstall"
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'
767   Sleep 3000
768
769 ; ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
770   ; Remove Bacula File Daemon service
771   nsExec::ExecToLog '"$INSTDIR\bacula-fd.exe" /remove'
772
773 ; Remove Bacula Storage Daemon service
774   nsExec::ExecToLog '"$INSTDIR\bacula-sd.exe" /remove'
775
776   nsExec::ExecToLog '"$INSTDIR\plugins\exchange-fd.dll" /remove'
777   
778   ; remove registry keys
779   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
780   DeleteRegKey HKLM "Software\Bacula"
781
782   ; remove start menu items
783   SetShellVarContext all
784   Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
785   RMDir /REBOOTOK "$SMPROGRAMS\Bacula"
786
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"
806
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"
822 NoDel:
823
824   ; remove directories used
825   RMDir "$INSTDIR\plugins"
826   RMDir "$INSTDIR\working"
827   RMDir "$INSTDIR\doc"
828   RMDir "$INSTDIR\help"
829   RMDir "$INSTDIR"
830 SectionEnd
831
832 ;
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
837 ;
838 Function InstallDaemon
839   Call InstallCommonFiles
840
841   WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
842   
843   ${If} $2 = 1
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'
848     sleep 3000
849     nsExec::ExecToLog '"$INSTDIR\$0.exe" /remove'
850     nsExec::ExecToLog '"$INSTDIR\$0.exe" /install -c "$INSTDIR\$0.conf"'
851
852     ${If} $OsIsNT <> 1
853       File "Start.bat"
854       File "Stop.bat"
855     ${EndIf}
856
857     ; Start the service?
858
859     ${If} $3 = 1  
860       ${If} $OsIsNT = 1
861         nsExec::ExecToLog 'net start $0'
862       ${Else}
863         Exec '"$INSTDIR\$0.exe" /service -c "$INSTDIR\$0.conf"'
864       ${EndIf}
865     ${EndIf}
866   ${Else}
867     CreateShortCut "$SMPROGRAMS\Bacula\Start $1.lnk" "$INSTDIR\$0.exe" '-c "$INSTDIR\$0.conf"' "$INSTDIR\$0.exe" 0
868   ${EndIf}
869 FunctionEnd
870
871 Function GetComputerName
872   Push $R0
873   Push $R1
874   Push $R2
875
876   System::Call "kernel32::GetComputerNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2"
877
878   ${StrCase} $R0 $R0 "L"
879
880   Pop $R2
881   Pop $R1
882   Exch $R0
883 FunctionEnd
884
885 !define ComputerNameDnsFullyQualified   3
886
887 Function GetHostName
888   Push $R0
889   Push $R1
890   Push $R2
891
892   ${If} $OsIsNT = 1
893     System::Call "kernel32::GetComputerNameExA(i ${ComputerNameDnsFullyQualified}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
894     ${If} $R2 = 0
895       Pop $R2
896       DetailPrint "GetComputerNameExA failed - LastError = $R2"
897       Call GetComputerName
898       Pop $R0
899     ${Else}
900       Pop $R2
901     ${EndIf}
902   ${Else}
903     Call GetComputerName
904     Pop $R0
905   ${EndIf}
906
907   Pop $R2
908   Pop $R1
909   Exch $R0
910 FunctionEnd
911
912 !define NameUserPrincipal 8
913
914 Function GetUserName
915   Push $R0
916   Push $R1
917   Push $R2
918
919   ${If} $OsIsNT = 1
920     System::Call "secur32::GetUserNameExA(i ${NameUserPrincipal}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
921     ${If} $R2 = 0
922       Pop $R2
923       DetailPrint "GetUserNameExA failed - LastError = $R2"
924       Pop $R0
925       StrCpy $R0 ""
926     ${Else}
927       Pop $R2
928     ${EndIf}
929   ${Else}
930       StrCpy $R0 ""
931   ${EndIf}
932
933   ${If} $R0 == ""
934     System::Call "advapi32::GetUserNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
935     ${If} $R2 = 0
936       Pop $R2
937       DetailPrint "GetUserNameA failed - LastError = $R2"
938       StrCpy $R0 ""
939     ${Else}
940       Pop $R2
941     ${EndIf}
942   ${EndIf}
943
944   Pop $R2
945   Pop $R1
946   Exch $R0
947 FunctionEnd
948
949 Function ConfigEditAndCopy
950   Push $R1
951
952   ${If} ${FileExists} "$0\$1"
953     StrCpy $R1 ".new"
954   ${Else}
955     StrCpy $R1 ""
956   ${EndIf}
957
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"
960
961   Pop $R1
962 FunctionEnd
963
964 Function GetSelectedComponents
965   Push $R0
966   StrCpy $R0 0
967   ${If} ${SectionIsSelected} ${SecFileDaemon}
968     IntOp $R0 $R0 | ${ComponentFile}
969   ${EndIf}
970   ${If} ${SectionIsSelected} ${SecStorageDaemon}
971     IntOp $R0 $R0 | ${ComponentStorage}
972   ${EndIf}
973   ${If} ${SectionIsSelected} ${SecConsole}
974     IntOp $R0 $R0 | ${ComponentTextConsole}
975   ${EndIf}
976   ${If} ${SectionIsSelected} ${SecBatConsole}
977     IntOp $R0 $R0 | ${ComponentBatConsole}
978   ${EndIf}
979   ${If} ${SectionIsSelected} ${SecTrayMonitor}
980     ;IntOp $R0 $R0 | ${ComponentTrayMonitor}
981   ${EndIf}
982   ${If} ${SectionIsSelected} ${SecAllDrivesPlugin}
983     IntOp $R0 $R0 | ${ComponentAllDrivesPlugin}
984   ${EndIf}
985   ${If} ${SectionIsSelected} ${SecOldExchangePlugin}
986     IntOp $R0 $R0 | ${ComponentOldExchangePlugin}
987   ${EndIf}
988   Exch $R0
989 FunctionEnd
990
991 Function PageComponentsShow
992
993   Call SelectPreviousComponents
994   Call UpdateComponentUI
995 FunctionEnd
996
997 Function PageDirectoryPre
998   ${If} $AutomaticInstall = 1
999   ${OrIf} $InstallType = ${UpgradeInstall}
1000     Abort
1001   ${EndIf}
1002 FunctionEnd
1003
1004 Function LeaveInstallPage
1005   Push "$INSTDIR\install.log"
1006   Call DumpLog
1007 FunctionEnd
1008
1009 Function EnterWriteTemplates
1010   Push $R0
1011   Push $R1
1012
1013   Call GetSelectedComponents
1014   Pop $R0
1015
1016   IntOp $R0 $R0 & ${ComponentDirector}
1017   IntOp $R1 $NewComponents & ${ComponentsFileAndStorage}
1018
1019   ${If} $R0 <> 0
1020   ${OrIf} $R1 = 0
1021     Pop $R1
1022     Pop $R0
1023     Abort
1024   ${EndIf}
1025
1026   IntOp $R0 $NewComponents & ${ComponentFile}
1027   ${If} $R0 = 0
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
1032   ${Else}
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"
1036   ${EndIf}
1037
1038   IntOp $R0 $NewComponents & ${ComponentStorage}
1039   ${If} $R0 = 0
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
1044   ${Else}
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
1050   ${EndIf}
1051
1052
1053   !InsertMacro MUI_HEADER_TEXT "$(TITLE_WriteTemplates)" "$(SUBTITLE_WriteTemplates)"
1054   !InsertMacro MUI_INSTALLOPTIONS_DISPLAY "WriteTemplates.ini"
1055
1056   !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 2" State
1057   ${If} $R0 <> 0
1058     File "/oname=$INSTDIR\working\client.conf.in" "client.conf.in"
1059
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
1062     ${If} $R0 != ""
1063       CopyFiles "$INSTDIR\working\client.conf" "$R0"
1064     ${EndIf}
1065   ${EndIf}
1066
1067   !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 4" State
1068   ${If} $R0 <> 0
1069     File "/oname=$INSTDIR\working\storage.conf.in" "storage.conf.in"
1070
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
1073     ${If} $R0 != ""
1074       CopyFiles "$INSTDIR\working\storage.conf.in" "$R0"
1075     ${EndIf}
1076   ${EndIf}
1077
1078
1079   Pop $R1
1080   Pop $R0
1081 FunctionEnd
1082
1083 Function SelectPreviousComponents
1084   ${If} $InstallType <> ${NewInstall}
1085     IntOp $R1 $PreviousComponents & ${ComponentFile}
1086     ${If} $R1 <> 0
1087       !InsertMacro SelectSection ${SecFileDaemon}
1088       !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_RO}
1089     ${Else}
1090       !InsertMacro UnselectSection ${SecFileDaemon}
1091       !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_RO}
1092     ${EndIf}
1093     IntOp $R1 $PreviousComponents & ${ComponentStorage}
1094     ${If} $R1 <> 0
1095       !InsertMacro SelectSection ${SecStorageDaemon}
1096       !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_RO}
1097     ${Else}
1098       !InsertMacro UnselectSection ${SecStorageDaemon}
1099       !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_RO}
1100     ${EndIf}
1101     IntOp $R1 $PreviousComponents & ${ComponentTextConsole}
1102     ${If} $R1 <> 0
1103       !InsertMacro SelectSection ${SecConsole}
1104       !InsertMacro SetSectionFlag ${SecConsole} ${SF_RO}
1105     ${Else}
1106       !InsertMacro UnselectSection ${SecConsole}
1107       !InsertMacro ClearSectionFlag ${SecConsole} ${SF_RO}
1108     ${EndIf}
1109     IntOp $R1 $PreviousComponents & ${ComponentBatConsole}
1110     ${If} $R1 <> 0
1111       !InsertMacro SelectSection ${SecBatConsole}
1112       !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_RO}
1113     ${Else}
1114       !InsertMacro UnselectSection ${SecBatConsole}
1115       !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_RO}
1116     ${EndIf}
1117     IntOp $R1 $PreviousComponents & ${ComponentTrayMonitor}
1118     ${If} $R1 <> 0
1119       !InsertMacro SelectSection ${SecTrayMonitor}
1120       ;!InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_RO}
1121     ${Else}
1122       !InsertMacro UnselectSection ${SecTrayMonitor}
1123       !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_RO}
1124     ${EndIf}
1125     IntOp $R1 $PreviousComponents & ${ComponentAllDrivesPlugin}
1126     ${If} $R1 <> 0
1127       !InsertMacro SelectSection ${SecAllDrivesPlugin}
1128       !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1129     ${Else}
1130       !InsertMacro UnselectSection ${SecAllDrivesPlugin}
1131       !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_RO}
1132     ${EndIf}
1133 ;    IntOp $R1 $PreviousComponents & ${ComponentWinBMRPlugin}
1134 ;    ${If} $R1 <> 0
1135 ;      !InsertMacro SelectSection ${SecWinBMRPlugin}
1136 ;      !InsertMacro SetSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1137 ;    ${Else}
1138 ;      !InsertMacro UnselectSection ${SecWinBMRPlugin}
1139 ;      !InsertMacro ClearSectionFlag ${SecWinBMRPlugin} ${SF_RO}
1140 ;    ${EndIf}
1141 ;    IntOp $R1 $PreviousComponents & ${ComponentOldExchangePlugin}
1142 ;    ${If} $R1 <> 0
1143 ;      !InsertMacro SelectSection ${SecOldExchangePlugin}
1144 ;      !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1145 ;    ${Else}
1146 ;      !InsertMacro UnselectSection ${SecOldExchangePlugin}
1147 ;      !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_RO}
1148 ;    ${EndIf}
1149   ${EndIf}
1150 FunctionEnd
1151
1152 Function UpdateComponentUI
1153   Push $R0
1154   Push $R1
1155
1156   Call GetSelectedComponents
1157   Pop $R0
1158
1159   IntOp $R1 $R0 ^ $PreviousComponents
1160   IntOp $NewComponents $R0 & $R1
1161
1162   ${If} $InstallType <> ${NewInstall}
1163     IntOp $R1 $NewComponents & ${ComponentFile}
1164     ${If} $R1 <> 0
1165       !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_BOLD}
1166     ${Else}
1167       !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_BOLD}
1168     ${EndIf}
1169     IntOp $R1 $NewComponents & ${ComponentStorage}
1170     ${If} $R1 <> 0
1171       !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1172     ${Else}
1173       !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1174     ${EndIf}
1175     IntOp $R1 $NewComponents & ${ComponentTextConsole}
1176     ${If} $R1 <> 0
1177       !InsertMacro SetSectionFlag ${SecConsole} ${SF_BOLD}
1178     ${Else}
1179       !InsertMacro ClearSectionFlag ${SecConsole} ${SF_BOLD}
1180     ${EndIf}
1181     IntOp $R1 $NewComponents & ${ComponentBatConsole}
1182     ${If} $R1 <> 0
1183       !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_BOLD}
1184     ${Else}
1185       !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_BOLD}
1186     ${EndIf}
1187     IntOp $R1 $NewComponents & ${ComponentTrayMonitor}
1188     ${If} $R1 <> 0
1189       ;!InsertMacro SetSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1190     ${Else}
1191       !InsertMacro ClearSectionFlag ${SecTrayMonitor} ${SF_BOLD}
1192     ${EndIf}
1193     IntOp $R1 $NewComponents & ${ComponentAllDrivesPlugin}
1194     ${If} $R1 <> 0
1195       !InsertMacro SetSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1196     ${Else}
1197       !InsertMacro ClearSectionFlag ${SecAllDrivesPlugin} ${SF_BOLD}
1198     ${EndIf}
1199     IntOp $R1 $NewComponents & ${ComponentOldExchangePlugin}
1200     ${If} $R1 <> 0
1201       !InsertMacro SetSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1202     ${Else}
1203       !InsertMacro ClearSectionFlag ${SecOldExchangePlugin} ${SF_BOLD}
1204     ${EndIf}
1205   ${EndIf}
1206
1207   GetDlgItem $R0 $HWNDPARENT 1
1208
1209   IntOp $R1 $NewComponents & ${ComponentsRequiringUserConfig}
1210   ${If} $R1 = 0
1211     SendMessage $R0 ${WM_SETTEXT} 0 "STR:Install"
1212   ${Else}
1213     SendMessage $R0 ${WM_SETTEXT} 0 "STR:&Next >"
1214   ${EndIf}
1215
1216   Pop $R1
1217   Pop $R0
1218 FunctionEnd
1219
1220 !include "InstallType.nsh"
1221 !include "ConfigPage1.nsh"
1222 !include "ConfigPage2.nsh"
1223 !include "DumpLog.nsh"