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