mixlib-install 3.15.0 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -14
- data/lib/mixlib/install/backend/base.rb +15 -1
- data/lib/mixlib/install/backend/package_router.rb +60 -17
- data/lib/mixlib/install/dist.rb +24 -4
- data/lib/mixlib/install/generator/base.rb +1 -14
- data/lib/mixlib/install/generator/bourne/scripts/check_product.sh +1 -1
- data/lib/mixlib/install/generator/bourne/scripts/fetch_metadata.sh.erb +89 -19
- data/lib/mixlib/install/generator/bourne/scripts/fetch_package.sh +47 -23
- data/lib/mixlib/install/generator/bourne/scripts/helpers.sh.erb +30 -32
- data/lib/mixlib/install/generator/bourne/scripts/install_package.sh +2 -2
- data/lib/mixlib/install/generator/bourne/scripts/platform_detection.sh +22 -22
- data/lib/mixlib/install/generator/bourne/scripts/proxy_env.sh +4 -4
- data/lib/mixlib/install/generator/bourne/scripts/script_cli_parameters.sh.erb +5 -3
- data/lib/mixlib/install/generator/bourne.rb +5 -20
- data/lib/mixlib/install/generator/powershell/scripts/get_project_metadata.ps1.erb +52 -36
- data/lib/mixlib/install/generator/powershell/scripts/helpers.ps1.erb +8 -4
- data/lib/mixlib/install/generator/powershell/scripts/install_project.ps1.erb +33 -16
- data/lib/mixlib/install/generator/powershell/scripts/platform_detection.ps1 +1 -0
- data/lib/mixlib/install/generator/powershell.rb +5 -9
- data/lib/mixlib/install/generator.rb +5 -4
- data/lib/mixlib/install/options.rb +40 -0
- data/lib/mixlib/install/product_matrix.rb +1 -1
- data/lib/mixlib/install/script_generator.rb +80 -23
- data/lib/mixlib/install/util.rb +47 -0
- data/lib/mixlib/install/version.rb +1 -1
- data/lib/mixlib/install.rb +82 -11
- data/support/install_command.ps1 +3 -0
- metadata +2 -2
|
@@ -62,10 +62,10 @@ unable_to_retrieve_package() {
|
|
|
62
62
|
echo "Unable to retrieve a valid package!"
|
|
63
63
|
report_bug
|
|
64
64
|
echo "Metadata URL: $metadata_url"
|
|
65
|
-
if
|
|
65
|
+
if [ -n "$download_url" ]; then
|
|
66
66
|
echo "Download URL: $download_url"
|
|
67
67
|
fi
|
|
68
|
-
if
|
|
68
|
+
if [ -n "$stderr_results" ]; then
|
|
69
69
|
echo "\nDEBUG OUTPUT FOLLOWS:\n$stderr_results"
|
|
70
70
|
fi
|
|
71
71
|
exit 1
|
|
@@ -94,10 +94,10 @@ http_404_error() {
|
|
|
94
94
|
echo ""
|
|
95
95
|
# deliberately do not call report_bug to suppress bug report noise.
|
|
96
96
|
echo "Metadata URL: $metadata_url"
|
|
97
|
-
if
|
|
97
|
+
if [ -n "$download_url" ]; then
|
|
98
98
|
echo "Download URL: $download_url"
|
|
99
99
|
fi
|
|
100
|
-
if
|
|
100
|
+
if [ -n "$stderr_results" ]; then
|
|
101
101
|
echo "\nDEBUG OUTPUT FOLLOWS:\n$stderr_results"
|
|
102
102
|
fi
|
|
103
103
|
exit 1
|
|
@@ -105,7 +105,7 @@ http_404_error() {
|
|
|
105
105
|
|
|
106
106
|
capture_tmp_stderr() {
|
|
107
107
|
# spool up /tmp/stderr from all the commands we called
|
|
108
|
-
if
|
|
108
|
+
if [ -f "$tmp_dir/stderr" ]; then
|
|
109
109
|
output=`cat $tmp_dir/stderr`
|
|
110
110
|
stderr_results="${stderr_results}\nSTDERR from $1:\n\n$output\n"
|
|
111
111
|
rm $tmp_dir/stderr
|
|
@@ -116,27 +116,26 @@ capture_tmp_stderr() {
|
|
|
116
116
|
do_wget() {
|
|
117
117
|
echo "trying wget..."
|
|
118
118
|
# If filename is empty, use --content-disposition to get filename from server
|
|
119
|
-
if
|
|
119
|
+
if [ -z "$2" ]; then
|
|
120
120
|
wget --user-agent="User-Agent: <%= user_agent_string %>" --content-disposition "$1" 2>$tmp_dir/stderr
|
|
121
121
|
else
|
|
122
122
|
wget --user-agent="User-Agent: <%= user_agent_string %>" -O "$2" "$1" 2>$tmp_dir/stderr
|
|
123
123
|
fi
|
|
124
124
|
rc=$?
|
|
125
125
|
# check for 404
|
|
126
|
-
grep "ERROR 404" $tmp_dir/stderr 2>&1 >/dev/null
|
|
127
|
-
if test $? -eq 0; then
|
|
126
|
+
if grep "ERROR 404" $tmp_dir/stderr 2>&1 >/dev/null; then
|
|
128
127
|
echo "ERROR 404"
|
|
129
128
|
http_404_error
|
|
130
129
|
fi
|
|
131
130
|
|
|
132
131
|
# check for bad return status (skip empty output check if using content-disposition)
|
|
133
|
-
if
|
|
132
|
+
if [ $rc -ne 0 ]; then
|
|
134
133
|
capture_tmp_stderr "wget"
|
|
135
134
|
return 1
|
|
136
135
|
fi
|
|
137
|
-
|
|
136
|
+
|
|
138
137
|
# Only check for empty output if we specified a filename
|
|
139
|
-
if
|
|
138
|
+
if [ -n "$2" ] && [ ! -s "$2" ]; then
|
|
140
139
|
capture_tmp_stderr "wget"
|
|
141
140
|
return 1
|
|
142
141
|
fi
|
|
@@ -148,29 +147,28 @@ do_wget() {
|
|
|
148
147
|
do_curl() {
|
|
149
148
|
echo "trying curl..."
|
|
150
149
|
# If filename is empty, use -O and -J to get filename from Content-Disposition header
|
|
151
|
-
if
|
|
150
|
+
if [ -z "$2" ]; then
|
|
152
151
|
curl -A "User-Agent: <%= user_agent_string %>" --retry 5 -sL -D $tmp_dir/stderr -O -J "$1"
|
|
153
152
|
rc=$?
|
|
154
153
|
else
|
|
155
154
|
curl -A "User-Agent: <%= user_agent_string %>" --retry 5 -sL -D $tmp_dir/stderr "$1" > "$2"
|
|
156
155
|
rc=$?
|
|
157
156
|
fi
|
|
158
|
-
|
|
157
|
+
|
|
159
158
|
# check for 404
|
|
160
|
-
grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null
|
|
161
|
-
if test $? -eq 0; then
|
|
159
|
+
if grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null; then
|
|
162
160
|
echo "ERROR 404"
|
|
163
161
|
http_404_error
|
|
164
162
|
fi
|
|
165
163
|
|
|
166
164
|
# check for bad return status
|
|
167
|
-
if
|
|
165
|
+
if [ $rc -ne 0 ]; then
|
|
168
166
|
capture_tmp_stderr "curl"
|
|
169
167
|
return 1
|
|
170
168
|
fi
|
|
171
|
-
|
|
169
|
+
|
|
172
170
|
# Only check for empty output if we specified a filename
|
|
173
|
-
if
|
|
171
|
+
if [ -n "$2" ] && [ ! -s "$2" ]; then
|
|
174
172
|
capture_tmp_stderr "curl"
|
|
175
173
|
return 1
|
|
176
174
|
fi
|
|
@@ -183,7 +181,7 @@ do_fetch() {
|
|
|
183
181
|
echo "trying fetch..."
|
|
184
182
|
fetch --user-agent="User-Agent: <%= user_agent_string %>" -o "$2" "$1" 2>$tmp_dir/stderr
|
|
185
183
|
# check for bad return status
|
|
186
|
-
|
|
184
|
+
[ $? -ne 0 ] && return 1
|
|
187
185
|
return 0
|
|
188
186
|
}
|
|
189
187
|
|
|
@@ -193,14 +191,13 @@ do_perl() {
|
|
|
193
191
|
perl -e 'use LWP::Simple; getprint($ARGV[0]);' "$1" > "$2" 2>$tmp_dir/stderr
|
|
194
192
|
rc=$?
|
|
195
193
|
# check for 404
|
|
196
|
-
grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null
|
|
197
|
-
if test $? -eq 0; then
|
|
194
|
+
if grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null; then
|
|
198
195
|
echo "ERROR 404"
|
|
199
196
|
http_404_error
|
|
200
197
|
fi
|
|
201
198
|
|
|
202
199
|
# check for bad return status or empty output
|
|
203
|
-
if
|
|
200
|
+
if [ $rc -ne 0 ] || [ ! -s "$2" ]; then
|
|
204
201
|
capture_tmp_stderr "perl"
|
|
205
202
|
return 1
|
|
206
203
|
fi
|
|
@@ -214,14 +211,13 @@ do_python() {
|
|
|
214
211
|
python -c "import sys,urllib2; sys.stdout.write(urllib2.urlopen(urllib2.Request(sys.argv[1], headers={ 'User-Agent': '<%= user_agent_string %>' })).read())" "$1" > "$2" 2>$tmp_dir/stderr
|
|
215
212
|
rc=$?
|
|
216
213
|
# check for 404
|
|
217
|
-
grep "HTTP Error 404" $tmp_dir/stderr 2>&1 >/dev/null
|
|
218
|
-
if test $? -eq 0; then
|
|
214
|
+
if grep "HTTP Error 404" $tmp_dir/stderr 2>&1 >/dev/null; then
|
|
219
215
|
echo "ERROR 404"
|
|
220
216
|
http_404_error
|
|
221
217
|
fi
|
|
222
218
|
|
|
223
219
|
# check for bad return status or empty output
|
|
224
|
-
if
|
|
220
|
+
if [ $rc -ne 0 ] || [ ! -s "$2" ]; then
|
|
225
221
|
capture_tmp_stderr "python"
|
|
226
222
|
return 1
|
|
227
223
|
fi
|
|
@@ -233,11 +229,13 @@ do_checksum() {
|
|
|
233
229
|
if exists sha256sum; then
|
|
234
230
|
echo "Comparing checksum with sha256sum..."
|
|
235
231
|
checksum=`sha256sum $1 | awk '{ print $1 }'`
|
|
236
|
-
|
|
232
|
+
[ "$checksum" = "$2" ]
|
|
233
|
+
return $?
|
|
237
234
|
elif exists shasum; then
|
|
238
235
|
echo "Comparing checksum with shasum..."
|
|
239
236
|
checksum=`shasum -a 256 $1 | awk '{ print $1 }'`
|
|
240
|
-
|
|
237
|
+
[ "$checksum" = "$2" ]
|
|
238
|
+
return $?
|
|
241
239
|
else
|
|
242
240
|
echo "WARNING: could not find a valid checksum program, pre-install shasum or sha256sum in your O/S image to get validation..."
|
|
243
241
|
return 0
|
|
@@ -250,8 +248,8 @@ do_download() {
|
|
|
250
248
|
echo " to file $2"
|
|
251
249
|
|
|
252
250
|
url=`echo $1`
|
|
253
|
-
if
|
|
254
|
-
if
|
|
251
|
+
if [ "$platform" = "solaris2" ]; then
|
|
252
|
+
if [ "$platform_version" = "5.9" ] || [ "$platform_version" = "5.10" ]; then
|
|
255
253
|
# solaris 9 lacks openssl, solaris 10 lacks recent enough credentials - your base O/S is completely insecure, please upgrade
|
|
256
254
|
url=`echo $url | sed -e 's/https/http/'`
|
|
257
255
|
fi
|
|
@@ -289,7 +287,7 @@ install_file() {
|
|
|
289
287
|
echo "Installing $project $version"
|
|
290
288
|
case "$1" in
|
|
291
289
|
"rpm")
|
|
292
|
-
if
|
|
290
|
+
if [ "$platform" = "nexus" ] || [ "$platform" = "ios_xr" ]; then
|
|
293
291
|
echo "installing with yum..."
|
|
294
292
|
yum install -yv "$2"
|
|
295
293
|
else
|
|
@@ -338,14 +336,14 @@ install_file() {
|
|
|
338
336
|
exit 1
|
|
339
337
|
;;
|
|
340
338
|
esac
|
|
341
|
-
if
|
|
339
|
+
if [ $? -ne 0 ]; then
|
|
342
340
|
echo "Installation failed"
|
|
343
341
|
report_bug
|
|
344
342
|
exit 1
|
|
345
343
|
fi
|
|
346
344
|
}
|
|
347
345
|
|
|
348
|
-
if
|
|
346
|
+
if [ -z "$TMPDIR" ]; then
|
|
349
347
|
tmp="/tmp"
|
|
350
348
|
else
|
|
351
349
|
tmp=$TMPDIR
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# $version: The version requested. Used only for warning user if not set.
|
|
9
9
|
############
|
|
10
10
|
|
|
11
|
-
if
|
|
11
|
+
if [ -z "$version" ] && [ "$CI" != "true" ]; then
|
|
12
12
|
echo
|
|
13
13
|
echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING"
|
|
14
14
|
echo
|
|
@@ -24,7 +24,7 @@ fi
|
|
|
24
24
|
|
|
25
25
|
install_file $filetype "$download_filename"
|
|
26
26
|
|
|
27
|
-
if
|
|
27
|
+
if [ -n "$tmp_dir" ]; then
|
|
28
28
|
rm -r "$tmp_dir"
|
|
29
29
|
fi
|
|
30
30
|
|
|
@@ -25,35 +25,35 @@
|
|
|
25
25
|
machine=`uname -m`
|
|
26
26
|
os=`uname -s`
|
|
27
27
|
|
|
28
|
-
if
|
|
28
|
+
if [ -f "/etc/lsb-release" ] && grep DISTRIB_ID /etc/lsb-release >/dev/null && ! grep wrlinux /etc/lsb-release >/dev/null; then
|
|
29
29
|
platform=`grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr '[A-Z]' '[a-z]'`
|
|
30
30
|
platform_version=`grep DISTRIB_RELEASE /etc/lsb-release | cut -d "=" -f 2`
|
|
31
31
|
|
|
32
|
-
if
|
|
32
|
+
if [ "$platform" = '"cumulus linux"' ]; then
|
|
33
33
|
platform="cumulus_linux"
|
|
34
|
-
elif
|
|
34
|
+
elif [ "$platform" = '"cumulus networks"' ]; then
|
|
35
35
|
platform="cumulus_networks"
|
|
36
36
|
fi
|
|
37
37
|
|
|
38
|
-
elif
|
|
38
|
+
elif [ -f "/etc/debian_version" ]; then
|
|
39
39
|
platform="debian"
|
|
40
40
|
platform_version=`cat /etc/debian_version`
|
|
41
|
-
elif
|
|
41
|
+
elif [ -f "/etc/Eos-release" ]; then
|
|
42
42
|
# EOS may also contain /etc/redhat-release so this check must come first.
|
|
43
43
|
platform=arista_eos
|
|
44
44
|
platform_version=`awk '{print $4}' /etc/Eos-release`
|
|
45
45
|
machine="i386"
|
|
46
|
-
elif
|
|
46
|
+
elif [ -f "/etc/redhat-release" ]; then
|
|
47
47
|
platform=`sed 's/^\(.\+\) release.*/\1/' /etc/redhat-release | tr '[A-Z]' '[a-z]'`
|
|
48
48
|
platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release`
|
|
49
|
-
|
|
50
|
-
if
|
|
49
|
+
|
|
50
|
+
if [ "$platform" = "rocky linux" ]; then
|
|
51
51
|
source /etc/os-release
|
|
52
52
|
os="${REDHAT_SUPPORT_PRODUCT}"
|
|
53
53
|
platform_version="${ROCKY_SUPPORT_PRODUCT_VERSION}"
|
|
54
54
|
platform=$ID
|
|
55
55
|
|
|
56
|
-
elif
|
|
56
|
+
elif [ "$platform" = "xenserver" ]; then
|
|
57
57
|
# Current XenServer 6.2 is based on CentOS 5, platform is not reset to "el" server should handle response
|
|
58
58
|
platform="xenserver"
|
|
59
59
|
else
|
|
@@ -61,7 +61,7 @@ elif test -f "/etc/redhat-release"; then
|
|
|
61
61
|
platform="el"
|
|
62
62
|
fi
|
|
63
63
|
|
|
64
|
-
elif
|
|
64
|
+
elif [ -f "/etc/system-release" ]; then
|
|
65
65
|
platform=`sed 's/^\(.\+\) release.\+/\1/' /etc/system-release | tr '[A-Z]' '[a-z]'`
|
|
66
66
|
platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/system-release | tr '[A-Z]' '[a-z]'`
|
|
67
67
|
case $platform in amazon*) # sh compat method of checking for a substring
|
|
@@ -88,11 +88,11 @@ elif test -f "/etc/system-release"; then
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
# Apple macOS
|
|
91
|
-
elif
|
|
91
|
+
elif [ -f "/usr/bin/sw_vers" ]; then
|
|
92
92
|
platform="mac_os_x"
|
|
93
93
|
# Matching the tab-space with sed is error-prone
|
|
94
94
|
platform_version=`sw_vers | awk '/^ProductVersion:/ { print $2 }' | cut -d. -f1,2`
|
|
95
|
-
elif
|
|
95
|
+
elif [ -f "/etc/release" ]; then
|
|
96
96
|
machine=`/usr/bin/uname -p`
|
|
97
97
|
if grep SmartOS /etc/release >/dev/null; then
|
|
98
98
|
platform="smartos"
|
|
@@ -101,7 +101,7 @@ elif test -f "/etc/release"; then
|
|
|
101
101
|
platform="solaris2"
|
|
102
102
|
platform_version=`/usr/bin/uname -r`
|
|
103
103
|
fi
|
|
104
|
-
elif
|
|
104
|
+
elif [ -f "/etc/SuSE-release" ]; then
|
|
105
105
|
if grep 'Enterprise' /etc/SuSE-release >/dev/null;
|
|
106
106
|
then
|
|
107
107
|
platform="sles"
|
|
@@ -110,16 +110,16 @@ elif test -f "/etc/SuSE-release"; then
|
|
|
110
110
|
platform="opensuseleap"
|
|
111
111
|
platform_version=`awk '/^VERSION =/ { print $3 }' /etc/SuSE-release`
|
|
112
112
|
fi
|
|
113
|
-
elif
|
|
113
|
+
elif [ "$os" = "FreeBSD" ]; then
|
|
114
114
|
platform="freebsd"
|
|
115
115
|
platform_version=`uname -r | sed 's/-.*//'`
|
|
116
|
-
elif
|
|
116
|
+
elif [ "$os" = "AIX" ]; then
|
|
117
117
|
platform="aix"
|
|
118
118
|
platform_version="`uname -v`.`uname -r`"
|
|
119
119
|
machine="powerpc"
|
|
120
|
-
elif
|
|
120
|
+
elif [ -f "/etc/os-release" ]; then
|
|
121
121
|
. /etc/os-release
|
|
122
|
-
if
|
|
122
|
+
if [ -n "$CISCO_RELEASE_INFO" ]; then
|
|
123
123
|
. $CISCO_RELEASE_INFO
|
|
124
124
|
fi
|
|
125
125
|
|
|
@@ -127,14 +127,14 @@ elif test -f "/etc/os-release"; then
|
|
|
127
127
|
|
|
128
128
|
# VERSION_ID is always the preferred variable to use, but not
|
|
129
129
|
# every distro has it so fallback to VERSION
|
|
130
|
-
if
|
|
130
|
+
if [ -n "$VERSION_ID" ]; then
|
|
131
131
|
platform_version=$VERSION_ID
|
|
132
132
|
else
|
|
133
133
|
platform_version=$VERSION
|
|
134
134
|
fi
|
|
135
135
|
fi
|
|
136
136
|
|
|
137
|
-
if
|
|
137
|
+
if [ -z "$platform" ]; then
|
|
138
138
|
echo "Unable to determine platform version!"
|
|
139
139
|
report_bug
|
|
140
140
|
exit 1
|
|
@@ -158,7 +158,7 @@ case $platform in
|
|
|
158
158
|
platform_version=$major_version
|
|
159
159
|
;;
|
|
160
160
|
"debian")
|
|
161
|
-
if
|
|
161
|
+
if [ "$major_version" = "5" ]; then
|
|
162
162
|
# This is here for potential back-compat.
|
|
163
163
|
# We do not have 5 in versions we publish for anymore but we
|
|
164
164
|
# might have it for earlier versions.
|
|
@@ -194,13 +194,13 @@ case $machine in
|
|
|
194
194
|
;;
|
|
195
195
|
esac
|
|
196
196
|
|
|
197
|
-
if
|
|
197
|
+
if [ -z "$platform_version" ]; then
|
|
198
198
|
echo "Unable to determine platform version!"
|
|
199
199
|
report_bug
|
|
200
200
|
exit 1
|
|
201
201
|
fi
|
|
202
202
|
|
|
203
|
-
if
|
|
203
|
+
if [ "$platform" = "solaris2" ]; then
|
|
204
204
|
# hack up the path on Solaris to find wget, pkgadd
|
|
205
205
|
PATH=/usr/sfw/bin:/usr/sbin:$PATH
|
|
206
206
|
export PATH
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Otherwise, default proxy env vars will be loaded by the respective
|
|
4
4
|
# download utility.
|
|
5
5
|
|
|
6
|
-
if
|
|
6
|
+
if [ -n "$https_proxy" ]; then
|
|
7
7
|
echo "setting https_proxy: $https_proxy"
|
|
8
8
|
HTTPS_PROXY=$https_proxy
|
|
9
9
|
https_proxy=$https_proxy
|
|
@@ -11,7 +11,7 @@ if test "x$https_proxy" != "x"; then
|
|
|
11
11
|
export https_proxy
|
|
12
12
|
fi
|
|
13
13
|
|
|
14
|
-
if
|
|
14
|
+
if [ -n "$http_proxy" ]; then
|
|
15
15
|
echo "setting http_proxy: $http_proxy"
|
|
16
16
|
HTTP_PROXY=$http_proxy
|
|
17
17
|
http_proxy=$http_proxy
|
|
@@ -19,7 +19,7 @@ if test "x$http_proxy" != "x"; then
|
|
|
19
19
|
export http_proxy
|
|
20
20
|
fi
|
|
21
21
|
|
|
22
|
-
if
|
|
22
|
+
if [ -n "$ftp_proxy" ]; then
|
|
23
23
|
echo "setting ftp_proxy: $ftp_proxy"
|
|
24
24
|
FTP_PROXY=$ftp_proxy
|
|
25
25
|
ftp_proxy=$ftp_proxy
|
|
@@ -27,7 +27,7 @@ if test "x$ftp_proxy" != "x"; then
|
|
|
27
27
|
export ftp_proxy
|
|
28
28
|
fi
|
|
29
29
|
|
|
30
|
-
if
|
|
30
|
+
if [ -n "$no_proxy" ]; then
|
|
31
31
|
echo "setting no_proxy: $no_proxy"
|
|
32
32
|
NO_PROXY=$no_proxy
|
|
33
33
|
no_proxy=$no_proxy
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
# Defaults
|
|
19
19
|
channel="stable"
|
|
20
20
|
project="<%= default_product %>"
|
|
21
|
+
<%= "license_id=\"#{license_id}\"" if license_id && !license_id.to_s.empty? %>
|
|
21
22
|
|
|
22
|
-
while getopts pnv:c:f:P:d:s:l:a:L: opt
|
|
23
|
+
while getopts pnv:b:c:f:P:d:s:l:a:L: opt
|
|
23
24
|
do
|
|
24
25
|
case "$opt" in
|
|
25
26
|
|
|
26
27
|
v) version="$OPTARG";;
|
|
28
|
+
b) base_api_url="$OPTARG";;
|
|
27
29
|
c) channel="$OPTARG";;
|
|
28
30
|
p) channel="current";; # compat for prerelease option
|
|
29
31
|
n) channel="current";; # compat for nightlies option
|
|
@@ -36,7 +38,7 @@ do
|
|
|
36
38
|
L) license_id="$OPTARG";;
|
|
37
39
|
\?) # unknown flag
|
|
38
40
|
echo >&2 \
|
|
39
|
-
"usage: $0 [-P project] [-c release_channel] [-v version] [-f filename | -d download_dir] [-s install_strategy] [-l download_url_override] [-a checksum] [-L license_id]"
|
|
41
|
+
"usage: $0 [-P project] [-b base_api_url] [-c release_channel] [-v version] [-f filename | -d download_dir] [-s install_strategy] [-l download_url_override] [-a checksum] [-L license_id]"
|
|
40
42
|
exit 1;;
|
|
41
43
|
esac
|
|
42
44
|
done
|
|
@@ -44,6 +46,6 @@ done
|
|
|
44
46
|
shift `expr $OPTIND - 1`
|
|
45
47
|
|
|
46
48
|
# Use CHEF_LICENSE_KEY environment variable if license_id not provided via CLI
|
|
47
|
-
if [ -z "$license_id" ] && [ -n "$
|
|
49
|
+
if [ -z "$license_id" ] && [ -n "$CHEF_LICENSE_KEY" ]; then
|
|
48
50
|
license_id="$CHEF_LICENSE_KEY"
|
|
49
51
|
fi
|
|
@@ -24,19 +24,7 @@ module Mixlib
|
|
|
24
24
|
def self.install_sh(context)
|
|
25
25
|
install_command = []
|
|
26
26
|
install_command << get_script("helpers.sh", context)
|
|
27
|
-
|
|
28
|
-
if context[:license_id] && !context[:license_id].to_s.empty?
|
|
29
|
-
install_command << "# License ID provided via context"
|
|
30
|
-
install_command << "license_id='#{context[:license_id]}'"
|
|
31
|
-
end
|
|
32
|
-
install_command << get_script("script_cli_parameters.sh")
|
|
33
|
-
# Check for CHEF_LICENSE_KEY in execution environment if not already set
|
|
34
|
-
install_command << <<~BASH.chomp
|
|
35
|
-
# Use CHEF_LICENSE_KEY from execution environment if license_id not set
|
|
36
|
-
if [ -z "${license_id:-}" ] && [ -n "${CHEF_LICENSE_KEY:-}" ]; then
|
|
37
|
-
license_id="$CHEF_LICENSE_KEY"
|
|
38
|
-
fi
|
|
39
|
-
BASH
|
|
27
|
+
install_command << get_script("script_cli_parameters.sh", context)
|
|
40
28
|
install_command << get_script("check_product.sh")
|
|
41
29
|
install_command << get_script("platform_detection.sh")
|
|
42
30
|
install_command << get_script("proxy_env.sh")
|
|
@@ -61,7 +49,7 @@ module Mixlib
|
|
|
61
49
|
install_command << get_script("check_product.sh")
|
|
62
50
|
install_command << get_script("platform_detection.sh")
|
|
63
51
|
install_command << get_script("proxy_env.sh")
|
|
64
|
-
install_command << get_script("fetch_metadata.sh")
|
|
52
|
+
install_command << get_script("fetch_metadata.sh", license_id: options.license_id, base_url: options.base_url)
|
|
65
53
|
install_command << get_script("fetch_package.sh")
|
|
66
54
|
install_command << get_script("install_package.sh")
|
|
67
55
|
|
|
@@ -73,16 +61,13 @@ module Mixlib
|
|
|
73
61
|
project=#{options.product_name}
|
|
74
62
|
version=#{options.product_version}
|
|
75
63
|
channel=#{options.channel}
|
|
64
|
+
#{"license_id=#{options.license_id}" if options.license_id && !options.license_id.to_s.empty?}
|
|
65
|
+
#{"base_api_url=#{options.base_url}" if options.base_url && !options.base_url.to_s.empty?}
|
|
76
66
|
EOS
|
|
77
|
-
# Add license_id if provided, otherwise use CHEF_LICENSE_KEY env var
|
|
78
|
-
license_id_value = options.license_id || ENV["CHEF_LICENSE_KEY"]
|
|
79
|
-
if license_id_value && !license_id_value.to_s.empty?
|
|
80
|
-
vars += "license_id=#{license_id_value}\n"
|
|
81
|
-
end
|
|
82
67
|
# Check for CHEF_LICENSE_KEY in execution environment if not already set
|
|
83
68
|
vars += <<EOS
|
|
84
69
|
# Use CHEF_LICENSE_KEY from execution environment if license_id not set
|
|
85
|
-
if [ -z "$
|
|
70
|
+
if [ -z "$license_id" ] && [ -n "$CHEF_LICENSE_KEY" ]; then
|
|
86
71
|
license_id="$CHEF_LICENSE_KEY"
|
|
87
72
|
fi
|
|
88
73
|
EOS
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
################ get_project_metadata.ps1
|
|
1
2
|
function Get-ProjectMetadata {
|
|
2
3
|
<#
|
|
3
4
|
.SYNOPSIS
|
|
@@ -5,22 +6,21 @@ function Get-ProjectMetadata {
|
|
|
5
6
|
.DESCRIPTION
|
|
6
7
|
Get metadata for project
|
|
7
8
|
.EXAMPLE
|
|
8
|
-
iex (new-object net.webclient).downloadstring('<%= base_url %>/install.ps1'); Get-ProjectMetadata -project chef -channel stable
|
|
9
|
+
iex (new-object net.webclient).downloadstring('<%= base_url || "https://chefdownload-commercial.chef.io" %>/install.ps1<%= base_url && base_url.include?("chefdownload") ? "?license_id=$env:CHEF_LICENSE_KEY" : "" %>'); Get-ProjectMetadata -project chef -channel stable
|
|
9
10
|
|
|
10
11
|
Gets the download url and SHA256 checksum for the latest stable release of Chef.
|
|
11
12
|
.EXAMPLE
|
|
12
|
-
iex (irm '<%= base_url %>/install.ps1'); Get-ProjectMetadata -project
|
|
13
|
-
|
|
14
|
-
Gets the download url and SHA256 checksum for ChefDK 0.8.0.
|
|
13
|
+
iex (irm '<%= base_url || "https://chefdownload-commercial.chef.io" %>/install.ps1<%= base_url && base_url.include?("chefdownload") ? "?license_id=$env:CHEF_LICENSE_KEY" : "" %>'); Get-ProjectMetadata -project chef-workstation -channel stable
|
|
15
14
|
#>
|
|
16
15
|
[cmdletbinding()]
|
|
17
16
|
param (
|
|
18
17
|
# Base url to retrieve metadata from.
|
|
19
|
-
[uri]
|
|
18
|
+
[uri]
|
|
19
|
+
$base_server_uri,
|
|
20
20
|
[string]
|
|
21
21
|
# Project to install
|
|
22
22
|
[string]
|
|
23
|
-
$project = '
|
|
23
|
+
$project = '<%= default_product %>',
|
|
24
24
|
# Version of the application to install
|
|
25
25
|
# This parameter is optional, if not supplied it will provide the latest version,
|
|
26
26
|
# and if an iteration number is not specified, it will grab the latest available iteration.
|
|
@@ -42,7 +42,7 @@ function Get-ProjectMetadata {
|
|
|
42
42
|
$architecture = 'auto',
|
|
43
43
|
# License ID for commercial API access
|
|
44
44
|
[string]
|
|
45
|
-
$license_id
|
|
45
|
+
$license_id <%= "= '#{license_id}'" if license_id && !license_id.to_s.empty? %>
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
# The following legacy switches are just aliases for the current channel
|
|
@@ -51,47 +51,63 @@ function Get-ProjectMetadata {
|
|
|
51
51
|
|
|
52
52
|
# PowerShell is only on Windows ATM
|
|
53
53
|
$platform = 'windows'
|
|
54
|
-
Write-
|
|
54
|
+
Write-Host "Platform: $platform"
|
|
55
55
|
|
|
56
56
|
$platform_version = Get-PlatformVersion
|
|
57
|
-
Write-
|
|
57
|
+
Write-Host "Platform Version: $platform_version"
|
|
58
58
|
|
|
59
59
|
if ($architecture -eq 'auto') {
|
|
60
60
|
$architecture = Get-PlatformArchitecture
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
Write-
|
|
64
|
-
Write-
|
|
63
|
+
Write-Host "Architecture: $architecture"
|
|
64
|
+
Write-Host "Project: $project"
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
if
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
<% if base_url && !base_url.to_s.empty? %>
|
|
67
|
+
# Set base_server_uri from option if not already set via parameter
|
|
68
|
+
if ([string]::IsNullOrEmpty($base_server_uri)) {
|
|
69
|
+
$base_server_uri = "<%= base_url %>"
|
|
70
|
+
}
|
|
71
|
+
<% end %>
|
|
72
|
+
|
|
73
|
+
if ([string]::IsNullOrEmpty($base_server_uri)) {
|
|
74
|
+
if (-not [string]::IsNullOrEmpty($license_id)) {
|
|
75
|
+
# Check if license_id starts with 'free-' or 'trial-' for trial API
|
|
76
|
+
if ($license_id -match '^(free-|trial-)') {
|
|
77
|
+
# Trial API endpoint
|
|
78
|
+
$base_server_uri = "<%= Mixlib::Install::Dist::TRIAL_API_ENDPOINT %>"
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
# Commercial API endpoint
|
|
82
|
+
$base_server_uri = "<%= Mixlib::Install::Dist::COMMERCIAL_API_ENDPOINT %>"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
# Omnitruck endpoint
|
|
87
|
+
$base_server_uri = "<%= Mixlib::Install::Dist::OMNITRUCK_ENDPOINT %>"
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
# For chef-ice product, add platform (p), machine (m), and package_manager (pm) parameters
|
|
92
|
+
if (-not [string]::IsNullOrEmpty($license_id)) {
|
|
93
|
+
if ($project -eq "chef-ice") {
|
|
94
|
+
$package_manager = "msi"
|
|
95
|
+
$platform_param = "windows"
|
|
96
|
+
$metadata_url = "$base_server_uri$channel/$project/metadata?license_id=$license_id&v=$version&m=$architecture&p=$platform_param&pm=$package_manager"
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
# For other products, use standard parameters
|
|
100
|
+
$metadata_url = "$base_server_uri$channel/$project/metadata?license_id=$license_id&v=$version&p=$platform&pv=$platform_version&m=$architecture"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
# Omnitruck URL parameters without license_id
|
|
105
|
+
$metadata_url = "$base_server_uri$channel/$project/metadata?v=$version&p=$platform&pv=$platform_version&m=$architecture"
|
|
87
106
|
}
|
|
88
|
-
|
|
89
|
-
$metadata_base_url += [string]::join('&', $metadata_array)
|
|
90
|
-
$metadata_url = new-uri $base_server_uri $metadata_base_url
|
|
91
107
|
|
|
92
|
-
Write-
|
|
108
|
+
Write-Host "Downloading $project details from $metadata_url"
|
|
93
109
|
$response = (Get-WebContent $metadata_url).trim()
|
|
94
|
-
|
|
110
|
+
|
|
95
111
|
# Commercial and trial APIs return JSON, omnitruck returns text format
|
|
96
112
|
if ($license_id) {
|
|
97
113
|
# Parse JSON response from commercial/trial API
|
|
@@ -114,9 +130,9 @@ function Get-ProjectMetadata {
|
|
|
114
130
|
foreach { $hash = @{} } {$key, $value = $_ -split '\s+'; $hash.Add($key, $value)} {$hash}
|
|
115
131
|
}
|
|
116
132
|
|
|
117
|
-
Write-
|
|
133
|
+
Write-Host "Project details: "
|
|
118
134
|
foreach ($key in $package_metadata.keys) {
|
|
119
|
-
Write-
|
|
135
|
+
Write-Host "`t$key = $($package_metadata[$key])"
|
|
120
136
|
}
|
|
121
137
|
$package_metadata
|
|
122
138
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
################ helpers.ps1
|
|
2
|
+
# Set strict error handling to ensure errors cause script failures
|
|
3
|
+
$ErrorActionPreference = 'Stop'
|
|
4
|
+
|
|
5
|
+
try { [Console]::OutputEncoding = New-Object -typename System.Text.ASCIIEncoding } catch { }
|
|
2
6
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'
|
|
3
7
|
|
|
4
8
|
function Get-PlatformVersion {
|
|
@@ -168,11 +172,11 @@ function Test-ProjectPackage {
|
|
|
168
172
|
[cmdletbinding()]
|
|
169
173
|
param ($Path, $Algorithm = 'SHA256', $Hash)
|
|
170
174
|
if (!$env:Valid_ProjectPackage){
|
|
171
|
-
Write-
|
|
175
|
+
Write-Host "Testing the $Algorithm hash for $path."
|
|
172
176
|
$ActualHash = (Custom-GetFileHash -Algorithm $Algorithm -Path $Path).Hash.ToLower()
|
|
173
177
|
|
|
174
|
-
Write-
|
|
175
|
-
Write-
|
|
178
|
+
Write-Host "`tDesired Hash - '$Hash'"
|
|
179
|
+
Write-Host "`tActual Hash - '$ActualHash'"
|
|
176
180
|
$env:Valid_ProjectPackage = $ActualHash -eq $Hash
|
|
177
181
|
if (-not $env:Valid_ProjectPackage) {
|
|
178
182
|
Write-Error "Failed to validate the downloaded installer. The expected $Algorithm hash was '$Hash' and the actual hash was '$ActualHash' for $path"
|