This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·96 lines (86 loc) · 1.82 KB
/
run.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
#!/usr/bin/bash
set -euo pipefail
# shellcheck source=/dev/null
source /root/demo-scm/demo.profile.sh
setDebugLevel
SECONDS=0
OPT=${1:-}
#######################
## Functions
#######################
build(){
if bash "$BIN/setup.sh"; then
INFO "$DEMO_NAME - Build OK"
else
ERROR "$DEMO_NAME - Build KO"
fi
}
reload-cbci(){
if bash "$BIN/reload-cbci.sh"; then
INFO "$DEMO_NAME - Reload OK"
else
ERROR "$DEMO_NAME - Reload KO"
fi
}
scale(){
if bash "$BIN/scale.sh"; then
INFO "$DEMO_NAME - Scale OK"
else
ERROR "$DEMO_NAME - Scale KO"
fi
}
restore(){
if bash "$BIN/restore.sh"; then
INFO "$DEMO_NAME - Restore OK"
else
ERROR "$DEMO_NAME - Restore KO"
fi
}
destroy(){
if bash "$BIN/teardown.sh"; then
INFO "$DEMO_NAME - Destroy OK"
else
ERROR "$DEMO_NAME - Destroy KO"
fi
}
#######################
## Init
#######################
if [ -z "$OPT" ]; then
cat <<EOF
Select one of the following option and press [ENTER]:
[B] Build
[L] reLoad
[S] Scale
[R] Restore
[D] Destroy
EOF
read -r opt
else
opt="$OPT"
fi
upperOpt=$(echo "$opt" | tr '[:lower:]' '[:upper:]')
if [ ! -d "logs" ]; then
mkdir "logs"
fi
case $upperOpt in
[B]* )
build 2>&1 | tee "logs/build_$DEMO_NAME.log"
;;
[L]* )
reload-cbci 2>&1 | tee "logs/reload_$DEMO_NAME.log"
;;
[S]* )
scale 2>&1 | tee "logs/scale_$DEMO_NAME.log"
;;
[R]* )
restore 2>&1 | tee "logs/restore_$DEMO_NAME.log"
;;
[D]* )
destroy 2>&1 | tee "logs/destroy_$DEMO_NAME.log"
;;
* ) INFO "Please answer a valid option."
;;
esac
duration=$SECONDS
INFO "$((duration / 60)) minutes and $((duration % 60)) seconds elapsed"