]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/full_win32_installer/winbacula.nsi
Fix license problems in Bug #2382
[bacula/bacula] / bacula / src / win32 / full_win32_installer / winbacula.nsi
1 #
2 # Copyright (C) 2000-2018 Kern Sibbald
3 # License: BSD 2-Clause; see file LICENSE-FOSS
4 #
5 ; winbacula.nsi
6 ;
7 ; Began as a version written by Michel Meyers (michel@tcnnet.dyndns.org)
8 ;
9 ; Adapted by Kern Sibbald for native Win32 Bacula
10 ;    added a number of elements from Christopher Hull's installer
11 ;
12 ; D. Scott Barninger Nov 13 2004
13 ; added configuration editing for bconsole.conf and bwx-console.conf
14 ; better explanation in dialog boxes for editing config files
15 ; added Start Menu items
16 ; fix uninstall of config files to do all not just bacula-fd.conf
17 ;
18 ; D. Scott Barninger Dec 05 2004
19 ; added specification of default permissions for bacula-fd.conf
20 ;   - thanks to Jamie Ffolliott for pointing me at cacls
21 ; added removal of working-dir files if user selects to remove config
22 ; uninstall is now 100% clean
23 ;
24 ; D. Scott Barninger Apr 17 2005
25 ; 1.36.3 release docs update
26 ; add pdf manual and menu shortcut
27 ;
28 ; Robert Nelson May 15 2006
29 ; Added server installs and implemented Microsoft install locations
30 ; Use LogicLib.nsh
31 ; Added Bacula-SD and Bacula-DIR
32 ; Replaced ParameterGiven with standard GetOptions
33 ;
34 ; Command line options:
35 ;
36 ; /service    - 
37 ; /start
38 ;
39 ; netsh firewall add portopening protocol=tcp port=9102 name="Bacula-FD"
40
41
42 !define PRODUCT "Bacula"
43
44 ;
45 ; Include the Modern UI
46 ;
47
48 !include "MUI.nsh"
49 !include "LogicLib.nsh"
50 !include "FileFunc.nsh"
51 !include "Sections.nsh"
52 !include "StrFunc.nsh"
53 !include "WinMessages.nsh"
54 ;
55 ; Basics
56 ;
57 Name "Bacula"
58 OutFile "${OUT_DIR}\winbacula-${VERSION}.exe"
59 SetCompressor lzma
60 InstallDir "$PROGRAMFILES\Bacula"
61 InstallDirRegKey HKLM "Software\Bacula" "InstallLocation"
62
63 InstType "Client"
64 InstType "Server"
65 InstType "Full"
66
67 !insertmacro GetParent
68
69 ${StrCase}
70 ${StrRep}
71 ${StrTok}
72 ${StrTrimNewLines}
73
74 ;
75 ; Pull in pages
76 ;
77
78 !define      MUI_COMPONENTSPAGE_SMALLDESC
79
80 !define      MUI_HEADERIMAGE
81 !define      MUI_BGCOLOR                739AB9
82 !define      MUI_HEADERIMAGE_BITMAP     "bacula-logo.bmp"
83
84 !InsertMacro MUI_PAGE_WELCOME
85 !InsertMacro MUI_PAGE_LICENSE "..\..\..\LICENSE"
86 Page custom EnterInstallType
87 !define      MUI_PAGE_CUSTOMFUNCTION_SHOW PageComponentsShow
88 !InsertMacro MUI_PAGE_COMPONENTS
89 !define      MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
90 !InsertMacro MUI_PAGE_DIRECTORY
91 Page custom EnterConfigPage1 LeaveConfigPage1
92 Page custom EnterConfigPage2 LeaveConfigPage2
93 !Define      MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveInstallPage
94 !InsertMacro MUI_PAGE_INSTFILES
95 Page custom EnterWriteTemplates
96 !Define      MUI_FINISHPAGE_SHOWREADME $INSTDIR\Readme.txt
97 !InsertMacro MUI_PAGE_FINISH
98
99 !InsertMacro MUI_UNPAGE_WELCOME
100 !InsertMacro MUI_UNPAGE_CONFIRM
101 !InsertMacro MUI_UNPAGE_INSTFILES
102 !InsertMacro MUI_UNPAGE_FINISH
103
104 !define      MUI_ABORTWARNING
105
106 !InsertMacro MUI_LANGUAGE "English"
107
108 !InsertMacro GetParameters
109 !InsertMacro GetOptions
110
111 DirText "Setup will install Bacula ${VERSION} to the directory specified below. To install in a different folder, click Browse and select another folder."
112
113 !InsertMacro MUI_RESERVEFILE_INSTALLOPTIONS
114 ;
115 ; Global Variables
116 ;
117 Var OptService
118 Var OptStart
119 Var OptSilent
120
121 Var CommonFilesDone
122
123 Var OsIsNT
124
125 Var HostName
126
127 Var ConfigClientName
128 Var ConfigClientPort
129 Var ConfigClientMaxJobs
130 Var ConfigClientPassword
131 Var ConfigClientInstallService
132 Var ConfigClientStartService
133
134 Var ConfigStorageName
135 Var ConfigStoragePort
136 Var ConfigStorageMaxJobs
137 Var ConfigStoragePassword
138 Var ConfigStorageInstallService
139 Var ConfigStorageStartService
140
141 Var ConfigDirectorName
142 Var ConfigDirectorPort
143 Var ConfigDirectorMaxJobs
144 Var ConfigDirectorPassword
145 Var ConfigDirectorAddress
146 Var ConfigDirectorMailServer
147 Var ConfigDirectorMailAddress
148 Var ConfigDirectorDB
149 Var ConfigDirectorInstallService
150 Var ConfigDirectorStartService
151
152 Var ConfigMonitorName
153 Var ConfigMonitorPassword
154
155 Var LocalDirectorPassword
156 Var LocalHostAddress
157
158 Var MySQLPath
159 Var MySQLVersion
160 Var PostgreSQLPath
161 Var PostgreSQLVersion
162
163 Var AutomaticInstall
164 Var InstallType
165 !define NewInstall      0
166 !define UpgradeInstall  1
167 !define MigrateInstall  2
168
169 Var OldInstallDir
170 Var PreviousComponents
171 Var NewComponents
172
173 ; Bit 0 = File Service
174 ;     1 = Storage Service
175 ;     2 = Director Service
176 ;     3 = Command Console
177 ;     4 = Bat Console
178 ;     5 = wxWidgets Console
179 ;     7 = Documentation (PDF)
180 ;     7 = Documentation (HTML)
181
182 !define ComponentFile                   1
183 !define ComponentStorage                2
184 !define ComponentDirector               4
185 !define ComponentTextConsole            8
186 !define ComponentBatConsole             16
187 !define ComponentGUIConsole             32
188 !define ComponentPDFDocs                64
189 !define ComponentHTMLDocs               128
190
191 !define ComponentsRequiringUserConfig           63
192 !define ComponentsFileAndStorage                3
193 !define ComponentsFileAndStorageAndDirector     7
194 !define ComponentsDirectorAndTextGuiConsoles    60
195 !define ComponentsTextAndGuiConsoles            56
196
197 Var HDLG
198 Var HCTL
199
200 Function .onInit
201   Push $R0
202   Push $R1
203
204   ; Process Command Line Options
205   StrCpy $OptService 1
206   StrCpy $OptStart 1
207   StrCpy $OptSilent 0
208   StrCpy $CommonFilesDone 0
209   StrCpy $OsIsNT 0
210   StrCpy $AutomaticInstall 0
211   StrCpy $InstallType ${NewInstall}
212   StrCpy $OldInstallDir ""
213   StrCpy $PreviousComponents 0
214   StrCpy $NewComponents 0
215   StrCpy $MySQLPath ""
216   StrCpy $MySQLVersion ""
217   StrCpy $PostgreSQLPath ""
218   StrCpy $PostgreSQLVersion ""
219
220   ${GetParameters} $R0
221
222   ClearErrors
223   ${GetOptions} $R0 "/noservice" $R1
224   IfErrors +2
225     StrCpy $OptService 0
226
227   ClearErrors
228   ${GetOptions} $R0 "/nostart" $R1
229   IfErrors +2
230     StrCpy $OptStart 0
231
232   IfSilent 0 +2
233     StrCpy $OptSilent 1
234
235   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
236   ${If} $R0 != ""
237     StrCpy $OsIsNT 1
238   ${EndIf}
239
240   Call GetComputerName
241   Pop $HostName
242
243   Call GetHostName
244   Pop $LocalHostAddress
245
246   Call GetUserName
247   Pop $ConfigDirectorMailAddress
248
249   Call FindDatabaseApps
250
251   ; Configuration Defaults
252
253   StrCpy $ConfigClientName               "$HostName-fd"
254   StrCpy $ConfigClientPort               9102
255   StrCpy $ConfigClientMaxJobs            5
256   ;StrCpy $ConfigClientPassword
257   StrCpy $ConfigClientInstallService     "$OptService"
258   StrCpy $ConfigClientStartService       "$OptStart"
259
260   StrCpy $ConfigStorageName              "$HostName-sd"
261   StrCpy $ConfigStoragePort              9103
262   StrCpy $ConfigStorageMaxJobs           10
263   ;StrCpy $ConfigStoragePassword
264   StrCpy $ConfigStorageInstallService    "$OptService"
265   StrCpy $ConfigStorageStartService      "$OptStart"
266
267   ;StrCpy $ConfigDirectorName            "$HostName-dir"
268   StrCpy $ConfigDirectorPort             9101
269   StrCpy $ConfigDirectorMaxJobs          1
270   ;StrCpy $ConfigDirectorPassword
271   StrCpy $ConfigDirectorDB               0
272   StrCpy $ConfigDirectorInstallService   "$OptService"
273   StrCpy $ConfigDirectorStartService     "$OptStart"
274
275   StrCpy $ConfigMonitorName              "$HostName-mon"
276   ;StrCpy $ConfigMonitorPassword
277
278   InitPluginsDir
279   File "/oname=$PLUGINSDIR\openssl.exe"  "${SRC_DIR}\openssl.exe"
280   File "/oname=$PLUGINSDIR\libeay32.dll" "${SRC_DIR}\libeay32.dll"
281   File "/oname=$PLUGINSDIR\ssleay32.dll" "${SRC_DIR}\ssleay32.dll"
282   File "/oname=$PLUGINSDIR\sed.exe"      "${SRC_DIR}\sed.exe"
283
284   !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
285   !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
286
287   SetPluginUnload alwaysoff
288
289   nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
290   pop $R0
291   ${If} $R0 = 0
292    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
293    IfErrors +4
294      FileRead $R1 $R0
295      ${StrTrimNewLines} $ConfigClientPassword $R0
296      FileClose $R1
297   ${EndIf}
298
299   nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
300   pop $R0
301   ${If} $R0 = 0
302    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
303    IfErrors +4
304      FileRead $R1 $R0
305      ${StrTrimNewLines} $ConfigStoragePassword $R0
306      FileClose $R1
307   ${EndIf}
308
309   nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
310   pop $R0
311   ${If} $R0 = 0
312    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
313    IfErrors +4
314      FileRead $R1 $R0
315      ${StrTrimNewLines} $LocalDirectorPassword $R0
316      FileClose $R1
317   ${EndIf}
318
319   SetPluginUnload manual
320
321   nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
322   pop $R0
323   ${If} $R0 = 0
324    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
325    IfErrors +4
326      FileRead $R1 $R0
327      ${StrTrimNewLines} $ConfigMonitorPassword $R0
328      FileClose $R1
329   ${EndIf}
330
331   Pop $R1
332   Pop $R0
333 FunctionEnd
334
335 Function .onSelChange
336   Call UpdateComponentUI
337 FunctionEnd
338
339 Function InstallCommonFiles
340   ${If} $CommonFilesDone = 0
341     SetOutPath "$INSTDIR"
342     File "Readme.txt"
343
344     SetOutPath "$INSTDIR\bin"
345 !if "${BUILD_TOOLS}" == "VC8"
346     File "${SRC_DIR}\msvcm80.dll"
347     File "${SRC_DIR}\msvcp80.dll"
348     File "${SRC_DIR}\msvcr80.dll"
349     File "${SRC_DIR}\Microsoft.VC80.CRT.manifest"
350     File "${SRC_DIR}\pthreadVCE.dll"
351 !endif
352 !if "${BUILD_TOOLS}" == "VC8_DEBUG"
353     File "${SRC_DIR}\msvcm80.dll"
354     File "${SRC_DIR}\msvcp80.dll"
355     File "${SRC_DIR}\msvcr80.dll"
356     File "${SRC_DIR}\Microsoft.VC80.CRT.manifest"
357     File "${SRC_DIR}\msvcm80d.dll"
358     File "${SRC_DIR}\msvcp80d.dll"
359     File "${SRC_DIR}\msvcr80d.dll"
360     File "${SRC_DIR}\Microsoft.VC80.DebugCRT.manifest"
361     File "${SRC_DIR}\pthreadVCE.dll"
362 !endif
363 !if "${BUILD_TOOLS}" == "MinGW"
364     File "${SRC_DIR}\mingwm10.dll"
365     File "${SRC_DIR}\pthreadGCE.dll"
366 !endif
367     File "${SRC_DIR}\libeay32.dll"
368     File "${SRC_DIR}\ssleay32.dll"
369     File "${SRC_DIR}\zlib1.dll"
370 !if "${BUILD_TOOLS}" == "VC8"
371     File "${SRC_DIR}\zlib1.dll.manifest"
372 !endif
373 !If "${BUILD_TOOLS}" == "VC8_DEBUG"
374     File "${SRC_DIR}\zlib1.dll.manifest"
375 !endif
376     File "/oname=$INSTDIR\openssl.cnf" "${SRC_DIR}\openssl.cnf"
377     File "${SRC_DIR}\openssl.exe"
378     File "${SRC_DIR}\bsleep.exe"
379     File "${SRC_DIR}\bsmtp.exe"
380     File "${SRC_DIR}\bacula.dll"
381     File "${SRC_DIR}\expr64.exe"
382     File "${SRC_DIR}\snooze.exe"
383
384     CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
385
386     StrCpy $CommonFilesDone 1
387   ${EndIf}
388 FunctionEnd
389
390 Section "-Initialize"
391   ${If} $MySQLPath != ""
392     DetailPrint "Found MySQL (version $MySQLVersion)"
393   ${EndIf}
394   ${If} $PostgreSQLPath != ""
395     DetailPrint "Found PostgreSQL (version $PostgreSQLVersion)"
396   ${EndIf}
397
398   WriteRegStr   HKLM Software\Bacula InstallLocation "$INSTDIR"
399
400   Call GetSelectedComponents
401   Pop $R2
402   WriteRegDWORD HKLM Software\Bacula Components $R2
403
404   WriteRegDWORD HKLM Software\Bacula Database $ConfigDirectorDB
405
406   ; remove start menu items
407   SetShellVarContext all
408
409   Delete /REBOOTOK "$SMPROGRAMS\Bacula\Configuration\*"
410   Delete /REBOOTOK "$SMPROGRAMS\Bacula\Documentation\*"
411   Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
412   RMDir "$SMPROGRAMS\Bacula\Configuration"
413   RMDir "$SMPROGRAMS\Bacula\Documentation"
414   RMDir "$SMPROGRAMS\Bacula"
415   CreateDirectory "$SMPROGRAMS\Bacula"
416   CreateDirectory "$SMPROGRAMS\Bacula\Configuration"
417   CreateDirectory "$SMPROGRAMS\Bacula\Documentation"
418
419   CreateDirectory "$INSTDIR"
420   CreateDirectory "$INSTDIR\bin"
421   CreateDirectory "$APPDATA\Bacula"
422   CreateDirectory "$APPDATA\Bacula\Work"
423   CreateDirectory "$APPDATA\Bacula\Spool"
424
425   SetOutPath "$INSTDIR"
426   File "..\..\..\LICENSE"
427   Delete /REBOOTOK "$INSTDIR\bin\License.txt"
428
429   FileOpen $R1 $PLUGINSDIR\config.sed w
430   FileWrite $R1 "s;@VERSION@;${VERSION};g$\r$\n"
431   FileWrite $R1 "s;@DATE@;${__DATE__};g$\r$\n"
432   FileWrite $R1 "s;@DISTNAME@;Windows;g$\r$\n"
433
434 !If "$BUILD_TOOLS" == "MinGW"
435   StrCpy $R2 "MinGW32"
436 !Else
437   StrCpy $R2 "MVS"
438 !EndIf
439
440   Call GetHostName
441   Exch $R3
442   Pop $R3
443
444   FileWrite $R1 "s;@DISTVER@;$R2;g$\r$\n"
445
446   ${StrRep} $R2 "$APPDATA\Bacula\Work" "\" "\\\\"
447   FileWrite $R1 's;@working_dir@;$R2;g$\r$\n'
448   ${StrRep} $R2 "$APPDATA\Bacula\Work" "\" "\\"
449   FileWrite $R1 's;@working_dir_cmd@;$R2;g$\r$\n'
450
451   ${StrRep} $R2 "$INSTDIR\bin" "\" "\\\\"
452   FileWrite $R1 's;@bin_dir@;$R2;g$\r$\n'
453   ${StrRep} $R2 "$INSTDIR\bin" "\" "\\"
454   FileWrite $R1 's;@bin_dir_cmd@;$R2;g$\r$\n'
455
456   ${StrRep} $R2 "$INSTDIR\bin\fdplugins" "\" "\\\\"
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   Call IsDirectorSelected
463   Pop $R2
464   ${If} $R2 = 1
465     FileWrite $R1 "s;@director_address@;$LocalHostAddress;g$\r$\n"
466   ${Else}
467     ${If} "$ConfigDirectorAddress" != ""
468       FileWrite $R1 "s;@director_address@;$ConfigDirectorAddress;g$\r$\n"
469     ${EndIf}
470   ${EndIf}
471
472   FileWrite $R1 "s;@client_address@;$LocalHostAddress;g$\r$\n"
473   FileWrite $R1 "s;@storage_address@;$LocalHostAddress;g$\r$\n"
474
475   ${If} "$ConfigClientName" != ""
476     FileWrite $R1 "s;@client_name@;$ConfigClientName;g$\r$\n"
477   ${EndIf}
478   ${If} "$ConfigClientPort" != ""
479     FileWrite $R1 "s;@client_port@;$ConfigClientPort;g$\r$\n"
480   ${EndIf}
481   ${If} "$ConfigClientMaxJobs" != ""
482     FileWrite $R1 "s;@client_maxjobs@;$ConfigClientMaxJobs;g$\r$\n"
483   ${EndIf}
484   ${If} "$ConfigClientPassword" != ""
485     FileWrite $R1 "s;@client_password@;$ConfigClientPassword;g$\r$\n"
486   ${EndIf}
487   ${If} "$ConfigStorageName" != ""
488     FileWrite $R1 "s;@storage_name@;$ConfigStorageName;g$\r$\n"
489   ${EndIf}
490   ${If} "$ConfigStoragePort" != ""
491     FileWrite $R1 "s;@storage_port@;$ConfigStoragePort;g$\r$\n"
492   ${EndIf}
493   ${If} "$ConfigStorageMaxJobs" != ""
494     FileWrite $R1 "s;@storage_maxjobs@;$ConfigStorageMaxJobs;g$\r$\n"
495   ${EndIf}
496   ${If} "$ConfigStoragePassword" != ""
497     FileWrite $R1 "s;@storage_password@;$ConfigStoragePassword;g$\r$\n"
498   ${EndIf}
499   ${If} "$ConfigDirectorName" != ""
500     FileWrite $R1 "s;@director_name@;$ConfigDirectorName;g$\r$\n"
501   ${EndIf}
502   ${If} "$ConfigDirectorPort" != ""
503     FileWrite $R1 "s;@director_port@;$ConfigDirectorPort;g$\r$\n"
504   ${EndIf}
505   ${If} "$ConfigDirectorMaxJobs" != ""
506     FileWrite $R1 "s;@director_maxjobs@;$ConfigDirectorMaxJobs;g$\r$\n"
507   ${EndIf}
508   ${If} "$ConfigDirectorPassword" != ""
509     FileWrite $R1 "s;@director_password@;$ConfigDirectorPassword;g$\r$\n"
510   ${EndIf}
511   ${If} "$ConfigDirectorMailServer" != ""
512     FileWrite $R1 "s;@smtp_host@;$ConfigDirectorMailServer;g$\r$\n"
513   ${EndIf}
514   ${If} "$ConfigDirectorMailAddress" != ""
515     FileWrite $R1 "s;@job_email@;$ConfigDirectorMailAddress;g$\r$\n"
516   ${EndIf}
517   ${If} "$ConfigMonitorName" != ""
518     FileWrite $R1 "s;@monitor_name@;$ConfigMonitorName;g$\r$\n"
519   ${EndIf}
520   ${If} "$ConfigMonitorPassword" != ""
521     FileWrite $R1 "s;@monitor_password@;$ConfigMonitorPassword;g$\r$\n"
522   ${EndIf}
523
524   ${If} $ConfigDirectorDB = 1
525     ${If} $MySQLPath != ""
526       ${StrRep} $R2 "$MySQLPath\bin" "\" "\\"
527       FileWrite $R1 "s;@SQL_BINDIR@;$R2;g$\r$\n"
528     ${EndIf}
529   ${ElseIf} $ConfigDirectorDB = 2
530     ${If} $PostgreSQLPath != ""
531       ${StrRep} $R2 "$PostgreSQLPath\bin" "\" "\\"
532       FileWrite $R1 "s;@SQL_BINDIR@;$R2;g$\r$\n"
533     ${EndIf}
534   ${EndIf}
535
536   FileClose $R1
537
538   ${If} $InstallType = ${MigrateInstall}
539     FileOpen $R1 $PLUGINSDIR\migrate.sed w
540     ${StrRep} $R2 "$APPDATA\Bacula\Work" "\" "\\\\"
541     FileWrite $R1 's;\(Working *Directory *= *\)[^ ][^ ]*.*$$;\1"$R2";$\r$\n'
542     FileWrite $R1 's;\(Pid *Directory *= *\)[^ ][^ ]*.*$$;\1"$R2";$\r$\n'
543     FileClose $R1
544   ${EndIf}
545
546   ${If} ${FileExists} "$OldInstallDir\bin\bacula-fd.exe"
547     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /kill'     ; Shutdown any bacula that could be running
548     Sleep 3000
549     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /remove'   ; Remove existing service
550   ${EndIf}
551
552   ${If} ${FileExists} "$OldInstallDir\bin\bacula-sd.exe"
553     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill'     ; Shutdown any bacula that could be running
554     Sleep 3000
555     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /remove'   ; Remove existing service
556   ${EndIf}
557
558   ${If} ${FileExists} "$OldInstallDir\bin\bacula-dir.exe"
559     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-dir.exe" /kill'     ; Shutdown any bacula that could be running
560     Sleep 3000
561     nsExec::ExecToLog '"$OldInstallDir\bin\bacula-dir.exe" /remove'   ; Remove existing service
562   ${EndIf}
563
564 SectionEnd
565
566 SectionGroup "Client" SecGroupClient
567
568 Section "File Service" SecFileDaemon
569   SectionIn 1 2 3
570
571   SetOutPath "$INSTDIR\bin\fdplugins"
572   File "${SRC_DIR}\exchange-fd.dll"
573
574   SetOutPath "$INSTDIR\bin"
575
576   File "${SRC_DIR}\bacula-fd.exe"
577
578   ${If} $InstallType = ${MigrateInstall}
579   ${AndIf} ${FileExists} "$OldInstallDir\bin\bacula-fd.conf"
580     CopyFiles "$OldInstallDir\bin\bacula-fd.conf" "$APPDATA\Bacula"
581     nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\migrate.sed" -i.bak "$APPDATA\Bacula\bacula-fd.conf"'
582   ${Else}
583     File "/oname=$PLUGINSDIR\bacula-fd.conf" "bacula-fd.conf.in"
584
585     StrCpy $0 "$APPDATA\Bacula"
586     StrCpy $1 bacula-fd.conf
587     Call ConfigEditAndCopy
588   ${EndIf}
589
590   StrCpy $0 bacula-fd
591   StrCpy $1 "File Service"
592   StrCpy $2 $ConfigClientInstallService
593   StrCpy $3 $ConfigClientStartService
594
595   Call InstallDaemon
596
597   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Client Configuration.lnk" "write.exe" '"$APPDATA\Bacula\bacula-fd.conf"'
598 SectionEnd
599
600 SectionGroupEnd
601
602 SectionGroup "Server" SecGroupServer
603
604 Section "Storage Service" SecStorageDaemon
605   SectionIn 2 3
606
607   SetOutPath "$INSTDIR\bin"
608
609   File "${SRC_DIR}\loaderinfo.exe"
610   File "${SRC_DIR}\mt.exe"
611   File "${SRC_DIR}\mtx.exe"
612   File "${SRC_DIR}\scsitape.exe"
613   File "${SRC_DIR}\tapeinfo.exe"
614   File "${SRC_DIR}\bacula-sd.exe"
615   File "${SRC_DIR}\bcopy.exe"
616   File "${SRC_DIR}\bextract.exe"
617   File "${SRC_DIR}\bls.exe"
618   File "${SRC_DIR}\bscan.exe"
619   File "${SRC_DIR}\btape.exe"
620   File "${SRC_DIR}\scsilist.exe"
621   File "${SRC_DIR}\mkisofs.exe"
622   File "${SRC_DIR}\growisofs.exe"
623   File "${SRC_DIR}\dvd-ram-control.exe"
624   File "${SRC_DIR}\dvd+rw-booktype.exe"
625   File "${SRC_DIR}\dvd+rw-format.exe"
626   File "${SRC_DIR}\dvd+rw-mediainfo.exe"
627
628   File "/oname=$PLUGINSDIR\mtx-changer.cmd" "${SRC_DIR}\mtx-changer.cmd"
629
630   StrCpy $0 "$INSTDIR\bin"
631   StrCpy $1 mtx-changer.cmd
632   Call ConfigEditAndCopy
633
634   File "/oname=$PLUGINSDIR\disk-changer.cmd" "${SRC_DIR}\disk-changer.cmd"
635
636   StrCpy $0 "$INSTDIR\bin"
637   StrCpy $1 disk-changer.cmd
638   Call ConfigEditAndCopy
639
640   File "/oname=$PLUGINSDIR\dvd-handler.cmd" "${SRC_DIR}\dvd-handler.cmd"
641
642   StrCpy $0 "$INSTDIR\bin"
643   StrCpy $1 dvd-handler.cmd
644   Call ConfigEditAndCopy
645
646   File "/oname=$PLUGINSDIR\bacula-sd.conf" "bacula-sd.conf.in"
647
648   StrCpy $0 "$APPDATA\Bacula"
649   StrCpy $1 bacula-sd.conf
650   Call ConfigEditAndCopy
651
652   StrCpy $0 bacula-sd
653   StrCpy $1 "Storage Service"
654   StrCpy $2 $ConfigStorageInstallService
655   StrCpy $3 $ConfigStorageStartService
656   Call InstallDaemon
657
658   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\List Devices.lnk" "$INSTDIR\bin\scsilist.exe" "/pause"
659   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Storage Configuration.lnk" "write.exe" '"$APPDATA\Bacula\bacula-sd.conf"'
660 SectionEnd
661
662 Section "Director Service" SecDirectorDaemon
663   SectionIn 2 3
664
665   SetOutPath "$INSTDIR\bin"
666
667   ${If} $ConfigDirectorDB = 1
668     File /oname=bacula_cats.dll "${SRC_DIR}\cats_mysql.dll"
669     File "${SRC_DIR}\libmysql.dll"
670     File /oname=$PLUGINSDIR\create_database.cmd ${SRC_DIR}\create_mysql_database.cmd
671     File /oname=$PLUGINSDIR\drop_database.cmd ${SRC_DIR}\drop_mysql_database.cmd
672     File /oname=$PLUGINSDIR\make_tables.cmd ${SRC_DIR}\make_mysql_tables.cmd
673     File ${SRC_DIR}\make_mysql_tables.sql
674     File /oname=$PLUGINSDIR\drop_tables.cmd ${SRC_DIR}\drop_mysql_tables.cmd
675     File ${SRC_DIR}\drop_mysql_tables.sql
676     File /oname=$PLUGINSDIR\grant_privileges.cmd ${SRC_DIR}\grant_mysql_privileges.cmd
677     File ${SRC_DIR}\grant_mysql_privileges.sql
678     File /oname=$PLUGINSDIR\make_catalog_backup.cmd ${SRC_DIR}\make_mysql_catalog_backup.cmd
679   ${ElseIf} $ConfigDirectorDB = 2
680     File /oname=bacula_cats.dll "${SRC_DIR}\cats_postgresql.dll"
681     File "${SRC_DIR}\libpq.dll"
682 !if "${BUILD_TOOLS}" == "VC8"
683     File "${SRC_DIR}\comerr32.dll"
684     File "${SRC_DIR}\libintl-2.dll"
685     File "${SRC_DIR}\libiconv-2.dll"
686     File "${SRC_DIR}\krb5_32.dll"
687 !endif
688 !If "${BUILD_TOOLS}" == "VC8_DEBUG"
689     File "${SRC_DIR}\comerr32.dll"
690     File "${SRC_DIR}\libintl-2.dll"
691     File "${SRC_DIR}\libiconv-2.dll"
692     File "${SRC_DIR}\krb5_32.dll"
693 !endif
694     File /oname=$PLUGINSDIR\create_database.cmd ${SRC_DIR}\create_postgresql_database.cmd
695     File /oname=$PLUGINSDIR\drop_database.cmd ${SRC_DIR}\drop_postgresql_database.cmd
696     File /oname=$PLUGINSDIR\make_tables.cmd ${SRC_DIR}\make_postgresql_tables.cmd
697     File ${SRC_DIR}\create_postgresql_database.sql
698     File ${SRC_DIR}\make_postgresql_tables.sql
699     File /oname=$PLUGINSDIR\drop_tables.cmd ${SRC_DIR}\drop_postgresql_tables.cmd
700     File ${SRC_DIR}\drop_postgresql_tables.sql
701     File /oname=$PLUGINSDIR\grant_privileges.cmd ${SRC_DIR}\grant_postgresql_privileges.cmd
702     File ${SRC_DIR}\grant_postgresql_privileges.sql
703     File /oname=$PLUGINSDIR\make_catalog_backup.cmd ${SRC_DIR}\make_postgresql_catalog_backup.cmd
704   ${ElseIf} $ConfigDirectorDB = 3
705     File "${SRC_DIR}\sqlite3.exe"
706 !if "${BUILD_TOOLS}" == "VC8"
707     File "${SRC_DIR}\sqlite3.exe.manifest"
708 !endif
709 !If "${BUILD_TOOLS}" == "VC8_DEBUG"
710     File "${SRC_DIR}\sqlite3.exe.manifest"
711 !endif
712     File /oname=bacula_cats.dll "${SRC_DIR}\cats_sqlite3.dll"
713     File /oname=$PLUGINSDIR\create_database.cmd ${SRC_DIR}\create_sqlite3_database.cmd
714     File /oname=$PLUGINSDIR\drop_database.cmd ${SRC_DIR}\drop_sqlite3_database.cmd
715     File /oname=$PLUGINSDIR\make_tables.cmd ${SRC_DIR}\make_sqlite3_tables.cmd
716     File ${SRC_DIR}\make_sqlite3_tables.sql
717     File /oname=$PLUGINSDIR\drop_tables.cmd ${SRC_DIR}\drop_sqlite3_tables.cmd
718     File /oname=$PLUGINSDIR\grant_privileges.cmd ${SRC_DIR}\grant_sqlite3_privileges.cmd
719     File /oname=$PLUGINSDIR\make_catalog_backup.cmd ${SRC_DIR}\make_sqlite3_catalog_backup.cmd
720   ${EndIf}
721
722   File "${SRC_DIR}\bacula-dir.exe"
723   File "${SRC_DIR}\dbcheck.exe"
724
725   File "/oname=$PLUGINSDIR\delete_catalog_backup.cmd" "${SRC_DIR}\delete_catalog_backup.cmd"
726
727   StrCpy $0 "$INSTDIR\bin"
728   
729   StrCpy $1 create_database.cmd
730   Call ConfigEditAndCopy
731
732   StrCpy $1 drop_database.cmd
733   Call ConfigEditAndCopy
734
735   StrCpy $1 make_tables.cmd
736   Call ConfigEditAndCopy
737
738   StrCpy $1 drop_tables.cmd
739   Call ConfigEditAndCopy
740
741   StrCpy $1 grant_privileges.cmd
742   Call ConfigEditAndCopy
743
744   StrCpy $1 make_catalog_backup.cmd
745   Call ConfigEditAndCopy
746
747   StrCpy $1 delete_catalog_backup.cmd
748   Call ConfigEditAndCopy
749
750   File "${SRC_DIR}\query.sql"
751
752   File "/oname=$PLUGINSDIR\bacula-dir.conf" "bacula-dir.conf.in"
753
754   StrCpy $0 "$APPDATA\Bacula"
755   StrCpy $1 bacula-dir.conf
756   Call ConfigEditAndCopy
757
758   StrCpy $0 bacula-dir
759   StrCpy $1 "Director Service"
760   StrCpy $2 $ConfigDirectorInstallService
761   StrCpy $3 $ConfigDirectorStartService
762   Call InstallDaemon
763
764   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Director Configuration.lnk" "write.exe" '"$APPDATA\Bacula\bacula-dir.conf"'
765 SectionEnd
766
767 SectionGroupEnd
768
769 SectionGroup "Consoles" SecGroupConsoles
770
771 Section "Command Console" SecConsole
772   SectionIn 1 2 3
773
774   SetOutPath "$INSTDIR\bin"
775
776   File "${SRC_DIR}\bconsole.exe"
777   Call InstallCommonFiles
778
779   ${If} $InstallType = ${MigrateInstall}
780   ${AndIf} ${FileExists} "$OldInstallDir\bin\bconsole.conf"
781     CopyFiles "$OldInstallDir\bin\bconsole.conf" "$APPDATA\Bacula"
782   ${Else}
783     File "/oname=$PLUGINSDIR\bconsole.conf" "bconsole.conf.in"
784     StrCpy $0 "$APPDATA\Bacula"
785     StrCpy $1 bconsole.conf
786     Call ConfigEditAndCopy
787   ${EndIf}
788
789   CreateShortCut "$SMPROGRAMS\Bacula\bconsole.lnk" "$INSTDIR\bin\bconsole.exe" '-c "$APPDATA\Bacula\bconsole.conf"' "$INSTDIR\bin\bconsole.exe" 0
790   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Command Console Configuration.lnk" "write.exe" '"$APPDATA\Bacula\bconsole.conf"'
791
792 SectionEnd
793
794 Section "Bat Console" SecBatConsole
795   SectionIn 1 2 3
796   
797   SetOutPath "$INSTDIR\bin"
798
799   Call InstallCommonFiles
800   File "${SRC_DIR}\QtCore4.dll"
801   File "${SRC_DIR}\QtGui4.dll"
802
803   File "${SRC_DIR}\bat.exe"
804
805   ${If} $InstallType = ${MigrateInstall}
806   ${AndIf} ${FileExists} "$OldInstallDir\bin\bat.conf"
807     CopyFiles "$OldInstallDir\bin\bat.conf" "$APPDATA\Bacula"
808   ${Else}
809     File "/oname=$PLUGINSDIR\bat.conf" "bat.conf.in"
810     StrCpy $0 "$APPDATA\Bacula"
811     StrCpy $1 bat.conf
812     Call ConfigEditAndCopy
813   ${EndIf}
814
815   ; Create Start Menu entry
816   CreateShortCut "$SMPROGRAMS\Bacula\Bat.lnk" "$INSTDIR\bin\bat.exe" '-c "$APPDATA\Bacula\bat.conf"' "$INSTDIR\bin\bat.exe" 0
817   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Bat Configuration.lnk" "write.exe" '"$APPDATA\Bacula\bat.conf"'
818 SectionEnd
819
820
821 Section "Graphical Console" SecWxConsole
822   SectionIn 1 2 3
823   
824   SetOutPath "$INSTDIR\bin"
825
826   Call InstallCommonFiles
827 !if "${BUILD_TOOLS}" == "VC8"
828   File "${SRC_DIR}\wxbase28_vc_bacula.dll"
829   File "${SRC_DIR}\wxmsw28_core_vc_bacula.dll"
830 !endif
831 !If "${BUILD_TOOLS}" == "VC8_DEBUG"
832   File "${SRC_DIR}\wxbase28_vc_bacula.dll"
833   File "${SRC_DIR}\wxmsw28_core_vc_bacula.dll"
834 !endif
835 !if "${BUILD_TOOLS}" == "MinGW"
836   File "${SRC_DIR}\wxbase28_gcc_bacula.dll"
837   File "${SRC_DIR}\wxmsw28_core_gcc_bacula.dll"
838 !endif
839
840   File "${SRC_DIR}\bwx-console.exe"
841
842   ${If} $InstallType = ${MigrateInstall}
843   ${AndIf} ${FileExists} "$OldInstallDir\bin\bwx-console.conf"
844     CopyFiles "$OldInstallDir\bin\bwx-console.conf" "$APPDATA\Bacula"
845   ${Else}
846     File "/oname=$PLUGINSDIR\bwx-console.conf" "bwx-console.conf.in"
847     StrCpy $0 "$APPDATA\Bacula"
848     StrCpy $1 bwx-console.conf
849     Call ConfigEditAndCopy
850   ${EndIf}
851
852   ; Create Start Menu entry
853   CreateShortCut "$SMPROGRAMS\Bacula\bwx-console.lnk" "$INSTDIR\bin\bwx-console.exe" '-c "$APPDATA\Bacula\bwx-console.conf"' "$INSTDIR\bin\bwx-console.exe" 0
854   CreateShortCut "$SMPROGRAMS\Bacula\Configuration\Edit Graphical Console Configuration.lnk" "write.exe" '"$APPDATA\Bacula\bwx-console.conf"'
855 SectionEnd
856
857 SectionGroupEnd
858
859 SectionGroup "Documentation" SecGroupDocumentation
860
861 Section "Documentation (Acrobat Format)" SecDocPdf
862   SectionIn 1 2 3
863
864   SetOutPath "$INSTDIR\doc"
865   CreateDirectory "$INSTDIR\doc"
866
867   File "${SRC_DIR}\docs\manuals\en\console\console.pdf"
868   File "${SRC_DIR}\docs\manuals\en\misc\misc.pdf"
869   File "${SRC_DIR}\docs\manuals\en\main\main.pdf"
870   File "${SRC_DIR}\docs\manuals\en\utility\utility.pdf"
871   File "${SRC_DIR}\docs\manuals\en\problems\problems.pdf"
872   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Console.lnk" '"$INSTDIR\doc\console.pdf"'
873   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Main.lnk" '"$INSTDIR\doc\main.pdf"'
874   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Misc.lnk" '"$INSTDIR\doc\misc.pdf"'
875   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Utility.lnk" '"$INSTDIR\doc\utility.pdf"'
876   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Problems.lnk" '"$INSTDIR\doc\problems.pdf"'
877 SectionEnd
878
879 Section "Documentation (HTML Format)" SecDocHtml
880   SectionIn 3
881
882   SetOutPath "$INSTDIR\doc"
883   CreateDirectory "$INSTDIR\doc"
884
885 ; File "${SRC_DIR}\manual\bacula\*.html"
886 ; File "${SRC_DIR}\manual\bacula\*.png"
887 ; File "${SRC_DIR}\manual\bacula\*.css"
888 ; CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Manual (HTML).lnk" '"$INSTDIR\doc\index.html"'
889 SectionEnd
890
891 SectionGroupEnd
892
893 Section "-Finish"
894   Push $R0
895
896   ${If} $OsIsNT = 1
897     nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR" /T /G SYSTEM:F Administrators:F'
898     nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$APPDATA\Bacula" /T /G SYSTEM:F Administrators:F'
899   ${EndIf}
900
901   ; Write the uninstall keys for Windows & create Start Menu entry
902   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula"
903   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "InstallLocation" "$INSTDIR"
904   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayVersion" "${VERSION}"
905   ${StrTok} $R0 "${VERSION}" "." 0 0
906   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMajor" $R0
907   ${StrTok} $R0 "${VERSION}" "." 1 0
908   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "VersionMinor" $R0
909   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoModify" 1
910   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "NoRepair" 1
911   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=50727"
912   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "URLInfoAbout" "http://www.bacula.org"
913   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "HelpLink" "http://www.bacula.org/?page=support"
914   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
915   WriteUninstaller "$INSTDIR\Uninstall.exe"
916   CreateShortCut "$SMPROGRAMS\Bacula\Uninstall Bacula.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
917   Pop $R0
918 SectionEnd
919
920 ; Extra Page descriptions
921
922 LangString DESC_SecFileDaemon ${LANG_ENGLISH} "Install Bacula File Daemon on this system."
923 LangString DESC_SecStorageDaemon ${LANG_ENGLISH} "Install Bacula Storage Daemon on this system."
924 LangString DESC_SecDirectorDaemon ${LANG_ENGLISH} "Install Bacula Director Daemon on this system."
925 LangString DESC_SecConsole ${LANG_ENGLISH} "Install command console program on this system."
926 LangString DESC_SecBatConsole ${LANG_ENGLISH} "Install Bat graphical console program on this system."
927 LangString DESC_SecWxConsole ${LANG_ENGLISH} "Install wxWidgets graphical console program on this system."
928 LangString DESC_SecDocPdf ${LANG_ENGLISH} "Install documentation in Acrobat format on this system."
929 LangString DESC_SecDocHtml ${LANG_ENGLISH} "Install documentation in HTML format on this system."
930
931 LangString TITLE_ConfigPage1 ${LANG_ENGLISH} "Configuration"
932 LangString SUBTITLE_ConfigPage1 ${LANG_ENGLISH} "Set installation configuration."
933
934 LangString TITLE_ConfigPage2 ${LANG_ENGLISH} "Configuration (continued)"
935 LangString SUBTITLE_ConfigPage2 ${LANG_ENGLISH} "Set installation configuration."
936
937 LangString TITLE_InstallType ${LANG_ENGLISH} "Installation Type"
938 LangString SUBTITLE_InstallType ${LANG_ENGLISH} "Choose installation type."
939
940 LangString TITLE_WriteTemplates ${LANG_ENGLISH} "Create Templates"
941 LangString SUBTITLE_WriteTemplates ${LANG_ENGLISH} "Create resource templates for inclusion in the Director's configuration file."
942
943 !InsertMacro MUI_FUNCTION_DESCRIPTION_BEGIN
944   !InsertMacro MUI_DESCRIPTION_TEXT ${SecFileDaemon} $(DESC_SecFileDaemon)
945   !InsertMacro MUI_DESCRIPTION_TEXT ${SecStorageDaemon} $(DESC_SecStorageDaemon)
946   !InsertMacro MUI_DESCRIPTION_TEXT ${SecDirectorDaemon} $(DESC_SecDirectorDaemon)
947   !InsertMacro MUI_DESCRIPTION_TEXT ${SecConsole} $(DESC_SecConsole)
948   !InsertMacro MUI_DESCRIPTION_TEXT ${SecBatConsole} $(DESC_SecBatConsole)
949   !InsertMacro MUI_DESCRIPTION_TEXT ${SecWxConsole} $(DESC_SecWxConsole)
950   !InsertMacro MUI_DESCRIPTION_TEXT ${SecDocPdf} $(DESC_SecDocPdf)
951   !InsertMacro MUI_DESCRIPTION_TEXT ${SecDocHtml} $(DESC_SecDocHtml)
952 !InsertMacro MUI_FUNCTION_DESCRIPTION_END
953
954 ; Uninstall section
955
956 UninstallText "This will uninstall Bacula. Hit next to continue."
957
958 Section "Uninstall"
959   ; Shutdown any baculum that could be running
960   nsExec::ExecToLog '"$INSTDIR\bin\bacula-fd.exe" /kill'
961   nsExec::ExecToLog '"$INSTDIR\bin\bacula-sd.exe" /kill'
962   nsExec::ExecToLog '"$INSTDIR\bin\bacula-dir.exe" /kill'
963   Sleep 3000
964
965   ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
966   ${If} $R0 = 1
967     ; Remove bacula service
968     nsExec::ExecToLog '"$INSTDIR\bin\bacula-fd.exe" /remove'
969     nsExec::ExecToLog '"$INSTDIR\bin\exchange-fd.dll" /remove'
970   ${EndIf}
971   
972   ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-sd"
973   ${If} $R0 = 1
974     ; Remove bacula service
975     nsExec::ExecToLog '"$INSTDIR\bin\bacula-sd.exe" /remove'
976   ${EndIf}
977   
978   ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-dir"
979   ${If} $R0 = 1
980     ; Remove bacula service
981     nsExec::ExecToLog '"$INSTDIR\bin\bacula-dir.exe" /remove'
982   ${EndIf}
983   
984   ; remove registry keys
985   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
986   DeleteRegKey HKLM "Software\Bacula"
987
988   ; remove start menu items
989   SetShellVarContext all
990   Delete /REBOOTOK "$SMPROGRAMS\Bacula\*"
991   RMDir "$SMPROGRAMS\Bacula"
992
993   ; remove files and uninstaller (preserving config for now)
994   Delete /REBOOTOK "$INSTDIR\bin\*"
995   Delete /REBOOTOK "$INSTDIR\doc\*"
996   Delete /REBOOTOK "$INSTDIR\*"
997
998   ; Check for existing installation
999   MessageBox MB_YESNO|MB_ICONQUESTION \
1000   "Would you like to delete the current configuration files and the working state file?" IDNO NoDel
1001     Delete /REBOOTOK "$APPDATA\Bacula\*"
1002     Delete /REBOOTOK "$APPDATA\Bacula\Work\*"
1003     Delete /REBOOTOK "$APPDATA\Bacula\Spool\*"
1004     Delete /REBOOTOK "$PLUGINSDIR\bacula-*.conf"
1005     Delete /REBOOTOK "$PLUGINSDIR\*console.conf"
1006     Delete /REBOOTOK "$PLUGINSDIR\*conf.in"
1007     Delete /REBOOTOK "$PLUGINSDIR\openssl.exe"
1008     Delete /REBOOTOK "$PLUGINSDIR\libeay32.dll"
1009     Delete /REBOOTOK "$PLUGINSDIR\ssleay32.dll"
1010     Delete /REBOOTOK "$PLUGINSDIR\sed.exe"    
1011     Delete /REBOOTOK "$PLUGINSDIR\pw.txt"     
1012     Delete /REBOOTOK "$PLUGINSDIR\*.sed" 
1013     Delete /REBOOTOK "$PLUGINSDIR\*.cmd"    
1014     Delete /REBOOTOK "$PLUGINSDIR\*.sql"    
1015     RMDir "$APPDATA\Bacula\Work"
1016     RMDir "$APPDATA\Bacula\Spool"
1017     RMDir "$APPDATA\Bacula"
1018 NoDel:
1019
1020   ; remove directories used
1021   RMDir "$INSTDIR\bin"
1022   RMDir "$INSTDIR\doc"
1023   RMDir "$INSTDIR"
1024 SectionEnd
1025
1026 ;
1027 ; $0 - Service Name (ie Bacula-FD)
1028 ; $1 - Service Description (ie Bacula File Daemon)
1029 ; $2 - Install as Service
1030 ; $3 - Start Service now
1031 ;
1032 Function InstallDaemon
1033   Call InstallCommonFiles
1034
1035   WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
1036   
1037   ${If} $2 = 1
1038     nsExec::ExecToLog '"$INSTDIR\bin\$0.exe" /install -c "$APPDATA\Bacula\$0.conf"'
1039
1040     ${If} $OsIsNT <> 1
1041       File "Start.bat"
1042       File "Stop.bat"
1043     ${EndIf}
1044
1045     ; Start the service?
1046
1047     ${If} $3 = 1  
1048       ${If} $OsIsNT = 1
1049         nsExec::ExecToLog 'net start $0'
1050       ${Else}
1051         Exec '"$INSTDIR\bin\$0.exe" -c "$APPDATA\Bacula\$0.conf"'
1052       ${EndIf}
1053     ${EndIf}
1054   ${Else}
1055     CreateShortCut "$SMPROGRAMS\Bacula\Start $1.lnk" "$INSTDIR\bin\$0.exe" '-c "$APPDATA\Bacula\$0.conf"' "$INSTDIR\bin\$0.exe" 0
1056   ${EndIf}
1057 FunctionEnd
1058
1059 Function GetComputerName
1060   Push $R0
1061   Push $R1
1062   Push $R2
1063
1064   System::Call "kernel32::GetComputerNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2"
1065
1066   ${StrCase} $R0 $R0 "L"
1067
1068   Pop $R2
1069   Pop $R1
1070   Exch $R0
1071 FunctionEnd
1072
1073 !define ComputerNameDnsFullyQualified   3
1074
1075 Function GetHostName
1076   Push $R0
1077   Push $R1
1078   Push $R2
1079
1080   ${If} $OsIsNT = 1
1081     System::Call "kernel32::GetComputerNameExA(i ${ComputerNameDnsFullyQualified}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
1082     ${If} $R2 = 0
1083       Pop $R2
1084       DetailPrint "GetComputerNameExA failed - LastError = $R2"
1085       Call GetComputerName
1086       Pop $R0
1087     ${Else}
1088       Pop $R2
1089     ${EndIf}
1090   ${Else}
1091     Call GetComputerName
1092     Pop $R0
1093   ${EndIf}
1094
1095   Pop $R2
1096   Pop $R1
1097   Exch $R0
1098 FunctionEnd
1099
1100 !define NameUserPrincipal 8
1101
1102 Function GetUserName
1103   Push $R0
1104   Push $R1
1105   Push $R2
1106
1107   ${If} $OsIsNT = 1
1108     System::Call "secur32::GetUserNameExA(i ${NameUserPrincipal}, t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
1109     ${If} $R2 = 0
1110       Pop $R2
1111       DetailPrint "GetUserNameExA failed - LastError = $R2"
1112       Pop $R0
1113       StrCpy $R0 ""
1114     ${Else}
1115       Pop $R2
1116     ${EndIf}
1117   ${Else}
1118       StrCpy $R0 ""
1119   ${EndIf}
1120
1121   ${If} $R0 == ""
1122     System::Call "advapi32::GetUserNameA(t .R0, *i ${NSIS_MAX_STRLEN} R1) i.R2 ?e"
1123     ${If} $R2 = 0
1124       Pop $R2
1125       DetailPrint "GetUserNameA failed - LastError = $R2"
1126       StrCpy $R0 ""
1127     ${Else}
1128       Pop $R2
1129     ${EndIf}
1130   ${EndIf}
1131
1132   Pop $R2
1133   Pop $R1
1134   Exch $R0
1135 FunctionEnd
1136
1137 Function ConfigEditAndCopy
1138   Push $R1
1139
1140   ${If} ${FileExists} "$0\$1"
1141     StrCpy $R1 ".new"
1142   ${Else}
1143     StrCpy $R1 ""
1144   ${EndIf}
1145
1146   nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\$1"'
1147   CopyFiles "$PLUGINSDIR\$1" "$0\$1$R1"
1148
1149   Pop $R1
1150 FunctionEnd
1151
1152 Function FindDatabaseApps
1153   Push $R1
1154
1155   ReadRegStr $0 HKLM "Software\MySQL AB\MySQL Server 5.0" "Location"
1156
1157   ${If} $0 != ""
1158     Call RemoveTrailingSlash
1159     StrCpy $MySQLPath $0
1160     ReadRegStr $0 HKLM "Software\MySQL AB\MySQL Server 5.0" "Version"
1161     StrCpy $MySQLVersion $0
1162   ${EndIf}
1163
1164   EnumRegKey $R1 HKLM "Software\PostgreSQL\Installations" 0
1165   ${If} $R1 != ""
1166     ReadRegStr $0 HKLM "Software\PostgreSQL\Installations\$R1" "Base Directory"
1167     Call RemoveTrailingSlash
1168     StrCpy $PostgreSQLPath $0
1169     ReadRegStr $0 HKLM "Software\PostgreSQL\Installations\$R1" "Version"
1170     StrCpy $PostgreSQLVersion $0
1171   ${EndIf}
1172
1173   Pop $R1
1174 FunctionEnd
1175
1176 Function RemoveTrailingSlash
1177   Push $R1
1178   StrCpy $R1 $0 "" -1
1179   ${If} $R1 == "\"
1180     StrCpy $0 $0 -1
1181   ${EndIf}
1182   Pop $R1
1183 FunctionEnd
1184
1185 Function IsDirectorSelected
1186   Push $R0
1187   SectionGetFlags ${SecDirectorDaemon} $R0
1188   IntOp $R0 $R0 & ${SF_SELECTED}
1189   Exch $R0
1190 FunctionEnd
1191
1192 Function GetSelectedComponents
1193   Push $R0
1194   StrCpy $R0 0
1195   ${If} ${SectionIsSelected} ${SecFileDaemon}
1196     IntOp $R0 $R0 | ${ComponentFile}
1197   ${EndIf}
1198   ${If} ${SectionIsSelected} ${SecStorageDaemon}
1199     IntOp $R0 $R0 | ${ComponentStorage}
1200   ${EndIf}
1201   ${If} ${SectionIsSelected} ${SecDirectorDaemon}
1202     IntOp $R0 $R0 | ${ComponentDirector}
1203   ${EndIf}
1204   ${If} ${SectionIsSelected} ${SecConsole}
1205     IntOp $R0 $R0 | ${ComponentTextConsole}
1206   ${EndIf}
1207   ${If} ${SectionIsSelected} ${SecBatConsole}
1208     IntOp $R0 $R0 | ${ComponentBatConsole}
1209   ${EndIf}
1210   ${If} ${SectionIsSelected} ${SecWxConsole}
1211     IntOp $R0 $R0 | ${ComponentGUIConsole}
1212   ${EndIf}
1213   ${If} ${SectionIsSelected} ${SecDocPdf}
1214     IntOp $R0 $R0 | ${ComponentPDFDocs}
1215   ${EndIf}
1216   ${If} ${SectionIsSelected} ${SecDocHtml}
1217     IntOp $R0 $R0 | ${ComponentHTMLDocs}
1218   ${EndIf}
1219   Exch $R0
1220 FunctionEnd
1221
1222 Function PageComponentsShow
1223   ${If} $OsIsNT <> 1
1224     Call DisableServerSections
1225   ${EndIf}
1226
1227   Call SelectPreviousComponents
1228   Call UpdateComponentUI
1229 FunctionEnd
1230
1231 Function PageDirectoryPre
1232   ${If} $AutomaticInstall = 1
1233   ${OrIf} $InstallType = ${UpgradeInstall}
1234     Abort
1235   ${EndIf}
1236 FunctionEnd
1237
1238 Function LeaveInstallPage
1239   Push "$INSTDIR\install.log"
1240   Call DumpLog
1241 FunctionEnd
1242
1243 Function EnterWriteTemplates
1244   Push $R0
1245   Push $R1
1246
1247   Call GetSelectedComponents
1248   Pop $R0
1249
1250   IntOp $R0 $R0 & ${ComponentDirector}
1251   IntOp $R1 $NewComponents & ${ComponentsFileAndStorage}
1252
1253   ${If} $R0 <> 0
1254   ${OrIf} $R1 = 0
1255     Pop $R1
1256     Pop $R0
1257     Abort
1258   ${EndIf}
1259
1260   IntOp $R0 $NewComponents & ${ComponentFile}
1261   ${If} $R0 = 0
1262     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" State 0
1263     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" Flags DISABLED
1264     DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" State
1265     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1266   ${Else}
1267     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" State 1
1268     DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 2" Flags
1269     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 3" State "C:\$ConfigClientName.conf"
1270     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST
1271   ${EndIf}
1272
1273   IntOp $R0 $NewComponents & ${ComponentStorage}
1274   ${If} $R0 = 0
1275     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" State 0
1276     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" Flags DISABLED
1277     DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" State
1278     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST|DISABLED
1279   ${Else}
1280     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" State 1
1281     DeleteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 4" Flags
1282     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" State "C:\$ConfigStorageName.conf"
1283     WriteINIStr "$PLUGINSDIR\WriteTemplates.ini" "Field 5" Flags REQ_SAVE|FILE_EXPLORER|WARN_IF_EXIST
1284   ${EndIf}
1285
1286   !InsertMacro MUI_HEADER_TEXT "$(TITLE_WriteTemplates)" "$(SUBTITLE_WriteTemplates)"
1287   !InsertMacro MUI_INSTALLOPTIONS_DISPLAY "WriteTemplates.ini"
1288
1289   !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 2" State
1290   ${If} $R0 <> 0
1291     File "/oname=$PLUGINSDIR\client.conf.in" "client.conf.in"
1292
1293     nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\client.conf.in"'
1294     !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 3" State
1295     ${If} $R0 != ""
1296       CopyFiles "$PLUGINSDIR\client.conf.in" "$R0"
1297     ${EndIf}
1298   ${EndIf}
1299
1300   !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 4" State
1301   ${If} $R0 <> 0
1302     File "/oname=$PLUGINSDIR\storage.conf.in" "storage.conf.in"
1303
1304     nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\storage.conf.in"'
1305     !InsertMacro MUI_INSTALLOPTIONS_READ $R0 "WriteTemplates.ini" "Field 5" State
1306     ${If} $R0 != ""
1307       CopyFiles "$PLUGINSDIR\storage.conf.in" "$R0"
1308     ${EndIf}
1309   ${EndIf}
1310
1311   Pop $R1
1312   Pop $R0
1313 FunctionEnd
1314
1315 Function SelectPreviousComponents
1316   ${If} $InstallType <> ${NewInstall}
1317     IntOp $R1 $PreviousComponents & ${ComponentFile}
1318     ${If} $R1 <> 0
1319       !InsertMacro SelectSection ${SecFileDaemon}
1320       !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_RO}
1321     ${Else}
1322       !InsertMacro UnselectSection ${SecFileDaemon}
1323       !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_RO}
1324     ${EndIf}
1325     IntOp $R1 $PreviousComponents & ${ComponentStorage}
1326     ${If} $R1 <> 0
1327       !InsertMacro SelectSection ${SecStorageDaemon}
1328       !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_RO}
1329     ${Else}
1330       !InsertMacro UnselectSection ${SecStorageDaemon}
1331       !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_RO}
1332     ${EndIf}
1333     IntOp $R1 $PreviousComponents & ${ComponentDirector}
1334     ${If} $R1 <> 0
1335       !InsertMacro SelectSection ${SecDirectorDaemon}
1336       !InsertMacro SetSectionFlag ${SecDirectorDaemon} ${SF_RO}
1337     ${Else}
1338       !InsertMacro UnselectSection ${SecDirectorDaemon}
1339       !InsertMacro ClearSectionFlag ${SecDirectorDaemon} ${SF_RO}
1340     ${EndIf}
1341     IntOp $R1 $PreviousComponents & ${ComponentTextConsole}
1342     ${If} $R1 <> 0
1343       !InsertMacro SelectSection ${SecConsole}
1344       !InsertMacro SetSectionFlag ${SecConsole} ${SF_RO}
1345     ${Else}
1346       !InsertMacro UnselectSection ${SecConsole}
1347       !InsertMacro ClearSectionFlag ${SecConsole} ${SF_RO}
1348     ${EndIf}
1349     IntOp $R1 $PreviousComponents & ${ComponentBatConsole}
1350     ${If} $R1 <> 0
1351       !InsertMacro SelectSection ${SecBatConsole}
1352       !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_RO}
1353     ${Else}
1354       !InsertMacro UnselectSection ${SecBatConsole}
1355       !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_RO}
1356     ${EndIf}
1357     IntOp $R1 $PreviousComponents & ${ComponentGUIConsole}
1358     ${If} $R1 <> 0
1359       !InsertMacro SelectSection ${SecWxConsole}
1360       !InsertMacro SetSectionFlag ${SecWxConsole} ${SF_RO}
1361     ${Else}
1362       !InsertMacro UnselectSection ${SecWxConsole}
1363       !InsertMacro ClearSectionFlag ${SecWxConsole} ${SF_RO}
1364     ${EndIf}
1365     IntOp $R1 $PreviousComponents & ${ComponentPDFDocs}
1366     ${If} $R1 <> 0
1367       !InsertMacro SelectSection ${SecDocPdf}
1368       !InsertMacro SetSectionFlag ${SecDocPdf} ${SF_RO}
1369     ${Else}
1370       !InsertMacro UnselectSection ${SecDocPdf}
1371       !InsertMacro ClearSectionFlag ${SecDocPdf} ${SF_RO}
1372     ${EndIf}
1373     IntOp $R1 $PreviousComponents & ${ComponentHTMLDocs}
1374     ${If} $R1 <> 0
1375       !InsertMacro SelectSection ${SecDocHtml}
1376       !InsertMacro SetSectionFlag ${SecDocHtml} ${SF_RO}
1377     ${Else}
1378       !InsertMacro UnselectSection ${SecDocHtml}
1379       !InsertMacro ClearSectionFlag ${SecDocHtml} ${SF_RO}
1380     ${EndIf}
1381   ${EndIf}
1382 FunctionEnd
1383
1384 Function DisableServerSections
1385   !InsertMacro UnselectSection ${SecGroupServer}
1386   !InsertMacro SetSectionFlag  ${SecGroupServer} ${SF_RO}
1387   !InsertMacro UnselectSection ${SecStorageDaemon}
1388   !InsertMacro SetSectionFlag  ${SecStorageDaemon} ${SF_RO}
1389   !InsertMacro UnselectSection ${SecDirectorDaemon}
1390   !InsertMacro SetSectionFlag  ${SecDirectorDaemon} ${SF_RO}
1391 FunctionEnd
1392
1393 Function UpdateComponentUI
1394   Push $R0
1395   Push $R1
1396
1397   Call GetSelectedComponents
1398   Pop $R0
1399
1400   IntOp $R1 $R0 ^ $PreviousComponents
1401   IntOp $NewComponents $R0 & $R1
1402
1403   ${If} $InstallType <> ${NewInstall}
1404     IntOp $R1 $NewComponents & ${ComponentFile}
1405     ${If} $R1 <> 0
1406       !InsertMacro SetSectionFlag ${SecFileDaemon} ${SF_BOLD}
1407     ${Else}
1408       !InsertMacro ClearSectionFlag ${SecFileDaemon} ${SF_BOLD}
1409     ${EndIf}
1410     IntOp $R1 $NewComponents & ${ComponentStorage}
1411     ${If} $R1 <> 0
1412       !InsertMacro SetSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1413     ${Else}
1414       !InsertMacro ClearSectionFlag ${SecStorageDaemon} ${SF_BOLD}
1415     ${EndIf}
1416     IntOp $R1 $NewComponents & ${ComponentDirector}
1417     ${If} $R1 <> 0
1418       !InsertMacro SetSectionFlag ${SecDirectorDaemon} ${SF_BOLD}
1419     ${Else}
1420       !InsertMacro ClearSectionFlag ${SecDirectorDaemon} ${SF_BOLD}
1421     ${EndIf}
1422     IntOp $R1 $NewComponents & ${ComponentTextConsole}
1423     ${If} $R1 <> 0
1424       !InsertMacro SetSectionFlag ${SecConsole} ${SF_BOLD}
1425     ${Else}
1426       !InsertMacro ClearSectionFlag ${SecConsole} ${SF_BOLD}
1427     ${EndIf}
1428     IntOp $R1 $NewComponents & ${ComponentBatConsole}
1429     ${If} $R1 <> 0
1430       !InsertMacro SetSectionFlag ${SecBatConsole} ${SF_BOLD}
1431     ${Else}
1432       !InsertMacro ClearSectionFlag ${SecBatConsole} ${SF_BOLD}
1433     ${EndIf}
1434     IntOp $R1 $NewComponents & ${ComponentGUIConsole}
1435     ${If} $R1 <> 0
1436       !InsertMacro SetSectionFlag ${SecWxConsole} ${SF_BOLD}
1437     ${Else}
1438       !InsertMacro ClearSectionFlag ${SecWxConsole} ${SF_BOLD}
1439     ${EndIf}
1440     IntOp $R1 $NewComponents & ${ComponentPDFDocs}
1441     ${If} $R1 <> 0
1442       !InsertMacro SetSectionFlag ${SecDocPdf} ${SF_BOLD}
1443     ${Else}
1444       !InsertMacro ClearSectionFlag ${SecDocPdf} ${SF_BOLD}
1445     ${EndIf}
1446     IntOp $R1 $NewComponents & ${ComponentHTMLDocs}
1447     ${If} $R1 <> 0
1448       !InsertMacro SetSectionFlag ${SecDocHtml} ${SF_BOLD}
1449     ${Else}
1450       !InsertMacro ClearSectionFlag ${SecDocHtml} ${SF_BOLD}
1451     ${EndIf}
1452   ${EndIf}
1453
1454   GetDlgItem $R0 $HWNDPARENT 1
1455
1456   IntOp $R1 $NewComponents & ${ComponentsRequiringUserConfig}
1457   ${If} $R1 = 0
1458     SendMessage $R0 ${WM_SETTEXT} 0 "STR:Install"
1459   ${Else}
1460     SendMessage $R0 ${WM_SETTEXT} 0 "STR:&Next >"
1461   ${EndIf}
1462
1463   Pop $R1
1464   Pop $R0
1465 FunctionEnd
1466
1467 !include "InstallType.nsh"
1468 !include "ConfigPage1.nsh"
1469 !include "ConfigPage2.nsh"
1470 !include "DumpLog.nsh"