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