source: opsi/products/xenserver-tools/CLIENT_DATA/setup.ins @ 949

Last change on this file since 949 was 949, checked in by joergs, 12 years ago

opsi-template

File size: 10.0 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/credits/
5
6[Actions]
7requiredWinstVersion >= "4.10.8.6"
8
9DefVar $MsiId32$
10DefVar $UninstallProgram32$
11DefVar $MsiId64$
12DefVar $UninstallProgram64$
13DefVar $LogDir$
14DefVar $ProductId$ 
15DefVar $MinimumSpace$
16DefVar $InstallDir32$
17DefVar $InstallDir64$
18DefVar $ExitCode$
19DefVar $LicenseRequired$
20DefVar $LicenseKey$
21DefVar $LicensePool$
22DefVar $INST_SystemType$
23DefVar $INST_architecture$
24
25Set $INST_SystemType$ = GetSystemType
26set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
27
28
29Set $LogDir$ = "%SystemDrive%\tmp"
30
31; ----------------------------------------------------------------
32; - Please edit the following values                             -
33; ----------------------------------------------------------------
34;$ProductId$ should be the name of the product in opsi
35; therefore please: only lower letters, no umlauts,
36; no white space use '-' as a seperator
37Set $ProductId$       = "opsi-template"
38Set $MinimumSpace$    = "1 MB"
39; the path were we find the product after the installation
40Set $InstallDir32$      = "%ProgramFiles32Dir%\<path to the product>"
41Set $InstallDir64$      = "%ProgramFiles64Dir%\<path to the product>"
42Set $LicenseRequired$ = "false"
43Set $LicensePool$     = "p_" + $ProductId$
44; ----------------------------------------------------------------
45
46if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
47        LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
48        isFatalError
49        ; Stop process and set installation status to failed
50else
51        comment "Show product picture"
52        ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
53       
54        if FileExists("%ScriptPath%\delsub.ins")
55                comment "Start uninstall sub section"
56                Sub "%ScriptPath%\delsub.ins"
57        endif
58       
59        if $LicenseRequired$ = "true"
60                comment "Licensing required, reserve license and get license key"
61                Sub_get_licensekey
62        endif
63       
64        comment "installing"
65
66        if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
67                Message "Installing " + $ProductId$ + " 32 Bit..."
68                comment "Start setup program"
69                Winbatch_install_32
70                Sub_check_exitcode
71                comment "Copy files"
72                Files_install_32 /32Bit
73                comment "Patch Registry"
74                Registry_install /32Bit
75                comment "Create shortcuts"
76                LinkFolder_install
77        endif
78
79        if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
80                Message "Installing " + $ProductId$ + " 64 Bit..."
81                comment "Start setup program"
82                Winbatch_install_64
83                Sub_check_exitcode
84                comment "Copy files"
85                Files_install_64 /64Bit
86                comment "Patch Registry"
87                Registry_install /64Bit
88                comment "Create shortcuts"
89                LinkFolder_install
90        endif
91       
92endif
93
94[Winbatch_install_32]
95; Choose one of the following examples as basis for your installation
96; You can use $LicenseKey$ var to pass a license key to the installer
97;
98; === Nullsoft Scriptable Install System ================================================================
99; "%ScriptPath%\Setup.exe" /S
100;
101; === MSI package =======================================================================================
102; You may use the parameter PIDKEY=$Licensekey$
103; msiexec /i "%ScriptPath%\some.msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress
104;
105; === InstallShield + MSI=====================================================================================
106; Attention: The path to the log file should not contain any whitespaces
107; "%ScriptPath%\setup.exe" /s /v" /l* $LogDir$\$ProductId$.install_log.txt /qb! ALLUSERS=2 REBOOT=ReallySuppress"
108; "%ScriptPath%\setup.exe" /s /v" /qb! ALLUSERS=2 REBOOT=ReallySuppress"
109;
110; === InstallShield =====================================================================================
111; Create setup.iss answer file by running: setup.exe /r /f1"c:\setup.iss"
112; "%ScriptPath%\setup.exe" /s /sms /f1"%ScriptPath%\setup.iss" /f2"$LogDir$\$ProductId$.install_log.txt"
113;
114; === Inno Setup ========================================================================================
115; http://unattended.sourceforge.net/InnoSetup_Switches_ExitCodes.html
116; You may create setup answer file by: setup.exe /SAVEINF="filename"
117; You may use an answer file by the parameter /LOADINF="filename"
118; "%ScriptPath%\setup.exe" /sp- /silent /norestart
119
120[Files_install_32]
121; Example of recursively copying some files into the installation directory:
122;
123; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
124
125[Winbatch_install_64]
126; Choose one of the following examples as basis for your installation
127; You can use $LicenseKey$ var to pass a license key to the installer
128;
129; === Nullsoft Scriptable Install System ================================================================
130; "%ScriptPath%\Setup.exe" /S
131;
132; === MSI package =======================================================================================
133; You may use the parameter PIDKEY=$Licensekey$
134; msiexec /i "%ScriptPath%\some.msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress
135;
136; === InstallShield + MSI=====================================================================================
137; Attention: The path to the log file should not contain any whitespaces
138; "%ScriptPath%\setup.exe" /s /v" /l* $LogDir$\$ProductId$.install_log.txt /qb! ALLUSERS=2 REBOOT=ReallySuppress"
139; "%ScriptPath%\setup.exe" /s /v" /qb! ALLUSERS=2 REBOOT=ReallySuppress"
140;
141; === InstallShield =====================================================================================
142; Create setup.iss answer file by running: setup.exe /r /f1"c:\setup.iss"
143; "%ScriptPath%\setup.exe" /s /sms /f1"%ScriptPath%\setup.iss" /f2"$LogDir$\$ProductId$.install_log.txt"
144;
145; === Inno Setup ========================================================================================
146; http://unattended.sourceforge.net/InnoSetup_Switches_ExitCodes.html
147; You may create setup answer file by: setup.exe /SAVEINF="filename"
148; You may use an answer file by the parameter /LOADINF="filename"
149; "%ScriptPath%\setup.exe" /sp- /silent /norestart
150
151[Files_install_64]
152; Example of recursively copying some files into the installation directory:
153;
154; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
155
156[Registry_install]
157; Example of setting some values of an registry key:
158;
159; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
160; set "name1" = "some string value"
161; set "name2" = REG_DWORD:0001
162; set "name3" = REG_BINARY:00 af 99 cd
163
164[LinkFolder_install]
165; Example of deleting a folder from AllUsers startmenu:
166;
167; set_basefolder common_programs
168; delete_subfolder $ProductId$
169;
170; Example of creating an shortcut to the installed exe in AllUsers startmenu:
171;
172; set_basefolder common_programs
173; set_subfolder $ProductId$
174;
175; set_link
176;       name: $ProductId$
177;       target: <path to the program>
178;       parameters:
179;       working_dir: $InstallDir$
180;       icon_file:
181;       icon_index:
182; end_link
183;
184; Example of creating an shortcut to the installed exe on AllUsers desktop:
185;
186; set_basefolder common_desktopdirectory
187; set_subfolder ""
188;
189; set_link
190;       name: $ProductId$
191;       target: <path to the program>
192;       parameters: <some_param>
193;       working_dir: $InstallDir$
194;       icon_file: <path to icon file>
195;       icon_index: 2
196; end_link
197
198[Sub_get_licensekey]
199if opsiLicenseManagementEnabled
200        comment "License management is enabled and will be used"
201
202        comment "Trying to get a license key"
203        Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
204        ; If there is an assignment of exactly one licensepool to the product the following call is possible:
205        ; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
206        ;
207        ; If there is an assignment of a license pool to a windows software id, it is possible to use:
208        ; DefVar $WindowsSoftwareId$
209        ; $WindowsSoftwareId$ = "..."
210        ; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
211       
212        DefVar $ServiceErrorClass$
213        set $ServiceErrorClass$ = getLastServiceErrorClass
214        comment "Error class: " + $ServiceErrorClass$
215       
216        if $ServiceErrorClass$ = "None"
217                comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
218        else
219                if $ServiceErrorClass$ = "LicenseConfigurationError"
220                        LogError "Fatal: license configuration must be corrected"
221                        LogError getLastServiceErrorMessage
222                        isFatalError
223                else
224                        if $ServiceErrorClass$ = "LicenseMissingError"
225                                LogError "Fatal: required license is not supplied"
226                                isFatalError
227                        endif
228                endif
229        endif
230else
231        LogError "Fatal: license required, but license management not enabled"
232        isFatalError
233endif
234
235
236[Sub_check_exitcode]
237comment "Test for installation success via exit code"
238set $ExitCode$ = getLastExitCode
239; informations to exit codes see
240; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
241; http://msdn.microsoft.com/en-us/library/aa368542.aspx
242if ($ExitCode$ = "0")
243        comment "Looks good: setup program gives exitcode zero"
244else
245        comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
246        if ($ExitCode$ = "1605")
247                comment "ERROR_UNKNOWN_PRODUCT  1605    This action is only valid for products that are currently installed."
248                comment "Uninstall of a not installed product failed - no problem"
249        else
250                if ($ExitCode$ = "1641")
251                        comment "looks good: setup program gives exitcode 1641"
252                        comment "ERROR_SUCCESS_REBOOT_INITIATED 1641    The installer has initiated a restart. This message is indicative of a success."
253                else
254                        if ($ExitCode$ = "3010")
255                                comment "looks good: setup program gives exitcode 3010"
256                                comment "ERROR_SUCCESS_REBOOT_REQUIRED  3010    A restart is required to complete the install. This message is indicative of a success."
257                        else
258                                logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
259                                isFatalError
260                        endif
261                endif
262        endif
263endif
264
Note: See TracBrowser for help on using the repository browser.