[1021] | 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 $MsiId$
|
---|
| 10 | DefVar $UninstallProgram$
|
---|
| 11 | DefVar $LogDir$
|
---|
| 12 | DefVar $ProductId$
|
---|
| 13 | DefVar $MinimumSpace$
|
---|
| 14 | DefVar $InstallDir$
|
---|
| 15 | DefVar $ExitCode$
|
---|
| 16 | DefVar $LicenseRequired$
|
---|
| 17 | DefVar $LicenseKey$
|
---|
| 18 | DefVar $LicensePool$
|
---|
| 19 |
|
---|
[1035] | 20 | DefVar $RegKeyRebootCounter$
|
---|
| 21 | DefVar $RebootCounter$
|
---|
| 22 | Set $RegKeyRebootCounter$ = "[HKLM\SOFTWARE\opsi.org\custom\bitlocker]"
|
---|
| 23 |
|
---|
| 24 |
|
---|
[1021] | 25 | DefVar $TpmPassword$
|
---|
| 26 | DefVar $RecoveryPassword$
|
---|
| 27 |
|
---|
| 28 | Set $LogDir$ = "%SystemDrive%\tmp"
|
---|
| 29 |
|
---|
| 30 | ; ----------------------------------------------------------------
|
---|
| 31 | ; - Please edit the following values -
|
---|
| 32 | ; ----------------------------------------------------------------
|
---|
| 33 | ;$ProductId$ should be the name of the product in opsi
|
---|
| 34 | ; therefore please: only lower letters, no umlauts,
|
---|
| 35 | ; no white space use '-' as a seperator
|
---|
| 36 | Set $ProductId$ = "bitlocker"
|
---|
| 37 | Set $MinimumSpace$ = "1 MB"
|
---|
| 38 | ; the path were we find the product after the installation
|
---|
| 39 | ;Set $InstallDir$ = "%ProgramFiles32Dir%\<path to the product>"
|
---|
| 40 | ;Set $LicenseRequired$ = "false"
|
---|
| 41 | ;Set $LicensePool$ = "p_" + $ProductId$
|
---|
| 42 | ; ----------------------------------------------------------------
|
---|
| 43 |
|
---|
| 44 | if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
|
---|
| 45 | LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
|
---|
| 46 | isFatalError
|
---|
| 47 | ; Stop process and set installation status to failed
|
---|
| 48 | else
|
---|
| 49 | comment "Show product picture"
|
---|
| 50 | ShowBitmap "%ScriptPath%\logo.png" $ProductId$
|
---|
| 51 |
|
---|
| 52 | ;if FileExists("%ScriptPath%\delsub.ins")
|
---|
| 53 | ; comment "Start uninstall sub section"
|
---|
| 54 | ; Sub "%ScriptPath%\delsub.ins"
|
---|
| 55 | ;endif
|
---|
[1035] | 56 |
|
---|
| 57 | sub_get_rebootcounter
|
---|
| 58 | comment "rebootcounter = $RebootCounter$"
|
---|
| 59 |
|
---|
[1021] | 60 |
|
---|
[1035] | 61 | Message "Installing " + $ProductId$ + ", Counter: " + $RebootCounter$
|
---|
[1021] | 62 |
|
---|
| 63 | comment "Start setup program"
|
---|
| 64 |
|
---|
| 65 | set $TpmPassword$ = GetProductProperty("TpmPassword", "none")
|
---|
| 66 | set $RecoveryPassword$ = GetProductProperty("RecoveryPassword", "none")
|
---|
| 67 |
|
---|
[1033] | 68 | ShellInAnIcon_status winst /sysnative
|
---|
[1021] | 69 |
|
---|
[1035] | 70 | if (( $RebootCounter$ = "" ) or ( $RebootCounter$ = "0" ))
|
---|
| 71 | #winbatch_tpm_activate
|
---|
| 72 | #sub_check_exitcode_tpm_activate
|
---|
| 73 | ShellInAnIcon_tpm_activate winst /sysnative
|
---|
| 74 | set $RebootCounter$ = "1"
|
---|
| 75 | sub_do_reboot
|
---|
| 76 | endif
|
---|
[1021] | 77 |
|
---|
[1035] | 78 | #winbatch_tpm_TakeOwnerShip
|
---|
| 79 | #sub_check_exitcode_tpm_TakeOwnerShip
|
---|
| 80 | ShellInAnIcon_tpm_TakeOwnerShip winst /sysnative
|
---|
[1021] | 81 |
|
---|
[1035] | 82 | #winbatch_bitlocker_activate
|
---|
| 83 | #sub_check_exitcode_bitlocker_activate
|
---|
| 84 | ShellInAnIcon_tpm_bitlocker_activate winst /sysnative
|
---|
| 85 | ExitWindows /Reboot
|
---|
[1021] | 86 |
|
---|
[1035] | 87 | ShellInAnIcon_status winst /sysnative
|
---|
[1021] | 88 | endif
|
---|
| 89 |
|
---|
| 90 | [ShellInAnIcon_status]
|
---|
| 91 | manage-bde -status
|
---|
| 92 | manage-bde -protectors c: -get
|
---|
| 93 |
|
---|
[1035] | 94 | [ShellInAnIcon_tpm_activate]
|
---|
| 95 | manage-bde -tpm -TurnOn
|
---|
| 96 |
|
---|
[1021] | 97 | [winbatch_tpm_activate]
|
---|
| 98 | manage-bde -tpm -TurnOn
|
---|
| 99 |
|
---|
| 100 | [sub_check_exitcode_tpm_activate]
|
---|
| 101 | comment "Test exit code"
|
---|
[1035] | 102 | # WARNING:
|
---|
| 103 | # There are systems, that return 0, even if the TPM is already activated.
|
---|
| 104 | # This results in an endless loop
|
---|
| 105 | #
|
---|
[1021] | 106 | set $ExitCode$ = getLastExitCode
|
---|
| 107 | if ($ExitCode$ = "0")
|
---|
| 108 | comment "Looks good: setup program gives exitcode zero. Reboot required"
|
---|
| 109 | ExitWindows /ImmediateReboot
|
---|
| 110 | else
|
---|
| 111 | if ($ExitCode$ = "-1")
|
---|
| 112 | comment "TPM is already activated, ignored"
|
---|
| 113 | else
|
---|
| 114 | logError "Fatal: unknown error code ("+$ExitCode$+"), giving up"
|
---|
| 115 | isFatalError
|
---|
| 116 | endif
|
---|
| 117 | endif
|
---|
| 118 |
|
---|
| 119 |
|
---|
[1035] | 120 |
|
---|
| 121 | [ShellInAnIcon_tpm_TakeOwnerShip]
|
---|
| 122 | manage-bde -tpm -TakeOwnerShip $TpmPassword$
|
---|
| 123 |
|
---|
[1021] | 124 | [winbatch_tpm_TakeOwnerShip]
|
---|
| 125 | manage-bde -tpm -TakeOwnerShip $TpmPassword$
|
---|
| 126 |
|
---|
| 127 | [sub_check_exitcode_tpm_TakeOwnerShip]
|
---|
| 128 | comment "Test exit code"
|
---|
| 129 | set $ExitCode$ = getLastExitCode
|
---|
| 130 | if ($ExitCode$ = "0")
|
---|
[1035] | 131 | comment "Looks good: setup program gives exitcode zero"
|
---|
[1021] | 132 | else
|
---|
| 133 | if ($ExitCode$ = "-1")
|
---|
| 134 | comment "TPM has an owner. ignored"
|
---|
| 135 | else
|
---|
[1035] | 136 | logError "Fatal: unknown error code ("+$ExitCode$+"), giving up"
|
---|
| 137 | isFatalError
|
---|
[1021] | 138 | endif
|
---|
| 139 | endif
|
---|
| 140 |
|
---|
[1035] | 141 | [ShellInAnIcon_bitlocker_activate]
|
---|
| 142 | manage-bde -on c: -RecoveryPassword $RecoveryPassword$
|
---|
| 143 |
|
---|
[1021] | 144 | [winbatch_bitlocker_activate]
|
---|
| 145 | manage-bde -on c: -RecoveryPassword $RecoveryPassword$
|
---|
| 146 |
|
---|
| 147 | [sub_check_exitcode_bitlocker_activate]
|
---|
| 148 | comment "Test exit code"
|
---|
| 149 | set $ExitCode$ = getLastExitCode
|
---|
| 150 | if ($ExitCode$ = "0")
|
---|
[1035] | 151 | comment "Looks good: setup program gives exitcode zero"
|
---|
| 152 | ExitWindows /Reboot
|
---|
[1021] | 153 | else
|
---|
[1035] | 154 | logError "Fatal: unknown error code ("+$ExitCode$+"), giving up"
|
---|
| 155 | isFatalError
|
---|
[1021] | 156 | endif
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 | [Sub_check_exitcode]
|
---|
| 160 | comment "Test for installation success via exit code"
|
---|
| 161 | set $ExitCode$ = getLastExitCode
|
---|
| 162 | ; informations to exit codes see
|
---|
| 163 | ; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
|
---|
| 164 | ; http://msdn.microsoft.com/en-us/library/aa368542.aspx
|
---|
| 165 | if ($ExitCode$ = "0")
|
---|
| 166 | comment "Looks good: setup program gives exitcode zero"
|
---|
| 167 | else
|
---|
| 168 | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
|
---|
| 169 | if ($ExitCode$ = "1605")
|
---|
| 170 | comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
|
---|
| 171 | comment "Uninstall of a not installed product failed - no problem"
|
---|
| 172 | else
|
---|
| 173 | if ($ExitCode$ = "1641")
|
---|
| 174 | comment "looks good: setup program gives exitcode 1641"
|
---|
| 175 | comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
|
---|
| 176 | else
|
---|
| 177 | if ($ExitCode$ = "3010")
|
---|
| 178 | comment "looks good: setup program gives exitcode 3010"
|
---|
| 179 | comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
|
---|
| 180 | else
|
---|
| 181 | logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
|
---|
| 182 | isFatalError
|
---|
| 183 | endif
|
---|
| 184 | endif
|
---|
| 185 | endif
|
---|
| 186 | endif
|
---|
| 187 |
|
---|
[1035] | 188 | [sub_get_rebootcounter]
|
---|
| 189 | Set $RebootCounter$ = GetRegistryStringValue( $RegKeyRebootCounter$ + "RebootCounter")
|
---|
| 190 | if ( $RebootCounter$ = "" )
|
---|
| 191 | set $RebootCounter$ = "0"
|
---|
| 192 | endif
|
---|
| 193 |
|
---|
| 194 | [sub_set_rebootcounter]
|
---|
| 195 | if ( $RebootCounter$ = "" )
|
---|
| 196 | set $RebootCounter$ = "0"
|
---|
| 197 | endif
|
---|
| 198 | registry_rebootcounter
|
---|
| 199 |
|
---|
| 200 | [sub_do_reboot]
|
---|
| 201 | sub_set_rebootcounter
|
---|
| 202 | ExitWindows /ImmediateReboot
|
---|
| 203 |
|
---|
| 204 | [registry_rebootcounter]
|
---|
| 205 | openkey $RegKeyRebootCounter$
|
---|
| 206 | set "RebootCounter" = "$Rebootcounter$"
|
---|