source: opsi/products/bitlocker/CLIENT_DATA/setup.ins@ 1185

Last change on this file since 1185 was 1035, checked in by joergs, on Jul 12, 2012 at 5:43:24 PM

some Windows 7 system not as expected and return errorcode 0 instead of -1, therefore use registry RebootCounter to cound number of reboots

File size: 6.2 KB
Line 
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]
7requiredWinstVersion >= "4.10.8.6"
8
9DefVar $MsiId$
10DefVar $UninstallProgram$
11DefVar $LogDir$
12DefVar $ProductId$
13DefVar $MinimumSpace$
14DefVar $InstallDir$
15DefVar $ExitCode$
16DefVar $LicenseRequired$
17DefVar $LicenseKey$
18DefVar $LicensePool$
19
20DefVar $RegKeyRebootCounter$
21DefVar $RebootCounter$
22Set $RegKeyRebootCounter$ = "[HKLM\SOFTWARE\opsi.org\custom\bitlocker]"
23
24
25DefVar $TpmPassword$
26DefVar $RecoveryPassword$
27
28Set $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
36Set $ProductId$ = "bitlocker"
37Set $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
44if 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
48else
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
56
57 sub_get_rebootcounter
58 comment "rebootcounter = $RebootCounter$"
59
60
61 Message "Installing " + $ProductId$ + ", Counter: " + $RebootCounter$
62
63 comment "Start setup program"
64
65 set $TpmPassword$ = GetProductProperty("TpmPassword", "none")
66 set $RecoveryPassword$ = GetProductProperty("RecoveryPassword", "none")
67
68 ShellInAnIcon_status winst /sysnative
69
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
77
78 #winbatch_tpm_TakeOwnerShip
79 #sub_check_exitcode_tpm_TakeOwnerShip
80 ShellInAnIcon_tpm_TakeOwnerShip winst /sysnative
81
82 #winbatch_bitlocker_activate
83 #sub_check_exitcode_bitlocker_activate
84 ShellInAnIcon_tpm_bitlocker_activate winst /sysnative
85 ExitWindows /Reboot
86
87 ShellInAnIcon_status winst /sysnative
88endif
89
90[ShellInAnIcon_status]
91manage-bde -status
92manage-bde -protectors c: -get
93
94[ShellInAnIcon_tpm_activate]
95manage-bde -tpm -TurnOn
96
97[winbatch_tpm_activate]
98manage-bde -tpm -TurnOn
99
100[sub_check_exitcode_tpm_activate]
101comment "Test exit code"
102# WARNING:
103# There are systems, that return 0, even if the TPM is already activated.
104# This results in an endless loop
105#
106set $ExitCode$ = getLastExitCode
107if ($ExitCode$ = "0")
108 comment "Looks good: setup program gives exitcode zero. Reboot required"
109 ExitWindows /ImmediateReboot
110else
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
117endif
118
119
120
121[ShellInAnIcon_tpm_TakeOwnerShip]
122manage-bde -tpm -TakeOwnerShip $TpmPassword$
123
124[winbatch_tpm_TakeOwnerShip]
125manage-bde -tpm -TakeOwnerShip $TpmPassword$
126
127[sub_check_exitcode_tpm_TakeOwnerShip]
128comment "Test exit code"
129set $ExitCode$ = getLastExitCode
130if ($ExitCode$ = "0")
131 comment "Looks good: setup program gives exitcode zero"
132else
133 if ($ExitCode$ = "-1")
134 comment "TPM has an owner. ignored"
135 else
136 logError "Fatal: unknown error code ("+$ExitCode$+"), giving up"
137 isFatalError
138 endif
139endif
140
141[ShellInAnIcon_bitlocker_activate]
142manage-bde -on c: -RecoveryPassword $RecoveryPassword$
143
144[winbatch_bitlocker_activate]
145manage-bde -on c: -RecoveryPassword $RecoveryPassword$
146
147[sub_check_exitcode_bitlocker_activate]
148comment "Test exit code"
149set $ExitCode$ = getLastExitCode
150if ($ExitCode$ = "0")
151 comment "Looks good: setup program gives exitcode zero"
152 ExitWindows /Reboot
153else
154 logError "Fatal: unknown error code ("+$ExitCode$+"), giving up"
155 isFatalError
156endif
157
158
159[Sub_check_exitcode]
160comment "Test for installation success via exit code"
161set $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
165if ($ExitCode$ = "0")
166 comment "Looks good: setup program gives exitcode zero"
167else
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
186endif
187
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]
205openkey $RegKeyRebootCounter$
206set "RebootCounter" = "$Rebootcounter$"
Note: See TracBrowser for help on using the repository browser.