/
wallaroo-up.sh
executable file
·803 lines (686 loc) · 24.3 KB
/
wallaroo-up.sh
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
#!/bin/bash
# md5 for validatiing script checksum
MD5="0432d71ded8669380afee2b02965dee8 -"
set -eEuo pipefail
WALLAROO_UP_DEST_DEFAULT=~/wallaroo-tutorial
WALLAROO_UP_DEST_ARG="$WALLAROO_UP_DEST_DEFAULT"
WALLAROO_UP_INSTALL_TYPE=UNSPECIFIED
WALLAROO_VERSION_DEFAULT=0.5.3
WALLAROO_VERSION="$WALLAROO_VERSION_DEFAULT"
WALLAROO_TOOLS_TO_BUILD="build-giles-sender-all build-utils-all"
PKGS_TO_INSTALL="git wget findutils"
GOLANG_INSTALL=
PYTHON_INSTALL=
WALLAROO_UP_NAME=wallaroo-up
LOG_FILE="$(pwd -P)/$WALLAROO_UP_NAME.log"
set_trap() {
trap 'echo "ERROR!!!! Please check log file ($LOG_FILE) for details."' ERR
}
clear_trap() {
trap - ERR
}
# set trap
set_trap
#reset log file
echo > "$LOG_FILE"
# set up redirects
REDIRECT=" >> $LOG_FILE 2>&1"
VERBOSE_REDIRECT=" 2>&1 | tee -a $LOG_FILE"
VERBOSE=
GOLANG_VERSION=1.9.4
GOLANG_DL_URL=https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz
# sample wallaroo version to ponyc version map entry: W0.4.3=0.21.0
# another sample entry: W4807928=0.22.6
WALLAROO_PONYC_MAP="
W0.5.3=0.24.4
W0.5.2=0.24.4
Wmaster=
"
VALID_INSTALL_TYPES="
all
golang
python
"
VALID_DISTRO_VERSIONS="
centos-7
rhel-7
ol-7
amzn-2
fedora-26
fedora-27
fedora-28
ubuntu-trusty
ubuntu-xenial
ubuntu-artful
ubuntu-bionic
debian-jessie
debian-stretch
debian-buster
"
PREVIEW_COMMANDS=
OS=$(uname -s)
# check OS
case "$OS" in
Linux)
;;
*)
echo "This script has only been tested on Linux. Wallaroo can be "
echo "installed on non-Linux environments using Docker or Vagrant. Please visit: "
echo "https://docs.wallaroolabs.com/book/getting-started/choosing-an-installation-option.html"
echo "for instructions for a Python Wallaroo environment or please visit: "
echo "https://docs.wallaroolabs.com/book/go/getting-started/choosing-an-installation-option.html"
echo "for instructions for a Go Wallaroo environment."
exit 1
;;
esac
# check checksum of script to ensure it wasn't accidentally mangled
CALCULATED_MD5="$(tail -n +5 "$0" | md5sum)"
if [[ "$CALCULATED_MD5" != "$MD5" ]]; then
echo "Checksum error in '$0'! Script is corrupted! Please re-download." >&2
exit 1
fi
# function to log/run command (or if preview, only log it)
run_cmd() {
num_retries=0
max_retries=0
# only retry if requested
if [ "${3:-}" == "retry" ]; then
max_retries=3
fi
# retry loop
while true; do
# log commnd being run
if [ "${2:-}" == "root" ]; then
if [ "$PREVIEW_COMMANDS" == "true" ]; then
tmp_cmd="echo \"$root_cmd_pre '$1'\" $VERBOSE_REDIRECT"
else
tmp_cmd="echo \"Running: $root_cmd_pre '$1'\" $REDIRECT"
fi
else
if [ "$PREVIEW_COMMANDS" == "true" ]; then
tmp_cmd="echo \"$cmd_pre '$1'\" $VERBOSE_REDIRECT"
else
tmp_cmd="echo \"Running: $cmd_pre '$1'\" $REDIRECT"
fi
fi
eval "$tmp_cmd"
# if not previewing, run the command
if [ "$PREVIEW_COMMANDS" != "true" ]; then
# disable exit on error and trap
set +e
clear_trap
# run command (as root or normal)
if [ "${2:-}" == "root" ]; then
$root_cmd_pre "$1"
else
$cmd_pre "$1"
fi
# check exit code from command
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
break
fi
# check if we've exhausted all of our retries
(( num_retries=num_retries+1 ))
if [ $num_retries -gt $max_retries ]; then
if [ "${2:-}" == "root" ]; then
echo "ERROR! Error running '$root_cmd_pre \"$1\"'!"
else
echo "ERROR! Error running '$cmd_pre \"$1\"'!"
fi
echo "ERROR!!!! Please check log file ($LOG_FILE) for details."
exit 1
fi
# sleep for 1 second before retrying again
sleep 1
# re-enable exit on error and trap
set_trap
set -e
else
break
fi
done
}
# function to log messages
log() {
tmp_cmd="echo \"$WALLAROO_UP_NAME: $1\" $REDIRECT"
eval "$tmp_cmd"
if [ "$VERBOSE" != "true" ]; then
echo "$WALLAROO_UP_NAME: $1"
fi
}
error() {
log "ERROR: $1" >&2
exit 1
}
# function to check if a command exists or exit with failure otherwise
check_cmd() {
if have_cmd "$1"; then
error "Needed command '$1' not available"
fi
}
# check if a command exists
have_cmd() {
command -v "$1" > /dev/null 2>&1
}
usage() {
cat 1>&2 <<EOF
The installer for a wallaroo development environment
USAGE:
$WALLAROO_UP_NAME [FLAGS] [OPTIONS]
FLAGS:
-h Prints help information
-v Verbose output
OPTIONS:
-t <type> Choose a wallaroo install type (all/golang/python)
-p <path> Where to put wallaroo code (DEFAULT: $WALLAROO_UP_DEST_DEFAULT)
-w <version> Wallaroo version to install (DEFAULT: $WALLAROO_VERSION_DEFAULT)
EOF
}
# parse command line options
while getopts 'vht:p:w:' OPTION; do
case "$OPTION" in
t)
WALLAROO_UP_INSTALL_TYPE="$(echo "$OPTARG" | tr '[:upper:]' '[:lower:]')"
;;
h)
usage
exit 1
;;
p)
WALLAROO_UP_DEST_ARG="$OPTARG"
;;
w)
WALLAROO_VERSION="$OPTARG"
;;
v)
REDIRECT="$VERBOSE_REDIRECT"
VERBOSE=true
;;
?)
usage
exit 1
;;
esac
done
shift "$((OPTIND -1))"
# validate arguments and set variables
if ! echo "$VALID_INSTALL_TYPES" | grep "^$WALLAROO_UP_INSTALL_TYPE\$" >/dev/null; then
usage
echo
error "Invalid install type! '$WALLAROO_UP_INSTALL_TYPE'"
else
case "$WALLAROO_UP_INSTALL_TYPE" in
python)
PYTHON_INSTALL="true"
;;
golang)
GOLANG_INSTALL="true"
;;
all)
PYTHON_INSTALL="true"
GOLANG_INSTALL="true"
;;
esac
fi
# validate wallaroo version requested
if ! echo "$WALLAROO_PONYC_MAP" | grep "^W$WALLAROO_VERSION=" >/dev/null; then
usage
echo
error "Unsupported Wallaroo version! '$WALLAROO_VERSION'"
else
PONYC_VERSION=$(echo "$WALLAROO_PONYC_MAP" | grep "^W$WALLAROO_VERSION=" | cut -d'=' -f 2)
WALLAROO_VERSION_DIRECTORY="wallaroo-${WALLAROO_VERSION}"
fi
WALLAROO_UP_DEST=$(readlink -m "${WALLAROO_UP_DEST_ARG}")
# get which distribution we're running on
get_distribution() {
# check upstream lsb-release info if it exists
if [ -r /etc/upstream-release/lsb-release ]; then
# shellcheck disable=SC1091
dist="$(. /etc/upstream-release/lsb-release && echo "$DISTRIB_ID")"
# otherwise use standard os-release info
elif [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
dist="$(. /etc/os-release && echo "$ID")"
fi
# make it all lowercase just in case
# shellcheck disable=SC1091
dist="$(echo "$dist" | tr '[:upper:]' '[:lower:]')"
}
# get version of distribution
get_distribution_version() {
# check upstream lsb-release info if it exists
if [ -r /etc/upstream-release/lsb-release ]; then
# shellcheck disable=SC1091
dist_version="$(. /etc/upstream-release/lsb-release && echo "$DISTRIB_CODENAME")"
else
# otherwise use standard stuff based on distribution
case "$dist" in
ubuntu)
if [ -r /etc/lsb-release ]; then
# shellcheck disable=SC1091
dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
fi
;;
centos)
if [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
fi
;;
rhel|ol)
if [ -r /etc/os-release ]; then
# for RHEL/OL we need to get the major version out of a version number that looks like 7.5
# shellcheck disable=SC1091
dist_version="$(. /etc/os-release && echo "$VERSION_ID" | grep -o '^[0-9]')"
fi
;;
debian)
if [ -r /etc/os-release ]; then
# for debian, os-release is a number and not the codename and for testing there is no VERSION_ID set so we fall back to reading parsing it from debian_version
# shellcheck disable=SC1091
dist_version="$(. /etc/os-release && echo "${VERSION_ID:-$(cut -d'/' -f1 < /etc/debian_version)}")"
case "$dist_version" in
10)
dist_version="buster"
;;
9)
dist_version="stretch"
;;
8)
dist_version="jessie"
;;
esac
fi
;;
*)
if [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
fi
;;
esac
fi
dist_version="$(echo "$dist_version" | tr '[:upper:]' '[:lower:]')"
}
# Figure out if we have sudo or not or if we're already root for when running commands
set_cmd_prefix() {
root_cmd_pre="sh -c"
cmd_pre="sh -c"
HAVE_ROOT=rootuser
if [ "$(whoami)" != 'root' ]; then
if have_cmd sudo; then
root_cmd_pre='sudo sh -c'
HAVE_ROOT=sudo
else
HAVE_ROOT=
fi
fi
}
# check architecture
check_arch() {
arch=$(uname -m)
if [ "$arch" != 'x86_64' ]; then
error "Wallaroo is currently only available for x86_64 architectures. Architecture '${arch}' not supported!"
fi
}
# confirm we're running for a distro/version combination we support
check_valid_distro() {
if ! echo "$VALID_DISTRO_VERSIONS" | grep "^$dist-$dist_version\$" >/dev/null; then
error "Distro/version combination not supported: $dist-$dist_version"
fi
}
# install dependencies for wallaroo
install_required_dependencies() {
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Installing dependencies..."
fi
case "$dist" in
debian|ubuntu)
# figure out which pre-reqs need installing and install them
PREREQS_TO_INSTALL=
if ! dpkg -l | grep -q '\Wsoftware-properties-common\W'; then
PREREQS_TO_INSTALL="$PREREQS_TO_INSTALL software-properties-common"
fi
if ! dpkg -l | grep -q '\Wapt-transport-https\W'; then
PREREQS_TO_INSTALL="$PREREQS_TO_INSTALL apt-transport-https"
fi
if ! dpkg -l | grep -q '\Wca-certificates\W'; then
PREREQS_TO_INSTALL="$PREREQS_TO_INSTALL ca-certificates"
fi
if ! dpkg -l | grep -q '\Wcurl\W'; then
PREREQS_TO_INSTALL="$PREREQS_TO_INSTALL curl"
fi
if ! dpkg -l | grep -q '\Wgnupg2\W'; then
PREREQS_TO_INSTALL="$PREREQS_TO_INSTALL gnupg2"
fi
if ! dpkg -l | grep -q '\Wdirmngr\W'; then
PREREQS_TO_INSTALL="$PREREQS_TO_INSTALL dirmngr"
fi
if [ "$PREREQS_TO_INSTALL" != "" ]; then
run_cmd "apt-get update $REDIRECT" root retry
run_cmd "apt-get install -y $PREREQS_TO_INSTALL $REDIRECT" root retry
fi
# figure out which packages need installing
if [ "$PYTHON_INSTALL" == "true" ]; then
PKGS_TO_INSTALL="$PKGS_TO_INSTALL python-dev"
fi
if [ "$PONYC_VERSION" != "" ]; then
PKGS_TO_INSTALL="$PKGS_TO_INSTALL ponyc=${PONYC_VERSION}"
fi
PKGS_TO_INSTALL="$PKGS_TO_INSTALL libssl-dev make pony-stable libsnappy-dev liblz4-dev"
# if jessie/trusty add in wallaroolabs-debian repo for backport of liblz4 needed by Wallaroo
case "$dist_version" in
jessie|trusty)
if ! apt-cache policy 2>&1 | grep wallaroolabs-debian > /dev/null 2>&1; then
run_cmd "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 379CE192D401AB61 $REDIRECT" root retry
run_cmd "add-apt-repository 'deb https://wallaroo-labs.bintray.com/wallaroolabs-debian ${dist_version} main' $REDIRECT" root
fi
;;
esac
# add in ponylang-debian repo for ponylang install
if ! apt-cache policy 2>&1 | grep pony-language/ponylang-debian > /dev/null 2>&1; then
run_cmd "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys E04F0923 B3B48BDA $REDIRECT" root retry
run_cmd "add-apt-repository 'deb https://dl.bintray.com/pony-language/ponylang-debian ${dist_version} main' $REDIRECT" root
fi
# install dependencies for wallaroo
run_cmd "apt-get update $REDIRECT" root retry
run_cmd "apt-get install -y $PKGS_TO_INSTALL $REDIRECT" root retry
;;
centos|rhel|ol|amzn)
# figure out which packages need installing
PKGS_TO_INSTALL="$PKGS_TO_INSTALL which"
if [ "$PYTHON_INSTALL" == "true" ]; then
PKGS_TO_INSTALL="$PKGS_TO_INSTALL python-devel"
fi
if [ "$PONYC_VERSION" != "" ]; then
PKGS_TO_INSTALL="ponyc-${PONYC_VERSION} $PKGS_TO_INSTALL"
fi
if [ "$dist" == "amzn" ]; then
PKGS_TO_INSTALL="$PKGS_TO_INSTALL tar"
fi
PKGS_TO_INSTALL="$PKGS_TO_INSTALL pony-stable make gcc-c++ snappy-devel openssl-devel lz4-devel"
# if oracle linux, enable the optional repo
if [ "$dist" == "ol" ]; then
run_cmd "yum-config-manager --enable ol7_optional_latest $REDIRECT" root
fi
# enable ponylang copr repo
if ! yum list installed -q yum-plugin-copr > /dev/null 2>&1; then
run_cmd "yum makecache -y $REDIRECT" root retry
run_cmd "yum install -y yum-plugin-copr $REDIRECT" root retry
fi
if ! yum repolist 2>&1 | grep ponylang-ponylang > /dev/null 2>&1; then
run_cmd "yum copr enable ponylang/ponylang epel-7 -y $REDIRECT" root
fi
run_cmd "yum makecache -y $REDIRECT" root retry
## install one at a time or else yum doesn't throw an error for missing packages
for pkg in $PKGS_TO_INSTALL; do
run_cmd "yum install -y $pkg $REDIRECT" root retry
done
;;
fedora)
# figure out which packages need installing
PKGS_TO_INSTALL="$PKGS_TO_INSTALL which"
if [ "$PYTHON_INSTALL" == "true" ]; then
PKGS_TO_INSTALL="$PKGS_TO_INSTALL python-devel"
fi
if [ "$PONYC_VERSION" != "" ]; then
PKGS_TO_INSTALL="$PKGS_TO_INSTALL ponyc-${PONYC_VERSION}"
fi
PKGS_TO_INSTALL="$PKGS_TO_INSTALL pony-stable make gcc-c++ snappy-devel openssl-devel lz4-devel"
# enable ponylang copr repo
if ! dnf list installed -q 'dnf-plugins-core' > /dev/null 2>&1; then
run_cmd "dnf makecache -y >/dev/null $REDIRECT" root retry
run_cmd "dnf install 'dnf-command(copr)' -y $REDIRECT" root retry
fi
if ! dnf repolist 2>&1 | grep ponylang-ponylang > /dev/null 2>&1; then
run_cmd "dnf copr enable ponylang/ponylang -y $REDIRECT" root
fi
run_cmd "dnf makecache -y $REDIRECT" root retry
# install dependencies for wallaroo
run_cmd "dnf install -y $PKGS_TO_INSTALL $REDIRECT" root retry
;;
*)
echo "ERROR! Unknown distribution: $dist with version $dist_version"
exit 1
;;
esac
}
# check to see if the wallaroo destination already exists
check_wallaroo_dest() {
BACKUP_WALLAROO_UP_DEST=
if [ -e "${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}" ]; then
BACKUP_WALLAROO_UP_DEST=true
fi
}
# configure wallaroo version being installed
configure_wallaroo() {
# back up wallaroo directory if needed
if [ "$BACKUP_WALLAROO_UP_DEST" == "true" ]; then
INSTALL_TYPE=subsequent
DATETIME=$(date +%Y%m%d%H%M%S)
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Backing up existing '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}' to '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}.$DATETIME'..."
fi
run_cmd "mv '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}' '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}.$DATETIME' $REDIRECT"
fi
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Configuring Wallaroo into '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}'..."
fi
# make wallaroo destination directory and change to it
run_cmd "mkdir -p \"$WALLAROO_UP_DEST\" $REDIRECT"
if [ "$PREVIEW_COMMANDS" != "true" ]; then
tmp_cmd="echo Running: cd $WALLAROO_UP_DEST $REDIRECT"
eval "$tmp_cmd"
cd "$WALLAROO_UP_DEST"
else
tmp_cmd="echo cd $WALLAROO_UP_DEST $VERBOSE_REDIRECT"
eval "$tmp_cmd"
fi
## sets the wallaroo bintray subject
wallaroo_bintray_subject="wallaroo-labs"
## sets the wallaroo bintray package name
wallaroo_bintray_package="wallaroo"
## Sets Wallaroo source archive name
wallaroo_source_archive="wallaroo-${WALLAROO_VERSION}.tar.gz"
## Sets Metrics UI appimage name
metrics_ui_appimage="Wallaroo_Metrics_UI-${WALLAROO_VERSION}-x86_64.AppImage"
# set the correct wallaroo bintray repo name
if [[ "$WALLAROO_VERSION" == "release"* ]]; then
wallaroo_bintray_artifacts_repo=wallaroolabs-rc
else
wallaroo_bintray_artifacts_repo=wallaroolabs-ftp
fi
QUIET=-q
if [ "$VERBOSE" == "true" ]; then
QUIET=
fi
## download/untar wallaroo release tgz from bintray
WGET_URL_SUFFIX="?source=${WALLAROO_UP_SOURCE:-wallaroo-up}&install=${INSTALL_TYPE:-initial}&install_type=${WALLAROO_UP_INSTALL_TYPE}"
WGET_URL_SUFFIX=
WALLAROO_SOURCE_TGZ_URL="https://${wallaroo_bintray_subject}.bintray.com/${wallaroo_bintray_artifacts_repo}/${wallaroo_bintray_package}/${WALLAROO_VERSION}/${wallaroo_source_archive}${WGET_URL_SUFFIX}"
# download wallaroo source code (use custom tgz if requested for testing)
if [[ "${CUSTOM_WALLAROO_SOURCE_TGZ_URL:-}" == "" ]]; then
run_cmd "wget $QUIET -O $wallaroo_source_archive '${WALLAROO_SOURCE_TGZ_URL}' $REDIRECT" "" retry
else
log "Using custom wallaroo source tgz '${CUSTOM_WALLAROO_SOURCE_TGZ_URL:-}'..."
if [[ "${CUSTOM_WALLAROO_SOURCE_TGZ_URL:-}" == "http://"* ]] ; then
run_cmd "wget $QUIET -O $wallaroo_source_archive '${CUSTOM_WALLAROO_SOURCE_TGZ_URL:-}' $REDIRECT" "" retry
else
run_cmd "cp ${CUSTOM_WALLAROO_SOURCE_TGZ_URL:-} $wallaroo_source_archive $REDIRECT"
fi
fi
# make wallaroo version directory and extract wallaroo source code into it
run_cmd "mkdir ${WALLAROO_VERSION_DIRECTORY} $REDIRECT"
run_cmd "tar -C ${WALLAROO_VERSION_DIRECTORY} --strip-components=1 -xzf $wallaroo_source_archive $REDIRECT"
run_cmd "rm $wallaroo_source_archive $REDIRECT"
# change to wallaroo version directory
if [ "$PREVIEW_COMMANDS" != "true" ]; then
tmp_cmd="echo Running: cd ${WALLAROO_VERSION_DIRECTORY} $REDIRECT"
eval "$tmp_cmd"
cd "${WALLAROO_VERSION_DIRECTORY}"
# do a make clean if using a custom wallaroo source tgz
if [[ "${CUSTOM_WALLAROO_SOURCE_TGZ_URL:-}" != "" ]]; then
run_cmd "make clean $REDIRECT"
fi
else
tmp_cmd="echo cd ${WALLAROO_VERSION_DIRECTORY} $VERBOSE_REDIRECT"
eval "$tmp_cmd"
fi
# make bin directory
run_cmd "mkdir bin $REDIRECT"
## download/install our private golang
if [ "$GOLANG_INSTALL" == "true" ]; then
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Downloading and configuring private golang version $GOLANG_VERSION..."
fi
QUIET=-q
if [ "$VERBOSE" == "true" ]; then
QUIET=
fi
run_cmd "wget $QUIET $GOLANG_DL_URL -O /tmp/go.tar.gz $REDIRECT" "" retry
run_cmd "tar -C bin -xzf /tmp/go.tar.gz $REDIRECT"
run_cmd "mv bin/go bin/go${GOLANG_VERSION} $REDIRECT"
run_cmd "rm /tmp/go.tar.gz $REDIRECT"
fi
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Configuring Wallaroo Metrics UI..."
fi
## download/install metrics UI appImage
WALLAROO_METRICS_UI_APPIMAGE_URL="https://${wallaroo_bintray_subject}.bintray.com/${wallaroo_bintray_artifacts_repo}/${wallaroo_bintray_package}/${WALLAROO_VERSION}/${metrics_ui_appimage}${WGET_URL_SUFFIX}"
if [[ "${CUSTOM_WALLAROO_METRICS_UI_APPIMAGE_URL:-}" == "" ]]; then
run_cmd "wget $QUIET -O $metrics_ui_appimage '${WALLAROO_METRICS_UI_APPIMAGE_URL}' $REDIRECT" "" retry
else
log "Using custom wallaroo metrics ui appimage '${CUSTOM_WALLAROO_METRICS_UI_APPIMAGE_URL:-}'..."
if [[ "${CUSTOM_WALLAROO_METRICS_UI_APPIMAGE_URL:-}" == "http://"* ]] ; then
run_cmd "wget $QUIET -O $metrics_ui_appimage '${CUSTOM_WALLAROO_METRICS_UI_APPIMAGE_URL:-}' $REDIRECT" "" retry
else
run_cmd "cp ${CUSTOM_WALLAROO_METRICS_UI_APPIMAGE_URL:-} $metrics_ui_appimage $REDIRECT"
fi
fi
run_cmd "chmod +x $metrics_ui_appimage $REDIRECT"
# extract the appimage because metrics_ui likes to be able to write to it's directories and also because appimages don't work in docker
run_cmd "./$metrics_ui_appimage --appimage-extract $REDIRECT"
run_cmd "mv squashfs-root bin/metrics_ui $REDIRECT"
# delete libtinfo.so.5 so the one provided by the distribution can be used
if [[ "$dist" != "fedora" ]]; then
if [[ "$dist_version" != "buster" ]]; then
run_cmd "rm bin/metrics_ui/usr/lib/libtinfo.so.5"
fi
fi
run_cmd "sed -i 's/sleep 4/sleep 0/' bin/metrics_ui/AppRun"
run_cmd "rm $metrics_ui_appimage $REDIRECT"
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Compiling Wallaroo tools..."
fi
# compile wallaroo tools
run_cmd "make ${CUSTOM_WALLAROO_BUILD_ARGS:-} $WALLAROO_TOOLS_TO_BUILD $REDIRECT"
# compile machida if needed
if [ "$PYTHON_INSTALL" == "true" ]; then
if [ "$PREVIEW_COMMANDS" != "true" ]; then
log "Compiling Machida for running Python Wallaroo Applications..."
fi
echo "building machida with resilience"
run_cmd "make ${CUSTOM_WALLAROO_BUILD_ARGS:-} build-machida-all resilience=on $REDIRECT"
echo "building machida3 with resilience"
run_cmd "make ${CUSTOM_WALLAROO_BUILD_ARGS:-} build-machida3-all resilience=on $REDIRECT"
run_cmd "mv machida/build/machida bin/machida-resilience $REDIRECT"
run_cmd "mv machida3/build/machida3 bin/machida3-resilience $REDIRECT"
echo "building machida without resilience"
run_cmd "make ${CUSTOM_WALLAROO_BUILD_ARGS:-} build-machida-all $REDIRECT"
echo "building machida3 without resilience"
run_cmd "make ${CUSTOM_WALLAROO_BUILD_ARGS:-} build-machida3-all $REDIRECT"
run_cmd "cp machida/build/machida bin $REDIRECT"
run_cmd "cp machida3/build/machida3 bin $REDIRECT"
run_cmd "cp -r machida/lib bin/pylib $REDIRECT"
fi
# copy binaries to the bin directory
run_cmd "cp utils/data_receiver/data_receiver bin $REDIRECT"
run_cmd "cp utils/cluster_shutdown/cluster_shutdown bin $REDIRECT"
run_cmd "cp utils/cluster_shrinker/cluster_shrinker bin $REDIRECT"
run_cmd "cp giles/sender/sender bin $REDIRECT"
run_cmd "ln -s metrics_ui/AppRun bin/metrics_reporter_ui $REDIRECT"
# clean up built artifacts
run_cmd "make clean $REDIRECT $REDIRECT"
}
# do the actual install
do_install() {
install_required_dependencies
configure_wallaroo
}
# get user permission prior to proceeding
user_permission() {
log "This script will install/configure Wallaroo version '$WALLAROO_VERSION' for $dist-$dist_version."
log "It will use root privileges via '$HAVE_ROOT' to perform administrative tasks."
log ""
log "It will perform the following actions:"
log ""
log "* Add the ponylang repo to the package manager (if necessary)"
log "* Install the Wallaroo dependencies including ponyc and required libraries"
if [ "$PYTHON_INSTALL" == "true" ]; then
log "* Install the python development libraries for python support for Wallaroo"
fi
if [ "$GOLANG_INSTALL" == "true" ]; then
log "* Install private golang for golang support for Wallaroo"
fi
if [ "$BACKUP_WALLAROO_UP_DEST" == "true" ]; then
log "* Back up the existing '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}'"
fi
log "* Get the Wallaroo source code and put it into '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}'"
log "* Compile Wallaroo related tools (sender, cluster_shutdown, etc)"
log ""
log "NOTE: Full log of all actions can be found in $LOG_FILE"
log ""
if [ "$HAVE_ROOT" == "" ]; then
log "Error: this installer needs the ability to run commands as root."
error 'Unable to find "sudo" available to make this happen. Cannot proceed!'
fi
# allow user to proceed/abort/preview
while true; do
read -rp "$WALLAROO_UP_NAME: Ok to proceed with installation (y = Yes, n = No, p = preview)? " yn
case $yn in
[Yy]*)
log "Proceeding with installation"
break
;;
[Nn]*)
log "Aborting installation!"
exit
;;
[Pp]*)
log ""
log "Commands to run:"
PREVIEW_COMMANDS=true
echo
do_install
echo
PREVIEW_COMMANDS=false
log ""
;;
*)
log "Please answer y, n or p."
;;
esac
done
}
# put the activate script in the right location
create_env_file() {
cd "${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}"
cp misc/activate bin/
log "Please use \"source bin/activate\" in '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}' to set up environment for wallaroo."
}
main() {
check_arch
get_distribution
get_distribution_version
check_valid_distro
set_cmd_prefix
check_wallaroo_dest
user_permission
do_install
create_env_file
log ""
log "Successfully configured Wallaroo into '${WALLAROO_UP_DEST}/${WALLAROO_VERSION_DIRECTORY}'!"
}
main