forked from scylladb/scylladb-web-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server
executable file
·509 lines (456 loc) · 13.6 KB
/
server
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
#!/bin/bash
#
# A platform agnostic Scylla server installation script.
#
# Options:
# [--scylla-product scylla|scylla-enterprise] Scylla product to install (default: scylla)
# [--scylla-version <version>] Scylla version to install
#
# To install latest official version, run:
#
# curl -sSf get.scylladb.com/server | sudo bash
#
# To install a specific (stable) version, run:
#
# curl -sSf get.scylladb.com/server | sudo bash -s -- --scylla-version 4.1.0
#
# To install latest nightly version (for the brave), run:
#
# curl -sSf get.scylladb.com/server | sudo bash -s -- --scylla-version nightly-version
# version examples:
# --scylla-version nightly-master will install master latest nightly version
# --scylla-version nightly-4.5 will install 4.5 latest nightly version
# For enterprise product:
# --scylla-version nightly-enterprise will install enterprise latest nightly version
# --scylla-version nightly-2021.1 will install 2021.1 latest nightly version
#
# Flags:
# -h, --help - Prints help information
#
# DEBUG OPTIONS:
# [--scylla-repo-file-url <url>] URL to test installation from a custom URL.
# DEBUG FLAGS:
# [--debug-run] - use slim/minimal dockers when needed, and skip epel installation.
# [--dry-run] - Prints out commands instead of executing them.
# [--verbose] - Runs install commands with no quiet option, and more info.
#
# This file is open source software, licensed to you under the terms
# of the Apache License, Version 2.0 (the "License"). See the NOTICE file
# distributed with this work for additional information regarding copyright
# ownership. You may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
set -euo pipefail
shopt -s extglob
check_arch() {
ARCH=$(uname -m)
SCYLLA_RELEASE=$(echo $SCYLLA_VERSION | cut -d'-' -f 2)
case $SCYLLA_RELEASE in
*202[1-9].* | 4.6* | *[5-9].* | master | enterprise)
if [[ "$ARCH" != @("x86_64"|"aarch64") ]]; then
echo "Architecture $ARCH is not supported for $SCYLLA_PRODUCT-$SCYLLA_VERSION, for supported os and arch please refer to https://docs.scylladb.com/getting-started/os-support/."
exit 1
fi
;;
*)
if [[ "$ARCH" != "x86_64" ]]; then
echo "Architecture $ARCH is not supported for $SCYLLA_PRODUCT-$SCYLLA_VERSION, for supported os and arch please refer to https://docs.scylladb.com/getting-started/os-support/."
exit 1
fi
;;
esac
}
check_os() {
OS=$(uname -s)
case "$OS" in
Linux) ;;
*) echo -e "Your operating system $OS is not supported by this installer.\n\nPlease consider using Docker to run Scylla on this machine:\n\nhttps://hub.docker.com/r/scylladb/scylla" && exit 1 ;;
esac
}
echo_msg() {
if [ $DRY_RUN -eq 0 ]; then
echo $*
fi
}
run_cmd() {
CMD=("$@")
if [ $DRY_RUN -eq 0 ]; then
"${CMD[@]}"
else
echo "${CMD[@]}"
fi
}
check_product() {
case "$SCYLLA_PRODUCT" in
"scylla")
VERSION_CHECK_SYSTEM="scylla"
BRANCH_WORD="branch-"
;;
"scylla-enterprise")
VERSION_CHECK_SYSTEM="enterprise"
BRANCH_WORD="enterprise-"
;;
*)
echo "The product '$SCYLLA_PRODUCT' is not supported by this installer."
exit 1
;;
esac
}
is_rc_version() {
if [[ $SCYLLA_VERSION == *rc* ]]; then
# replace the 2nd '.' with '~' for RC versions, ex. 4.6.rc0 -> 4.6~rc0
SCYLLA_VERSION=$(echo $SCYLLA_VERSION | sed 's/\(.*\)\.)*/\1~/')
fi
}
query_default_version() {
DEFAULT_SCYLLA_VERSION_RAW=$(curl -s https://repositories.scylladb.com/scylla/check_version?system=$VERSION_CHECK_SYSTEM)
DEFAULT_SCYLLA_VERSION=$(echo $DEFAULT_SCYLLA_VERSION_RAW | sed -e "s/.*version\":\"\(.*\)\".*/\1/g")
}
set_gpg_key() {
SCYLLA_RELEASE=$(echo $SCYLLA_VERSION | cut -d'-' -f 2)
case $SCYLLA_RELEASE in
*"2020.1"* | *"2021.1"* | *"4.4"* | *"4.5"* | *"4.6"*)
SCYLLA_GPG_KEY="5e08fbd8b5d6ec9c"
;;
*)
SCYLLA_GPG_KEY="d0a112e067426ab2"
;;
esac
}
setup_install() {
set_gpg_key
if [[ -n "$SCYLLA_REPO_FILE_URL" ]]; then
SCYLLA_URL=${SCYLLA_REPO_FILE_URL}
SCYLLA_PRODUCT_VERSION="${SCYLLA_PRODUCT}"
else
if [[ $SCYLLA_VERSION == *"nightly"* ]]; then
SCYLLA_RELEASE=$(echo $SCYLLA_VERSION | cut -d'-' -f 2)
if [ $SCYLLA_RELEASE == "master" ] || [ $SCYLLA_RELEASE == "enterprise" ]; then
BRANCH_WORD=""
fi
if [ $1 == "debian" ]; then
SCYLLA_URL="http://downloads.scylladb.com/unstable/$SCYLLA_PRODUCT/$BRANCH_WORD$SCYLLA_RELEASE/deb/unified/latest/scylladb-$SCYLLA_RELEASE/scylla.list"
SCYLLA_PRODUCT_VERSION=$SCYLLA_PRODUCT
elif [ $1 == "ubuntu" ]; then
SCYLLA_URL="http://downloads.scylladb.com/unstable/$SCYLLA_PRODUCT/$BRANCH_WORD$SCYLLA_RELEASE/deb/unified/latest/scylladb-$SCYLLA_RELEASE/scylla.list"
SCYLLA_PRODUCT_VERSION=$SCYLLA_PRODUCT
else
set_rpm_install_tool
SCYLLA_URL="http://downloads.scylladb.com/unstable/$SCYLLA_PRODUCT/$BRANCH_WORD$SCYLLA_RELEASE/rpm/centos/latest/scylla.repo"
SCYLLA_PRODUCT_VERSION=$SCYLLA_PRODUCT
fi
else
SCYLLA_RELEASE=$(echo $SCYLLA_VERSION | sed -e "s/\([[:digit:]]\+.[[:digit:]]\+\).*/\1/g")
if [ $1 == "debian" ]; then
is_rc_version
SCYLLA_URL="http://downloads.scylladb.com/deb/debian/scylla-$SCYLLA_RELEASE.list"
SCYLLA_PRODUCT_VERSION="${SCYLLA_PRODUCT}=$SCYLLA_VERSION*"
elif [ $1 == "ubuntu" ]; then
is_rc_version
SCYLLA_URL="http://downloads.scylladb.com/deb/ubuntu/scylla-$SCYLLA_RELEASE.list"
SCYLLA_PRODUCT_VERSION="${SCYLLA_PRODUCT}=$SCYLLA_VERSION*"
else
set_rpm_install_tool
SCYLLA_URL="http://downloads.scylladb.com/rpm/centos/scylla-$SCYLLA_RELEASE.repo"
SCYLLA_PRODUCT_VERSION="$SCYLLA_PRODUCT-$SCYLLA_VERSION"
fi
fi
fi
}
main() {
require_cmd curl
DRY_RUN=0
SCYLLA_REPO_FILE_URL=""
DEBUG_RUN=0
VERBOSE=0
USAGE=0
DEFAULT_SCYLLA_PRODUCT="scylla"
SCYLLA_PRODUCT="$DEFAULT_SCYLLA_PRODUCT"
SCYLLA_VERSION=""
while [ $# -gt 0 ]; do
case "$1" in
"-h" | "--help")
USAGE=1
shift 1
;;
"--scylla-product")
SCYLLA_PRODUCT="$2"
shift 2
;;
"--scylla-version")
SCYLLA_VERSION="$2"
shift 2
;;
"--dry-run")
DRY_RUN=1
shift 1
;;
"--debug-run")
DEBUG_RUN=1
shift 1
;;
"--scylla-repo-file-url")
SCYLLA_REPO_FILE_URL="$2"
shift 2
;;
"--verbose")
VERBOSE=1
shift 1
;;
*)
USAGE=1
shift 1
;;
esac
done
RETRY_OPTION="-o Acquire::Retries=3"
if [ $VERBOSE -eq 1 ]; then
YUM_QUIET_CMD_PARAM="--assumeyes"
APT_FLAGS="--assume-yes $RETRY_OPTION"
else
YUM_QUIET_CMD_PARAM="--assumeyes --quiet"
APT_FLAGS="-qq $RETRY_OPTION"
fi
check_product
if [ -z "$SCYLLA_VERSION" ] && [ -z "$SCYLLA_REPO_FILE_URL" ]; then
query_default_version
SCYLLA_VERSION="$DEFAULT_SCYLLA_VERSION"
fi
if [ $USAGE -eq 1 ]; then
usage
exit 1
fi
check_arch
check_os
# os-release may be missing in container environment by default.
if [ -f "/etc/os-release" ]; then
. /etc/os-release
elif [ -f "/etc/arch-release" ]; then
export ID=arch
else
echo "/etc/os-release missing."
exit 1
fi
setup_install $ID
case "$ID" in
"amzn") amzn_install ;;
"centos") centos_install ;;
"rocky") centos_install ;;
"debian") debian_install ;;
"fedora") fedora_install ;;
"ol") ol_install ;;
"rhel") rhel_install ;;
"ubuntu") ubuntu_install ;;
*) echo "Operating system '$ID' is not supported by this installer." && exit 1
esac
echo_msg "Scylla installation done!"
}
usage() {
cat 1>&2 <<EOF
scylla-get
The platform agnostic installer for Scylla.
USAGE:
scylla-get [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
OPTIONS:
[--scylla-product scylla|scylla-enterprise] - Scylla product to install (default: $DEFAULT_SCYLLA_PRODUCT)
[--scylla-version <version>] - Scylla version to install (default: $DEFAULT_SCYLLA_VERSION)
Version examples:
--scylla-version nightly-master will install master latest nightly version
--scylla-version nightly-4.5 will install 4.5 latest nightly version
For enterprise product:
--scylla-version nightly-enterprise will install enterprise latest nightly version
--scylla-version nightly-2021.1 will install 2021.1 latest nightly version
DEBUG OPTIONS:
[--scylla-repo-file-url <url>] URL to test installation from a custom URL.
DEBUG FLAGS:
[--debug-run] - use slim/minimal dockers when needed, and skip epel installation.
[--dry-run] - Prints out commands instead of executing them.
[--verbose] - Runs install commands with no quiet option, and more info.
EOF
}
require_cmd() {
CMD=$1
if ! command -v "$CMD" &> /dev/null
then
echo "Please make sure '$CMD' is installed on this machine."
exit
fi
}
set_rpm_install_tool() {
RPM_INSTALL_TOOL="yum"
if [ $DEBUG_RUN -eq 1 ]; then
RPM_INSTALL_TOOL="microdnf"
fi
require_cmd $RPM_INSTALL_TOOL
}
install_rpm() {
ret=0
run_cmd curl -f -s -L -o /etc/yum.repos.d/scylla.repo "$SCYLLA_URL" || ret=$?
if [ $ret -ne 0 ]; then
echo "Your OS is not supported by this installer because there is no package repository."
exit 1
fi
run_cmd $RPM_INSTALL_TOOL install $YUM_QUIET_CMD_PARAM $SCYLLA_PRODUCT_VERSION
}
check_amzn_version() {
case "$VERSION_ID" in
"2")
return 1
;;
*)
return 0
;;
esac
}
amzn_install() {
if check_amzn_version = 0; then
echo "Amazon Linux $VERSION_ID is not supported by this installer."
exit 1
fi
echo_msg "Installing Scylla version $SCYLLA_VERSION for Amazon Linux ..."
set_rpm_install_tool
install_rpm
}
check_centos_version() {
case "$VERSION_ID" in
"7"|"8"|"8.5")
return 1
;;
*)
return 0
;;
esac
}
centos_install() {
if check_centos_version = 0; then
echo "CentOS $VERSION_ID is not supported by this installer."
exit 1
fi
set_rpm_install_tool
echo_msg "Installing Scylla version $SCYLLA_VERSION for CentOS ..."
install_rpm
}
fedora_install() {
echo_msg "Installing Scylla version $SCYLLA_VERSION for Fedora ..."
set_rpm_install_tool
install_rpm
}
check_rhel_version() {
case "$VERSION_ID" in
7.?|8.?)
return 1
;;
*)
return 0
;;
esac
}
rhel_install() {
if check_rhel_version = 0; then
echo "Red Hat Enterprise Linux $VERSION_ID is not supported by this installer."
exit 1
fi
echo_msg "Installing Scylla version $SCYLLA_VERSION for Red Hat Enterprise Linux ..."
set_rpm_install_tool
if [ $DEBUG_RUN -eq 0 ]; then
run_cmd $RPM_INSTALL_TOOL install $YUM_QUIET_CMD_PARAM https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
fi
install_rpm
}
check_ol_version() {
case "$VERSION_ID" in
7.?|8.?)
return 1
;;
*)
return 0
;;
esac
}
ol_install() {
if check_ol_version = 0; then
echo "Oracle Linux $VERSION_ID is not supported by this installer."
exit 1
fi
echo_msg "Installing Scylla version $SCYLLA_VERSION for Oracle Linux ..."
set_rpm_install_tool
if [ $DEBUG_RUN -eq 0 ]; then
run_cmd $RPM_INSTALL_TOOL install $YUM_QUIET_CMD_PARAM https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
fi
install_rpm
}
check_debian_version() {
case "$VERSION_ID" in
"9"|"10"|"11")
return 1
;;
*)
return 0
;;
esac
}
debian_install() {
if check_debian_version = 0; then
echo "Debian $VERSION_ID is not supported by this installer."
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
run_cmd apt update
run_cmd apt-get install $APT_FLAGS apt-transport-https curl gnupg2 dirmngr
ret=0
run_cmd curl -f -s -L -o /etc/apt/sources.list.d/scylla.list "$SCYLLA_URL" || ret=$?
if [ $ret -ne 0 ]; then
echo "Your OS is not supported by this installer because there is no package repository."
exit 1
fi
echo_msg "Installing Scylla version $SCYLLA_VERSION for Debian ..."
run_cmd apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $SCYLLA_GPG_KEY
run_cmd apt update
run_cmd apt-get install $APT_FLAGS $SCYLLA_PRODUCT_VERSION
}
check_ubuntu_version() {
case "$VERSION_ID" in
"16.04"|"18.04"|"20.04"|"22.04")
return 1
;;
*)
return 0
;;
esac
}
ubuntu_install() {
if check_ubuntu_version = 0; then
echo "Ubuntu $VERSION_ID is not supported by this installer."
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
run_cmd apt update
if [ "$VERSION_ID" = "16.04" ]; then
run_cmd apt-get install $APT_FLAGS curl gnupg2 apt-transport-https
else
run_cmd apt-get install $APT_FLAGS curl gnupg2
fi
ret=0
run_cmd curl -f -s -L -o /etc/apt/sources.list.d/scylla.list "$SCYLLA_URL" || ret=$?
if [ $ret -ne 0 ]; then
echo "Your OS is not supported by this installer because there is no package repository."
exit 1
fi
echo_msg "Installing Scylla version $SCYLLA_VERSION for Ubuntu ..."
run_cmd apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $SCYLLA_GPG_KEY
run_cmd apt update
run_cmd apt-get install $APT_FLAGS $SCYLLA_PRODUCT_VERSION
}
main "$@"