-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
executable file
·177 lines (152 loc) · 5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
#<HTML><HEAD><style>body {background-color: cyan;}</style></HEAD><BODY><!--
#--> <p><img width="500" src="https://submariner.io/images/logo-submariner.svg" /> </p> <!--
#--> <H1> Hi! I'm the get.submariner.io script</H1> <!--
#--> <p>I'm served from GitHub Pages and my source code lives here: <!--
#--> <a href="https://github.com/submariner-io/get.submariner.io">get.submariner.io @ github.com</a></p> <!--
#--> <p>You can find some useful links here: <!--
#--> <ul><li> <a href="https://submariner.io/">The Submariner website</a> </li> <!--
#--> <li> <a href="https://submariner.io/getting-started/quickstart/">Quickstart guides for installing Submariner</a> </li><!--
#--> <li> <a href="https://submariner.io/community/getting-help/">References to Submariner's Slack channel and other means to get community support</a> </li><!--
#--> </ul></p> <!--
#--> <h2>Source code:</h2> <pre>
set -e -o pipefail
get_operating_system() {
case $(uname -s) in
Darwin*) echo "darwin" ;;
Linux*) echo "linux" ;;
CYGWIN*) echo "windows" ;;
MINGW*) echo "windows" ;;
*)
error "This installer only works on Linux, macos and Windows. Found $(uname -s)"
return 1;;
esac
}
get_architecture() {
case $(uname -m) in
x86_64) echo "amd64" ;;
amd64) echo "amd64" ;;
arm64) echo "arm64" ;;
aarch64) echo "arm64" ;;
i?86) echo "386" ;;
*)
error "This installer only supports x86_64, i386, amd64, arm64, and aarch64 architectures. Found $(uname -m)"
return 1;;
esac
}
command_exists() {
command -v "$@" > /dev/null 2>&1
}
download_command() {
if command_exists curl; then
echo "curl -fsSL"
elif command_exists wget; then
echo "wget -qO-"
else
error "curl and wget are missing"
return 1
fi
}
get=$(download_command)
sanitized_version() {
case $1 in
rc|latest|devel|release*|feature*|v*) echo $1;;
*) echo "v$1" ;;
esac
}
get_subctl_release_url() {
local draft_filter="cat"
local url
case ${VERSION} in
rc) url=https://api.github.com/repos/submariner-io/releases/releases
draft_filter="grep \-rc.*xz"
;;
latest) url=https://api.github.com/repos/submariner-io/releases/releases/latest ;;
feature-multi-active-gw|release-0.?|release-0.1[012])
echo "https://github.com/submariner-io/submariner-operator/releases/download/subctl-${VERSION}/subctl-${VERSION}-${os}-${architecture}.tar.xz"
return
;;
devel|release*|feature*)
echo "https://github.com/submariner-io/subctl/releases/download/subctl-${VERSION}/subctl-${VERSION}-${os}-${architecture}.tar.xz"
return
;;
v0.[1234567].*)
echo "https://github.com/submariner-io/submariner-operator/releases/download/${VERSION}/subctl-${VERSION}-${os}-${architecture}.tar.xz"
return
;;
*) echo "https://github.com/submariner-io/releases/releases/download/${VERSION}/subctl-${VERSION}-${os}-${architecture}.tar.xz"
return
;;
esac
${get} "${url}" | grep "browser_download_url.*-${os}-${architecture}" | ${draft_filter} | head -n 1 | cut -d\" -f 4
}
finish_cleanup() {
[ -z "${tmpdir}" ] || rm -rf "$tmpdir"
}
get_subctl() {
tmpdir=$(mktemp -d)
cd "${tmpdir}"
# Retry downloading several times, as the underlying $get command might not support the retries we need.
for i in {1..5}; do
echo "Download attempt #${i}..."
download_and_install && return 0
[ "$i" == 5 ] && exit 1
sleep "${backoff}"
backoff=$((backoff * 2))
done
}
download_and_install() {
case ${url} in
*tar.gz)
${get} "${url}" | tar xfz - || return 1
# shellcheck disable=SC2086
install_subctl subctl*/subctl*
;;
*tar.xz)
${get} "${url}" | tar xfJ - || return 1
# shellcheck disable=SC2086
install_subctl subctl*/subctl*
;;
*) # non tar.xz releases (older)
filename=$(basename "${url}")
${get} "${url}" > "${filename}"
install_subctl "${filename}"
;;
esac
}
install_subctl() {
local bin=$1
local bin_file
local destdir=${DESTDIR:-~/.local/bin}
local dest=${destdir}/subctl
mkdir -p "$destdir"
# Delete the target if it exists, to ensure we get a new inode
# This allows a running subctl to be replace (e.g. if subctl is really a download script)
rm -f "${dest}"
cp "${bin}" "${dest}"
chmod +x "${dest}"
bin_file=$(basename "${bin}")
echo "${bin_file} has been installed as ${dest}"
printf "This provides "
${dest} version
if [ "$(command -v subctl)" != "${dest}" ]; then
echo ""
echo "please update your path (and consider adding it to ~/.profile):
export PATH=\$PATH:${destdir}
"
fi
}
VERSION=$(sanitized_version "${VERSION:-latest}")
os=$(get_operating_system)
architecture=$(get_architecture)
url=$(get_subctl_release_url)
backoff=1
echo "Installing subctl version $VERSION"
echo " OS detected: ${os}"
echo " Architecture detected: ${architecture}"
echo " Download URL: ${url}"
echo ""
echo "Downloading..."
trap finish_cleanup EXIT
get_subctl
#</pre><BODY></HTML>