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 |
|
---|
137 | if ($INST_NTVersion$ >= "6.0")
|
---|
138 | DosBatch_open_firewall_nt6
|
---|
139 | else
|
---|
140 | DosBatch_open_firewall
|
---|
141 | endif
|
---|
142 |
|
---|
143 | ; start FD immediatly, not only after reboot
|
---|
144 | DosBatch_start_bacula-fd
|
---|
145 |
|
---|
146 | ;
|
---|
147 | ; end
|
---|
148 | ;
|
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 | ; winbatch installer:
|
---|
153 | ; /S silent installl
|
---|
154 | ; /D destination path
|
---|
155 | ; use this, otherwise it installs to "program files" for all languages.
|
---|
156 | ; don't use " around argument, otherwise argument is ignored
|
---|
157 |
|
---|
158 | [Winbatch_install_32]
|
---|
159 | "%ScriptPath%\data\bacula-win32-$ProductVer$.exe" /S /D=$InstallDir32$
|
---|
160 |
|
---|
161 | [Winbatch_install_64]
|
---|
162 | "%ScriptPath%\data\bacula-win64-$ProductVer$.exe" /S /D=$InstallDir64$
|
---|
163 |
|
---|
164 | [DosBatch_bacula-fd.conf]
|
---|
165 | (
|
---|
166 | echo #
|
---|
167 | echo # managed by opsi
|
---|
168 | echo #
|
---|
169 | echo # "Global" File daemon configuration specifications
|
---|
170 | echo #
|
---|
171 | echo FileDaemon { # this is me
|
---|
172 | echo Name = "$filedaemon_full_name$"
|
---|
173 | echo FDport = 9102 # where we listen for the director
|
---|
174 | echo WorkingDirectory = "$InstallDirOpsi$\\working"
|
---|
175 | echo Pid Directory = "$InstallDirOpsi$\\working"
|
---|
176 | echo Plugin Directory = "$InstallDirOpsi$\\plugins"
|
---|
177 | echo Maximum Concurrent Jobs = 10
|
---|
178 | echo }
|
---|
179 | ;echo
|
---|
180 | echo #
|
---|
181 | echo # List Directors who are permitted to contact this File daemon
|
---|
182 | echo #
|
---|
183 | echo Director {
|
---|
184 | echo Name = "$director_name$"
|
---|
185 | echo Password = "$filedaemon_full_password$"
|
---|
186 | echo }
|
---|
187 | ;echo
|
---|
188 | echo #
|
---|
189 | echo # Restricted Director, used by tray-monitor to get the
|
---|
190 | echo # status of the file daemon
|
---|
191 | echo #
|
---|
192 | echo Director {
|
---|
193 | echo Name = "$filedaemon_monitor_name$"
|
---|
194 | echo Password = "$filedaemon_monitor_password$"
|
---|
195 | echo Monitor = yes
|
---|
196 | echo }
|
---|
197 | ;echo
|
---|
198 | echo # Send all messages except skipped files back to Director
|
---|
199 | echo Messages {
|
---|
200 | echo Name = Standard
|
---|
201 | echo director = $director_name$ = all, !skipped, !restored
|
---|
202 | echo }
|
---|
203 | ) > $InstallDir$/bacula-fd.conf
|
---|
204 |
|
---|
205 |
|
---|
206 |
|
---|
207 | [DosBatch_bconsole.conf]
|
---|
208 | (
|
---|
209 | echo #
|
---|
210 | echo # managed by opsi
|
---|
211 | echo #
|
---|
212 | echo Director {
|
---|
213 | echo Name = "$director_name$"
|
---|
214 | echo Address = "$director_address$"
|
---|
215 | echo DIRport = 9101
|
---|
216 | echo Password = "$director_password$"
|
---|
217 | echo }
|
---|
218 | ) > $InstallDir$/bconsole.conf
|
---|
219 |
|
---|
220 |
|
---|
221 |
|
---|
222 | [DosBatch_bat.conf]
|
---|
223 | (
|
---|
224 | echo #
|
---|
225 | echo # managed by opsi
|
---|
226 | echo #
|
---|
227 | echo Director {
|
---|
228 | echo Name = "$director_name$"
|
---|
229 | echo Address = "$director_address$"
|
---|
230 | echo DIRport = 9101
|
---|
231 | echo Password = "$director_password$"
|
---|
232 | echo }
|
---|
233 | ) > $InstallDir$/bat.conf
|
---|
234 |
|
---|
235 |
|
---|
236 |
|
---|
237 | [DosBatch_tray-monitor.conf]
|
---|
238 | (
|
---|
239 | echo #
|
---|
240 | echo # managed by opsi
|
---|
241 | echo #
|
---|
242 | echo Monitor {
|
---|
243 | echo Name = "$filedaemon_monitor_name$"
|
---|
244 | echo Password = "$filedaemon_monitor_password$"
|
---|
245 | echo RefreshInterval = 30 seconds
|
---|
246 | echo }
|
---|
247 | echo
|
---|
248 | echo Client {
|
---|
249 | echo Name = "$filedaemon_full_name$"
|
---|
250 | echo Address = localhost
|
---|
251 | echo FDport = 9102
|
---|
252 | echo Password = "$filedaemon_monitor_password$"
|
---|
253 | echo }
|
---|
254 | ) > $InstallDir$/tray-monitor.conf
|
---|
255 |
|
---|
256 |
|
---|
257 |
|
---|
258 | [DosBatch_open_firewall]
|
---|
259 | netsh firewall add portopening protocol=TCP port=9102 name=bacula-fd-port
|
---|
260 |
|
---|
261 | [DosBatch_open_firewall_nt6]
|
---|
262 | netsh advfirewall firewall add rule name="bacula-fd-port" dir=in action=allow protocol=TCP localport=9102
|
---|
263 |
|
---|
264 | [DosBatch_start_bacula-fd]
|
---|
265 | net start bacula-fd
|
---|
266 |
|
---|
267 | [opsiservicecall_set_product_property_filedaemon_full_name]
|
---|
268 | "method": "setProductProperty",
|
---|
269 | "params": [
|
---|
270 | 'bacula',
|
---|
271 | 'filedaemon_full_name',
|
---|
272 | '$filedaemon_full_name$',
|
---|
273 | '%HostID%'
|
---|
274 | ]
|
---|
275 |
|
---|
276 | [opsiservicecall_set_product_property_filedaemon_monitor_name]
|
---|
277 | "method": "setProductProperty",
|
---|
278 | "params": [
|
---|
279 | 'bacula',
|
---|
280 | 'filedaemon_monitor_name',
|
---|
281 | '$filedaemon_monitor_name$',
|
---|
282 | '%HostID%'
|
---|
283 | ]
|
---|
284 |
|
---|
285 |
|
---|
286 | [Files_install_32]
|
---|
287 | ; Example of recursively copying some files into the installation directory:
|
---|
288 | ;
|
---|
289 | ; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
|
---|
290 |
|
---|
291 | [Files_install_64]
|
---|
292 | ; Example of recursively copying some files into the installation directory:
|
---|
293 | ;
|
---|
294 | ; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
|
---|
295 |
|
---|
296 | [Registry_install]
|
---|
297 | ; Example of setting some values of an registry key:
|
---|
298 | ;
|
---|
299 | ; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
|
---|
300 | ; set "name1" = "some string value"
|
---|
301 | ; set "name2" = REG_DWORD:0001
|
---|
302 | ; set "name3" = REG_BINARY:00 af 99 cd
|
---|
303 |
|
---|
304 | [LinkFolder_install]
|
---|
305 | ; Example of deleting a folder from AllUsers startmenu:
|
---|
306 | ;
|
---|
307 | ; set_basefolder common_programs
|
---|
308 | ; delete_subfolder $ProductId$
|
---|
309 | ;
|
---|
310 | ; Example of creating an shortcut to the installed exe in AllUsers startmenu:
|
---|
311 | ;
|
---|
312 | ; set_basefolder common_programs
|
---|
313 | ; set_subfolder $ProductId$
|
---|
314 | ;
|
---|
315 | ; set_link
|
---|
316 | ; name: $ProductId$
|
---|
317 | ; target: <path to the program>
|
---|
318 | ; parameters:
|
---|
319 | ; working_dir: $InstallDir$
|
---|
320 | ; icon_file:
|
---|
321 | ; icon_index:
|
---|
322 | ; end_link
|
---|
323 | ;
|
---|
324 | ; Example of creating an shortcut to the installed exe on AllUsers desktop:
|
---|
325 | ;
|
---|
326 | ; set_basefolder common_desktopdirectory
|
---|
327 | ; set_subfolder ""
|
---|
328 | ;
|
---|
329 | ; set_link
|
---|
330 | ; name: $ProductId$
|
---|
331 | ; target: <path to the program>
|
---|
332 | ; parameters: <some_param>
|
---|
333 | ; working_dir: $InstallDir$
|
---|
334 | ; icon_file: <path to icon file>
|
---|
335 | ; icon_index: 2
|
---|
336 | ; end_link
|
---|
337 |
|
---|
338 | [Sub_get_licensekey]
|
---|
339 | comment "License management is enabled and will be used"
|
---|
340 |
|
---|
341 | comment "Trying to get a license key"
|
---|
342 | Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
|
---|
343 | ; If there is an assignment of exactly one licensepool to the product the following call is possible:
|
---|
344 | ; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
|
---|
345 | ;
|
---|
346 | ; If there is an assignment of a license pool to a windows software id, it is possible to use:
|
---|
347 | ; DefVar $WindowsSoftwareId$
|
---|
348 | ; $WindowsSoftwareId$ = "..."
|
---|
349 | ; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
|
---|
350 |
|
---|
351 | DefVar $ServiceErrorClass$
|
---|
352 | set $ServiceErrorClass$ = getLastServiceErrorClass
|
---|
353 | comment "Error class: " + $ServiceErrorClass$
|
---|
354 |
|
---|
355 | if $ServiceErrorClass$ = "None"
|
---|
356 | comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
|
---|
357 | else
|
---|
358 | if $ServiceErrorClass$ = "LicenseConfigurationError"
|
---|
359 | LogError "Fatal: license configuration must be corrected"
|
---|
360 | LogError getLastServiceErrorMessage
|
---|
361 | isFatalError
|
---|
362 | else
|
---|
363 | if $ServiceErrorClass$ = "LicenseMissingError"
|
---|
364 | LogError "Fatal: required license is not supplied"
|
---|
365 | isFatalError
|
---|
366 | endif
|
---|
367 | endif
|
---|
368 | endif
|
---|
369 |
|
---|
370 | [Sub_check_exitcode]
|
---|
371 | comment "Test for installation success via exit code"
|
---|
372 | set $ExitCode$ = getLastExitCode
|
---|
373 | ; informations to exit codes see
|
---|
374 | ; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
|
---|
375 | ; http://msdn.microsoft.com/en-us/library/aa368542.aspx
|
---|
376 | if ($ExitCode$ = "0")
|
---|
377 | comment "Looks good: setup program gives exitcode zero"
|
---|
378 | else
|
---|
379 | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
|
---|
380 | if ($ExitCode$ = "1605")
|
---|
381 | comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
|
---|
382 | comment "Uninstall of a not installed product failed - no problem"
|
---|
383 | else
|
---|
384 | if ($ExitCode$ = "1641")
|
---|
385 | comment "looks good: setup program gives exitcode 1641"
|
---|
386 | comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
|
---|
387 | else
|
---|
388 | if ($ExitCode$ = "3010")
|
---|
389 | comment "looks good: setup program gives exitcode 3010"
|
---|
390 | comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
|
---|
391 | else
|
---|
392 | logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
|
---|
393 | isFatalError
|
---|
394 | endif
|
---|
395 | endif
|
---|
396 | endif
|
---|
397 | endif
|
---|
398 |
|
---|