[995] | 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/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 $MinimumSpace$
|
---|
| 16 | DefVar $InstallDir32$
|
---|
| 17 | DefVar $InstallDir64$
|
---|
| 18 | DefVar $ExitCode$
|
---|
| 19 | DefVar $LicenseRequired$
|
---|
| 20 | DefVar $LicenseKey$
|
---|
| 21 | DefVar $LicensePool$
|
---|
| 22 | DefVar $INST_SystemType$
|
---|
| 23 | DefVar $INST_architecture$
|
---|
| 24 |
|
---|
| 25 | Set $INST_SystemType$ = GetSystemType
|
---|
| 26 |
|
---|
| 27 | ;
|
---|
| 28 | ; get product properties for options
|
---|
| 29 | ;
|
---|
| 30 | ; multi-value values are return as string, seperated by ",", eg. "value1,value2,value3",
|
---|
| 31 | ; therefore we replace "," by " " (split, compose)
|
---|
| 32 | ;
|
---|
| 33 | DefVar $Options$
|
---|
| 34 | Set $Options$ = composeString( splitString ( GetProductProperty("options",""), "," ), " " )
|
---|
| 35 |
|
---|
| 36 | comment "options: " + $Options$
|
---|
| 37 |
|
---|
| 38 | Set $LogDir$ = "%SystemDrive%\tmp"
|
---|
| 39 |
|
---|
| 40 | ; ----------------------------------------------------------------
|
---|
| 41 | ; - Please edit the following values -
|
---|
| 42 | ; ----------------------------------------------------------------
|
---|
| 43 | ;$ProductId$ should be the name of the product in opsi
|
---|
| 44 | ; therefore please: only lower letters, no umlauts,
|
---|
| 45 | ; no white space use '-' as a seperator
|
---|
| 46 | Set $ProductId$ = "wsusoffline"
|
---|
| 47 | Set $MinimumSpace$ = "300 MB"
|
---|
| 48 | ; the path were we find the product after the installation
|
---|
| 49 | Set $InstallDir32$ = "%ProgramFiles32Dir%\<path to the product>"
|
---|
| 50 | Set $InstallDir64$ = "%ProgramFiles64Dir%\<path to the product>"
|
---|
| 51 | Set $LicenseRequired$ = "false"
|
---|
| 52 | Set $LicensePool$ = "p_" + $ProductId$
|
---|
| 53 | ; ----------------------------------------------------------------
|
---|
| 54 |
|
---|
| 55 | if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
|
---|
| 56 | LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
|
---|
| 57 | isFatalError
|
---|
| 58 | ; Stop process and set installation status to failed
|
---|
| 59 | else
|
---|
| 60 | comment "Show product picture"
|
---|
| 61 | ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
|
---|
| 62 |
|
---|
| 63 | ;if FileExists("%ScriptPath%\delsub3264.ins")
|
---|
| 64 | ; comment "Start uninstall sub section"
|
---|
| 65 | ; Sub "%ScriptPath%\delsub3264.ins"
|
---|
| 66 | ;endif
|
---|
| 67 |
|
---|
| 68 | ;if $LicenseRequired$ = "true"
|
---|
| 69 | ; comment "Licensing required, reserve license and get license key"
|
---|
| 70 | ; Sub_get_licensekey
|
---|
| 71 | ;endif
|
---|
| 72 |
|
---|
| 73 | comment "installing"
|
---|
| 74 |
|
---|
| 75 | Message "Installing " + $ProductId$ + " ..."
|
---|
| 76 | comment "Start setup program"
|
---|
| 77 | Winbatch_install
|
---|
| 78 | Sub_check_exitcode
|
---|
| 79 | ;comment "Copy files"
|
---|
| 80 | ;Files_install_32 /32Bit
|
---|
| 81 | ;comment "Patch Registry"
|
---|
| 82 | ;Registry_install /32Bit
|
---|
| 83 | ;comment "Create shortcuts"
|
---|
| 84 | ;LinkFolder_install
|
---|
| 85 |
|
---|
| 86 | endif
|
---|
| 87 |
|
---|
| 88 | [Winbatch_install]
|
---|
| 89 | "%ScriptPath%\exit-wrapper.cmd" "%ScriptPath%\client\cmd\DoUpdate.cmd" $Options$
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | [Files_install_32]
|
---|
| 93 | ; Example of recursively copying some files into the installation directory:
|
---|
| 94 | ;
|
---|
| 95 | ; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
|
---|
| 96 |
|
---|
| 97 | [Registry_install]
|
---|
| 98 | ; Example of setting some values of an registry key:
|
---|
| 99 | ;
|
---|
| 100 | ; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
|
---|
| 101 | ; set "name1" = "some string value"
|
---|
| 102 | ; set "name2" = REG_DWORD:0001
|
---|
| 103 | ; set "name3" = REG_BINARY:00 af 99 cd
|
---|
| 104 |
|
---|
| 105 | [LinkFolder_install]
|
---|
| 106 | ; Example of deleting a folder from AllUsers startmenu:
|
---|
| 107 | ;
|
---|
| 108 | ; set_basefolder common_programs
|
---|
| 109 | ; delete_subfolder $ProductId$
|
---|
| 110 | ;
|
---|
| 111 | ; Example of creating an shortcut to the installed exe in AllUsers startmenu:
|
---|
| 112 | ;
|
---|
| 113 | ; set_basefolder common_programs
|
---|
| 114 | ; set_subfolder $ProductId$
|
---|
| 115 | ;
|
---|
| 116 | ; set_link
|
---|
| 117 | ; name: $ProductId$
|
---|
| 118 | ; target: <path to the program>
|
---|
| 119 | ; parameters:
|
---|
| 120 | ; working_dir: $InstallDir$
|
---|
| 121 | ; icon_file:
|
---|
| 122 | ; icon_index:
|
---|
| 123 | ; end_link
|
---|
| 124 | ;
|
---|
| 125 | ; Example of creating an shortcut to the installed exe on AllUsers desktop:
|
---|
| 126 | ;
|
---|
| 127 | ; set_basefolder common_desktopdirectory
|
---|
| 128 | ; set_subfolder ""
|
---|
| 129 | ;
|
---|
| 130 | ; set_link
|
---|
| 131 | ; name: $ProductId$
|
---|
| 132 | ; target: <path to the program>
|
---|
| 133 | ; parameters: <some_param>
|
---|
| 134 | ; working_dir: $InstallDir$
|
---|
| 135 | ; icon_file: <path to icon file>
|
---|
| 136 | ; icon_index: 2
|
---|
| 137 | ; end_link
|
---|
| 138 |
|
---|
| 139 | [Sub_get_licensekey]
|
---|
| 140 | comment "License management is enabled and will be used"
|
---|
| 141 |
|
---|
| 142 | comment "Trying to get a license key"
|
---|
| 143 | Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
|
---|
| 144 | ; If there is an assignment of exactly one licensepool to the product the following call is possible:
|
---|
| 145 | ; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
|
---|
| 146 | ;
|
---|
| 147 | ; If there is an assignment of a license pool to a windows software id, it is possible to use:
|
---|
| 148 | ; DefVar $WindowsSoftwareId$
|
---|
| 149 | ; $WindowsSoftwareId$ = "..."
|
---|
| 150 | ; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
|
---|
| 151 |
|
---|
| 152 | DefVar $ServiceErrorClass$
|
---|
| 153 | set $ServiceErrorClass$ = getLastServiceErrorClass
|
---|
| 154 | comment "Error class: " + $ServiceErrorClass$
|
---|
| 155 |
|
---|
| 156 | if $ServiceErrorClass$ = "None"
|
---|
| 157 | comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
|
---|
| 158 | else
|
---|
| 159 | if $ServiceErrorClass$ = "LicenseConfigurationError"
|
---|
| 160 | LogError "Fatal: license configuration must be corrected"
|
---|
| 161 | LogError getLastServiceErrorMessage
|
---|
| 162 | isFatalError
|
---|
| 163 | else
|
---|
| 164 | if $ServiceErrorClass$ = "LicenseMissingError"
|
---|
| 165 | LogError "Fatal: required license is not supplied"
|
---|
| 166 | isFatalError
|
---|
| 167 | endif
|
---|
| 168 | endif
|
---|
| 169 | endif
|
---|
| 170 |
|
---|
| 171 |
|
---|
| 172 |
|
---|
| 173 | [Sub_check_exitcode]
|
---|
| 174 | comment "Test for installation success via exit code"
|
---|
| 175 | set $ExitCode$ = getLastExitCode
|
---|
| 176 | ; informations to exit codes see
|
---|
| 177 | ; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
|
---|
| 178 | ; http://msdn.microsoft.com/en-us/library/aa368542.aspx
|
---|
| 179 | if ($ExitCode$ = "0")
|
---|
| 180 | comment "Looks good: setup program gives exitcode zero"
|
---|
| 181 | else
|
---|
| 182 | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
|
---|
| 183 | if ($ExitCode$ = "1605")
|
---|
| 184 | comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
|
---|
| 185 | comment "Uninstall of a not installed product failed - no problem"
|
---|
| 186 | else
|
---|
| 187 | if ($ExitCode$ = "1641")
|
---|
| 188 | comment "looks good: setup program gives exitcode 1641"
|
---|
| 189 | comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
|
---|
| 190 | ExitWindows /Reboot
|
---|
| 191 | else
|
---|
| 192 | if ($ExitCode$ = "3010")
|
---|
| 193 | comment "looks good: setup program gives exitcode 3010"
|
---|
| 194 | comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
|
---|
| 195 | ExitWindows /Reboot
|
---|
| 196 | else
|
---|
| 197 | if ($ExitCode$ = "3011")
|
---|
| 198 | comment "looks good: setup program gives exitcode 3011"
|
---|
| 199 | comment "ERROR_SUCCESS: wsusoffline requires reboot and rerun."
|
---|
| 200 | ExitWindows /ImmediateReboot
|
---|
| 201 | else
|
---|
| 202 | logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
|
---|
| 203 | isFatalError
|
---|
| 204 | endif
|
---|
| 205 | endif
|
---|
| 206 | endif
|
---|
| 207 | endif
|
---|
| 208 | endif
|
---|
| 209 |
|
---|