-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkrectl.sh
executable file
·141 lines (117 loc) · 2.35 KB
/
krectl.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
#!/bin/sh
# disable unused vars check, vars are used on functions inside subscripts
# shellcheck disable=SC2034 # https://github.com/koalaman/shellcheck/wiki/SC2034
set -eu
DEBUG=${DEBUG:-0}
if [ "$DEBUG" = "1" ]; then
set -x
fi
# Default values
VERBOSE=1
SKIP_BUILD=0
BUILD_ALL=1
BUILD_ENGINE=0
BUILD_RUNTIME=0
BUILD_RUNNERS=0
SKIP_FRONTEND_BUILD=0
HOSTCTL_INSTALLED=0
MINIKUBE_RESET=0
MINIKUBE_CLEAN=0
MONGO_POD=""
# Admin MongoDB credentials
MONGO_DB=kre
MONGO_USER="admin"
MONGO_PASS=123456
# DEV Admin User
ADMIN_DEV_EMAIL="dev@local.local"
. ./.krectl.conf
. ./scripts/krectl/common_functions.sh
. ./scripts/krectl/cmd_help.sh
. ./scripts/krectl/cmd_minikube.sh
. ./scripts/krectl/cmd_etchost.sh
. ./scripts/krectl/cmd_dev.sh
. ./scripts/krectl/cmd_build.sh
. ./scripts/krectl/cmd_deploy.sh
. ./scripts/krectl/cmd_login.sh
. ./scripts/krectl/cmd_delete.sh
. ./scripts/krectl/cmd_restart.sh
check_requirements
echo
# Parse global arguments
case $* in
*\ -q*)
VERBOSE=0
;;
*--help|-h*)
show_help "$@"
exit
;;
esac
if [ -z "$*" ] || { [ "$VERBOSE" = "0" ] && [ "$#" = "1" ]; }; then
echo_warning "missing command"
echo
echo
show_help
exit 1
fi
# Split command and sub-command args and remove global flags
COMMAND=$1
shift
COMMAND_ARGS=$(echo "$*" | sed -e 's/ +-v//g')
# Check which command is requested
case $COMMAND in
start)
minikube_start
echo_done "Start done"
exit 0
;;
etchost)
cmd_etchost
echo_done "Done"
exit 0
;;
stop)
minikube_stop
echo_done "Stop done"
exit 0
;;
dev)
cmd_dev "$@"
echo_done "Dev environment created"
exit 0
;;
deploy)
cmd_deploy "$@"
echo_done "Deploy done"
exit 0
;;
build)
cmd_build "$@"
echo_done "Build done"
exit 0
;;
delete)
# NOTE: horrible hack to avoid passing -v as argument to sub-command
# shellcheck disable=SC2046 # https://github.com/koalaman/shellcheck/wiki/SC2046
# shellcheck disable=SC2116 # https://github.com/koalaman/shellcheck/wiki/SC2116
cmd_delete $(echo "$COMMAND_ARGS")
echo_done "Delete done"
exit 0
;;
restart)
cmd_restart "$@"
echo_done "Restart done"
exit 0
;;
login)
cmd_login "$@"
echo_done "Login done"
exit 0
;;
*)
echo_warning "unknown command: $(echo_yellow "$COMMAND")"
echo
echo
show_help
exit 1
esac