[1022] | 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$
|
---|
[1023] | 17 | DefVar $InstallDir$
|
---|
[1022] | 18 | DefVar $InstallDir32$
|
---|
| 19 | DefVar $InstallDir64$
|
---|
[1098] | 20 | DefVar $InstallDirOpsi$
|
---|
[1022] | 21 | DefVar $ExitCode$
|
---|
| 22 | DefVar $LicenseRequired$
|
---|
| 23 | DefVar $LicenseKey$
|
---|
| 24 | DefVar $LicensePool$
|
---|
| 25 | DefVar $INST_SystemType$
|
---|
[1099] | 26 | DefVar $INST_NTVersion$
|
---|
[1022] | 27 | DefVar $INST_architecture$
|
---|
| 28 |
|
---|
[1101] | 29 | DefVar $catalog$
|
---|
[1023] | 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 |
|
---|
[1099] | 39 | Set $INST_SystemType$ = GetSystemType
|
---|
| 40 | set $INST_NTVersion$ = GetMsVersionInfo
|
---|
[1022] | 41 | set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
|
---|
| 42 |
|
---|
[1099] | 43 | set $catalog$ = GetProductProperty( "catalog", "MyCatalog" )
|
---|
[1029] | 44 | set $filedaemon_full_name$ = GetProductProperty( "filedaemon_full_name", "" )
|
---|
[1023] | 45 | set $filedaemon_full_password$ = GetProductProperty( "filedaemon_full_password", "filedaemon_full_password" )
|
---|
[1029] | 46 | set $filedaemon_monitor_name$ = GetProductProperty( "filedaemon_monitor_name", "" )
|
---|
[1023] | 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" )
|
---|
[1022] | 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"
|
---|
[1023] | 62 | Set $MinimumSpace$ = "30 MB"
|
---|
[1022] | 63 | ; the path were we find the product after the installation
|
---|
[1023] | 64 | Set $InstallDir$ = "%ProgramFilesDir%\Bacula"
|
---|
| 65 | Set $InstallDir32$ = "%ProgramFiles32Dir%\Bacula"
|
---|
| 66 | Set $InstallDir64$ = "%ProgramFiles64Dir%\Bacula"
|
---|
[1098] | 67 | ; opsi requires path seperation by "\\" instead of "\"
|
---|
| 68 | Set $InstallDirOpsi$ = composeString( splitString ( $InstallDir$, "\"), "\\" )
|
---|
[1022] | 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
|
---|
[1023] | 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 |
|
---|
[1029] | 94 | if $filedaemon_full_name$ = ""
|
---|
| 95 | set $filedaemon_full_name$ = "%HostID%-fd"
|
---|
| 96 | opsiservicecall_set_product_property_filedaemon_full_name
|
---|
[1023] | 97 | endif
|
---|
[1022] | 98 |
|
---|
[1029] | 99 | if $filedaemon_monitor_name$ = ""
|
---|
| 100 | set $filedaemon_monitor_name$ = "%HostID%-mon"
|
---|
| 101 | opsiservicecall_set_product_property_filedaemon_monitor_name
|
---|
| 102 | endif
|
---|
[1022] | 103 |
|
---|
[1029] | 104 |
|
---|
[1023] | 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
|
---|
[1022] | 116 | endif
|
---|
| 117 |
|
---|
[1023] | 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
|
---|
[1099] | 133 | DosBatch_bconsole.conf
|
---|
| 134 | DosBatch_bat.conf
|
---|
[1103] | 135 | DosBatch_tray-monitor.conf
|
---|
[1106] | 136 | ; some config files are expected in %CommonAppdataDir%\Bacula\
|
---|
| 137 | Files_copy_conf
|
---|
[1023] | 138 |
|
---|
[1099] | 139 | if ($INST_NTVersion$ >= "6.0")
|
---|
[1102] | 140 | DosBatch_open_firewall_nt6
|
---|
[1099] | 141 | else
|
---|
[1102] | 142 | DosBatch_open_firewall
|
---|
[1099] | 143 | endif
|
---|
| 144 |
|
---|
| 145 | ; start FD immediatly, not only after reboot
|
---|
| 146 | DosBatch_start_bacula-fd
|
---|
| 147 |
|
---|
[1022] | 148 | ;
|
---|
[1023] | 149 | ; end
|
---|
[1022] | 150 | ;
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 |
|
---|
[1023] | 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
|
---|
[1022] | 159 |
|
---|
[1023] | 160 | [Winbatch_install_32]
|
---|
| 161 | "%ScriptPath%\data\bacula-win32-$ProductVer$.exe" /S /D=$InstallDir32$
|
---|
[1022] | 162 |
|
---|
| 163 | [Winbatch_install_64]
|
---|
[1023] | 164 | "%ScriptPath%\data\bacula-win64-$ProductVer$.exe" /S /D=$InstallDir64$
|
---|
[1022] | 165 |
|
---|
[1023] | 166 | [DosBatch_bacula-fd.conf]
|
---|
| 167 | (
|
---|
[1038] | 168 | echo #
|
---|
[1023] | 169 | echo # managed by opsi
|
---|
| 170 | echo #
|
---|
| 171 | echo # "Global" File daemon configuration specifications
|
---|
| 172 | echo #
|
---|
| 173 | echo FileDaemon { # this is me
|
---|
[1099] | 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"
|
---|
[1023] | 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 {
|
---|
[1099] | 186 | echo Name = "$director_name$"
|
---|
[1023] | 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 {
|
---|
[1099] | 195 | echo Name = "$filedaemon_monitor_name$"
|
---|
[1023] | 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 }
|
---|
[1038] | 205 | ) > $InstallDir$/bacula-fd.conf
|
---|
[1022] | 206 |
|
---|
[1099] | 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 }
|
---|
[1112] | 249 | ;echo
|
---|
[1099] | 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 |
|
---|
[1029] | 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 | ]
|
---|
[1022] | 277 |
|
---|
[1029] | 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 | ]
|
---|
[1022] | 286 |
|
---|
[1029] | 287 |
|
---|
[1106] | 288 | [Files_copy_conf]
|
---|
[1107] | 289 | copy "$InstallDir$\*.conf" "%CommonAppdataDir%\Bacula\"
|
---|
[1106] | 290 |
|
---|
| 291 |
|
---|
[1023] | 292 | [Files_install_32]
|
---|
| 293 | ; Example of recursively copying some files into the installation directory:
|
---|
| 294 | ;
|
---|
| 295 | ; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
|
---|
| 296 |
|
---|
[1022] | 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 |
|
---|