1 | ; Copyright (c) uib gmbh (www.uib.de)
|
---|
2 | ; This sourcecode is owned by uib
|
---|
3 | ; and published under the Terms of the General Public License.
|
---|
4 | ; credits: http://www.opsi.org/en/credits/
|
---|
5 |
|
---|
6 | [Actions]
|
---|
7 | requiredWinstVersion >= "4.10.8.6"
|
---|
8 |
|
---|
9 | DefVar $MsiId32$
|
---|
10 | DefVar $UninstallProgram32$
|
---|
11 | DefVar $MsiId64$
|
---|
12 | DefVar $UninstallProgram64$
|
---|
13 | DefVar $LogDir$
|
---|
14 | DefVar $ProductId$
|
---|
15 | DefVar $ProductVer$
|
---|
16 | DefVar $MinimumSpace$
|
---|
17 | DefVar $InstallDir$
|
---|
18 | DefVar $InstallDir32$
|
---|
19 | DefVar $InstallDir64$
|
---|
20 | DefVar $InstallDirOpsi$
|
---|
21 | DefVar $ExitCode$
|
---|
22 | DefVar $LicenseRequired$
|
---|
23 | DefVar $LicenseKey$
|
---|
24 | DefVar $LicensePool$
|
---|
25 | DefVar $INST_SystemType$
|
---|
26 | DefVar $INST_NTVersion$
|
---|
27 | DefVar $INST_architecture$
|
---|
28 |
|
---|
29 | DefVar $catalog$
|
---|
30 | DefVar $filedaemon_full_name$
|
---|
31 | DefVar $filedaemon_full_password$
|
---|
32 | DefVar $filedaemon_monitor_name$
|
---|
33 | DefVar $filedaemon_monitor_password$
|
---|
34 | DefVar $director_name$
|
---|
35 | DefVar $director_address$
|
---|
36 | DefVar $director_password$
|
---|
37 |
|
---|
38 |
|
---|
39 | Set $INST_SystemType$ = GetSystemType
|
---|
40 | set $INST_NTVersion$ = GetMsVersionInfo
|
---|
41 | set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
|
---|
42 |
|
---|
43 | set $catalog$ = GetProductProperty( "catalog", "MyCatalog" )
|
---|
44 | set $filedaemon_full_name$ = GetProductProperty( "filedaemon_full_name", "" )
|
---|
45 | set $filedaemon_full_password$ = GetProductProperty( "filedaemon_full_password", "filedaemon_full_password" )
|
---|
46 | set $filedaemon_monitor_name$ = GetProductProperty( "filedaemon_monitor_name", "" )
|
---|
47 | set $filedaemon_monitor_password$ = GetProductProperty( "filedaemon_monitor_password", "filedaemon_monitor_password" )
|
---|
48 | set $director_name$ = GetProductProperty( "director_name", "director_name" )
|
---|
49 | set $director_address$ = GetProductProperty( "director_address", "director_address.example.com" )
|
---|
50 | set $director_password$ = GetProductProperty( "director_password", "director_password" )
|
---|
51 |
|
---|
52 | Set $LogDir$ = "%SystemDrive%\tmp"
|
---|
53 |
|
---|
54 | ; ----------------------------------------------------------------
|
---|
55 | ; - Please edit the following values -
|
---|
56 | ; ----------------------------------------------------------------
|
---|
57 | ;$ProductId$ should be the name of the product in opsi
|
---|
58 | ; therefore please: only lower letters, no umlauts,
|
---|
59 | ; no white space use '-' as a seperator
|
---|
60 | Set $ProductId$ = "bacula"
|
---|
61 | Set $ProductVer$ = "5.2.10"
|
---|
62 | Set $MinimumSpace$ = "30 MB"
|
---|
63 | ; the path were we find the product after the installation
|
---|
64 | Set $InstallDir$ = "%ProgramFilesDir%\Bacula"
|
---|
65 | Set $InstallDir32$ = "%ProgramFiles32Dir%\Bacula"
|
---|
66 | Set $InstallDir64$ = "%ProgramFiles64Dir%\Bacula"
|
---|
67 | ; opsi requires path seperation by "\\" instead of "\"
|
---|
68 | Set $InstallDirOpsi$ = composeString( splitString ( $InstallDir$, "\"), "\\" )
|
---|
69 | Set $LicenseRequired$ = "false"
|
---|
70 | Set $LicensePool$ = "p_" + $ProductId$
|
---|
71 | ; ----------------------------------------------------------------
|
---|
72 |
|
---|
73 | if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
|
---|
74 | LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
|
---|
75 | isFatalError
|
---|
76 | ; Stop process and set installation status to failed
|
---|
77 | endif
|
---|
78 |
|
---|
79 | comment "Show product picture"
|
---|
80 | ShowBitmap "%ScriptPath%\logo.png" $ProductId$
|
---|
81 |
|
---|
82 | if FileExists("%ScriptPath%\delsub3264.ins")
|
---|
83 | comment "Start uninstall sub section"
|
---|
84 | Sub "%ScriptPath%\delsub3264.ins"
|
---|
85 | endif
|
---|
86 |
|
---|
87 | ;if $LicenseRequired$ = "true"
|
---|
88 | ; comment "Licensing required, reserve license and get license key"
|
---|
89 | ; Sub_get_licensekey
|
---|
90 | ;endif
|
---|
91 |
|
---|
92 | comment "installing"
|
---|
93 |
|
---|
94 | if $filedaemon_full_name$ = ""
|
---|
95 | set $filedaemon_full_name$ = "%HostID%-fd"
|
---|
96 | opsiservicecall_set_product_property_filedaemon_full_name
|
---|
97 | endif
|
---|
98 |
|
---|
99 | if $filedaemon_monitor_name$ = ""
|
---|
100 | set $filedaemon_monitor_name$ = "%HostID%-mon"
|
---|
101 | opsiservicecall_set_product_property_filedaemon_monitor_name
|
---|
102 | endif
|
---|
103 |
|
---|
104 |
|
---|
105 | if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
|
---|
106 | Message "Installing " + $ProductId$ + " 32 Bit..."
|
---|
107 | comment "Start setup program"
|
---|
108 | Winbatch_install_32
|
---|
109 | Sub_check_exitcode
|
---|
110 | ;comment "Copy files"
|
---|
111 | ;Files_install_32 /32Bit
|
---|
112 | ;comment "Patch Registry"
|
---|
113 | ;Registry_install /32Bit
|
---|
114 | ;comment "Create shortcuts"
|
---|
115 | ;LinkFolder_install
|
---|
116 | endif
|
---|
117 |
|
---|
118 | if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
|
---|
119 | Message "Installing " + $ProductId$ + " 64 Bit..."
|
---|
120 | comment "Start setup program"
|
---|
121 | Winbatch_install_64
|
---|
122 | Sub_check_exitcode
|
---|
123 | ;comment "Copy files"
|
---|
124 | ;Files_install_64 /64Bit
|
---|
125 | ;comment "Patch Registry"
|
---|
126 | ;Registry_install /64Bit
|
---|
127 | ;comment "Create shortcuts"
|
---|
128 | ;LinkFolder_install
|
---|
129 | endif
|
---|
130 |
|
---|
131 | ;Patches_bacula_conf $InstallDir$+"\bacula-fd.conf"
|
---|
132 | DosBatch_bacula-fd.conf
|
---|
133 | DosBatch_bconsole.conf
|
---|
134 | DosBatch_bat.conf
|
---|
135 | DosBatch_tray-monitor.conf
|
---|
136 | ; some config files are expected in %CommonAppdataDir%\Bacula\
|
---|
137 | Files_copy_conf
|
---|
138 |
|
---|
139 | if ($INST_NTVersion$ >= "6.0")
|
---|
140 | DosBatch_open_firewall_nt6
|
---|
141 | else
|
---|
142 | DosBatch_open_firewall
|
---|
143 | endif
|
---|
144 |
|
---|
145 | ; start FD immediatly, not only after reboot
|
---|
146 | DosBatch_start_bacula-fd
|
---|
147 |
|
---|
148 | ;
|
---|
149 | ; end
|
---|
150 | ;
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 | ; winbatch installer:
|
---|
155 | ; /S silent installl
|
---|
156 | ; /D destination path
|
---|
157 | ; use this, otherwise it installs to "program files" for all languages.
|
---|
158 | ; don't use " around argument, otherwise argument is ignored
|
---|
159 |
|
---|
160 | [Winbatch_install_32]
|
---|
161 | "%ScriptPath%\data\bacula-win32-$ProductVer$.exe" /S /D=$InstallDir32$
|
---|
162 |
|
---|
163 | [Winbatch_install_64]
|
---|
164 | "%ScriptPath%\data\bacula-win64-$ProductVer$.exe" /S /D=$InstallDir64$
|
---|
165 |
|
---|
166 | [DosBatch_bacula-fd.conf]
|
---|
167 | (
|
---|
168 | echo #
|
---|
169 | echo # managed by opsi
|
---|
170 | echo #
|
---|
171 | echo # "Global" File daemon configuration specifications
|
---|
172 | echo #
|
---|
173 | echo FileDaemon { # this is me
|
---|
174 | echo Name = "$filedaemon_full_name$"
|
---|
175 | echo FDport = 9102 # where we listen for the director
|
---|
176 | echo WorkingDirectory = "$InstallDirOpsi$\\working"
|
---|
177 | echo Pid Directory = "$InstallDirOpsi$\\working"
|
---|
178 | echo Plugin Directory = "$InstallDirOpsi$\\plugins"
|
---|
179 | echo Maximum Concurrent Jobs = 10
|
---|
180 | echo }
|
---|
181 | ;echo
|
---|
182 | echo #
|
---|
183 | echo # List Directors who are permitted to contact this File daemon
|
---|
184 | echo #
|
---|
185 | echo Director {
|
---|
186 | echo Name = "$director_name$"
|
---|
187 | echo Password = "$filedaemon_full_password$"
|
---|
188 | echo }
|
---|
189 | ;echo
|
---|
190 | echo #
|
---|
191 | echo # Restricted Director, used by tray-monitor to get the
|
---|
192 | echo # status of the file daemon
|
---|
193 | echo #
|
---|
194 | echo Director {
|
---|
195 | echo Name = "$filedaemon_monitor_name$"
|
---|
196 | echo Password = "$filedaemon_monitor_password$"
|
---|
197 | echo Monitor = yes
|
---|
198 | echo }
|
---|
199 | ;echo
|
---|
200 | echo # Send all messages except skipped files back to Director
|
---|
201 | echo Messages {
|
---|
202 | echo Name = Standard
|
---|
203 | echo director = $director_name$ = all, !skipped, !restored
|
---|
204 | echo }
|
---|
205 | ) > $InstallDir$/bacula-fd.conf
|
---|
206 |
|
---|
207 |
|
---|
208 |
|
---|
209 | [DosBatch_bconsole.conf]
|
---|
210 | (
|
---|
211 | echo #
|
---|
212 | echo # managed by opsi
|
---|
213 | echo #
|
---|
214 | echo Director {
|
---|
215 | echo Name = "$director_name$"
|
---|
216 | echo Address = "$director_address$"
|
---|
217 | echo DIRport = 9101
|
---|
218 | echo Password = "$director_password$"
|
---|
219 | echo }
|
---|
220 | ) > $InstallDir$/bconsole.conf
|
---|
221 |
|
---|
222 |
|
---|
223 |
|
---|
224 | [DosBatch_bat.conf]
|
---|
225 | (
|
---|
226 | echo #
|
---|
227 | echo # managed by opsi
|
---|
228 | echo #
|
---|
229 | echo Director {
|
---|
230 | echo Name = "$director_name$"
|
---|
231 | echo Address = "$director_address$"
|
---|
232 | echo DIRport = 9101
|
---|
233 | echo Password = "$director_password$"
|
---|
234 | echo }
|
---|
235 | ) > $InstallDir$/bat.conf
|
---|
236 |
|
---|
237 |
|
---|
238 |
|
---|
239 | [DosBatch_tray-monitor.conf]
|
---|
240 | (
|
---|
241 | echo #
|
---|
242 | echo # managed by opsi
|
---|
243 | echo #
|
---|
244 | echo Monitor {
|
---|
245 | echo Name = "$filedaemon_monitor_name$"
|
---|
246 | echo Password = "$filedaemon_monitor_password$"
|
---|
247 | echo RefreshInterval = 30 seconds
|
---|
248 | echo }
|
---|
249 | echo
|
---|
250 | echo Client {
|
---|
251 | echo Name = "$filedaemon_full_name$"
|
---|
252 | echo Address = localhost
|
---|
253 | echo FDport = 9102
|
---|
254 | echo Password = "$filedaemon_monitor_password$"
|
---|
255 | echo }
|
---|
256 | ) > $InstallDir$/tray-monitor.conf
|
---|
257 |
|
---|
258 |
|
---|
259 |
|
---|
260 | [DosBatch_open_firewall]
|
---|
261 | netsh firewall add portopening protocol=TCP port=9102 name=bacula-fd-port
|
---|
262 |
|
---|
263 | [DosBatch_open_firewall_nt6]
|
---|
264 | netsh advfirewall firewall add rule name="bacula-fd-port" dir=in action=allow protocol=TCP localport=9102
|
---|
265 |
|
---|
266 | [DosBatch_start_bacula-fd]
|
---|
267 | net start bacula-fd
|
---|
268 |
|
---|
269 | [opsiservicecall_set_product_property_filedaemon_full_name]
|
---|
270 | "method": "setProductProperty",
|
---|
271 | "params": [
|
---|
272 | 'bacula',
|
---|
273 | 'filedaemon_full_name',
|
---|
274 | '$filedaemon_full_name$',
|
---|
275 | '%HostID%'
|
---|
276 | ]
|
---|
277 |
|
---|
278 | [opsiservicecall_set_product_property_filedaemon_monitor_name]
|
---|
279 | "method": "setProductProperty",
|
---|
280 | "params": [
|
---|
281 | 'bacula',
|
---|
282 | 'filedaemon_monitor_name',
|
---|
283 | '$filedaemon_monitor_name$',
|
---|
284 | '%HostID%'
|
---|
285 | ]
|
---|
286 |
|
---|
287 |
|
---|
288 | [Files_copy_conf]
|
---|
289 | copy "$InstallDir$\*.conf" "%CommonAppdataDir%\Bacula\"
|
---|
290 |
|
---|
291 |
|
---|
292 | [Files_install_32]
|
---|
293 | ; Example of recursively copying some files into the installation directory:
|
---|
294 | ;
|
---|
295 | ; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
|
---|
296 |
|
---|
297 | [Files_install_64]
|
---|
298 | ; Example of recursively copying some files into the installation directory:
|
---|
299 | ;
|
---|
300 | ; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
|
---|
301 |
|
---|
302 | [Registry_install]
|
---|
303 | ; Example of setting some values of an registry key:
|
---|
304 | ;
|
---|
305 | ; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
|
---|
306 | ; set "name1" = "some string value"
|
---|
307 | ; set "name2" = REG_DWORD:0001
|
---|
308 | ; set "name3" = REG_BINARY:00 af 99 cd
|
---|
309 |
|
---|
310 | [LinkFolder_install]
|
---|
311 | ; Example of deleting a folder from AllUsers startmenu:
|
---|
312 | ;
|
---|
313 | ; set_basefolder common_programs
|
---|
314 | ; delete_subfolder $ProductId$
|
---|
315 | ;
|
---|
316 | ; Example of creating an shortcut to the installed exe in AllUsers startmenu:
|
---|
317 | ;
|
---|
318 | ; set_basefolder common_programs
|
---|
319 | ; set_subfolder $ProductId$
|
---|
320 | ;
|
---|
321 | ; set_link
|
---|
322 | ; name: $ProductId$
|
---|
323 | ; target: <path to the program>
|
---|
324 | ; parameters:
|
---|
325 | ; working_dir: $InstallDir$
|
---|
326 | ; icon_file:
|
---|
327 | ; icon_index:
|
---|
328 | ; end_link
|
---|
329 | ;
|
---|
330 | ; Example of creating an shortcut to the installed exe on AllUsers desktop:
|
---|
331 | ;
|
---|
332 | ; set_basefolder common_desktopdirectory
|
---|
333 | ; set_subfolder ""
|
---|
334 | ;
|
---|
335 | ; set_link
|
---|
336 | ; name: $ProductId$
|
---|
337 | ; target: <path to the program>
|
---|
338 | ; parameters: <some_param>
|
---|
339 | ; working_dir: $InstallDir$
|
---|
340 | ; icon_file: <path to icon file>
|
---|
341 | ; icon_index: 2
|
---|
342 | ; end_link
|
---|
343 |
|
---|
344 | [Sub_get_licensekey]
|
---|
345 | comment "License management is enabled and will be used"
|
---|
346 |
|
---|
347 | comment "Trying to get a license key"
|
---|
348 | Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
|
---|
349 | ; If there is an assignment of exactly one licensepool to the product the following call is possible:
|
---|
350 | ; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
|
---|
351 | ;
|
---|
352 | ; If there is an assignment of a license pool to a windows software id, it is possible to use:
|
---|
353 | ; DefVar $WindowsSoftwareId$
|
---|
354 | ; $WindowsSoftwareId$ = "..."
|
---|
355 | ; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
|
---|
356 |
|
---|
357 | DefVar $ServiceErrorClass$
|
---|
358 | set $ServiceErrorClass$ = getLastServiceErrorClass
|
---|
359 | comment "Error class: " + $ServiceErrorClass$
|
---|
360 |
|
---|
361 | if $ServiceErrorClass$ = "None"
|
---|
362 | comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
|
---|
363 | else
|
---|
364 | if $ServiceErrorClass$ = "LicenseConfigurationError"
|
---|
365 | LogError "Fatal: license configuration must be corrected"
|
---|
366 | LogError getLastServiceErrorMessage
|
---|
367 | isFatalError
|
---|
368 | else
|
---|
369 | if $ServiceErrorClass$ = "LicenseMissingError"
|
---|
370 | LogError "Fatal: required license is not supplied"
|
---|
371 | isFatalError
|
---|
372 | endif
|
---|
373 | endif
|
---|
374 | endif
|
---|
375 |
|
---|
376 | [Sub_check_exitcode]
|
---|
377 | comment "Test for installation success via exit code"
|
---|
378 | set $ExitCode$ = getLastExitCode
|
---|
379 | ; informations to exit codes see
|
---|
380 | ; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
|
---|
381 | ; http://msdn.microsoft.com/en-us/library/aa368542.aspx
|
---|
382 | if ($ExitCode$ = "0")
|
---|
383 | comment "Looks good: setup program gives exitcode zero"
|
---|
384 | else
|
---|
385 | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
|
---|
386 | if ($ExitCode$ = "1605")
|
---|
387 | comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
|
---|
388 | comment "Uninstall of a not installed product failed - no problem"
|
---|
389 | else
|
---|
390 | if ($ExitCode$ = "1641")
|
---|
391 | comment "looks good: setup program gives exitcode 1641"
|
---|
392 | comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
|
---|
393 | else
|
---|
394 | if ($ExitCode$ = "3010")
|
---|
395 | comment "looks good: setup program gives exitcode 3010"
|
---|
396 | comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
|
---|
397 | else
|
---|
398 | logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
|
---|
399 | isFatalError
|
---|
400 | endif
|
---|
401 | endif
|
---|
402 | endif
|
---|
403 | endif
|
---|
404 |
|
---|