-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·47 lines (35 loc) · 1.17 KB
/
setup
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
#!/bin/bash
set -eou pipefail
CYAN='\033[0;36m'
NC='\033[0m' # No Color
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#shellcheck source=./env.sh
. "$dir/env.sh"
var_ctl_repo="$ctl_repo"
var_ctl_repo_branch="${ctl_branch:-master}"
var_env_repo="$env_repo"
var_env_main_link_target="${env_main_link_target:-}"
if [ ! -d "$dir/ctl/.git" ] || [ "${1:-}" = "-f" ]; then
echo -e "${CYAN}$(date '+%F %X') Clone the controller repository...${NC}"
shopt -s dotglob && rm -rf "$dir/ctl"/*
git clone --branch "$var_ctl_repo_branch" "$var_ctl_repo" "$dir/ctl"
else
echo -e "${CYAN}$(date '+%F %X') Pull the controller repository...${NC}"
git -C "$dir/ctl" pull
fi
env_main_dir="$dir/ctl/env-main"
if [ -z "$var_env_main_link_target" ]; then
if [ -L "$env_main_dir" ]; then
rm -f "$env_main_dir"
fi
mkdir "$env_main_dir"
else
if [ -d "$env_main_dir" ] && [ ! -L "$env_main_dir" ]; then
rm -rf "$env_main_dir"
fi
mkdir -p "$dir/$var_env_main_link_target"
ln -rsfT "$dir/$var_env_main_link_target" "$env_main_dir"
fi
echo -e "${CYAN}$(date '+%F %X') [start] Controller Setup...${NC}"
"$dir/ctl/run" setup "$var_env_repo"
echo -e "${CYAN}$(date '+%F %X') [end] Controller Setup${NC}"