-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
executable file
·121 lines (110 loc) · 2.79 KB
/
setup.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
#!/bin/bash
set -e
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
# shellcheck disable=SC2091
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
cd -P "$( dirname "$SOURCE" )"
pwd
}
select_role() {
local role=$1
case "$role" in
"Backend developer")
ANSIBLE_OPTS="$ANSIBLE_OPTS --tags=backend_dev"
;;
"Frontend developer")
ANSIBLE_OPTS="$ANSIBLE_OPTS --tags=frontend_dev"
;;
"Algorithms developer")
ANSIBLE_OPTS="$ANSIBLE_OPTS --tags=algorithms_dev"
;;
"System administrator")
ANSIBLE_OPTS="$ANSIBLE_OPTS --tags=sysadmin"
;;
"All")
;;
*)
echo invalid option
exit 1
;;
esac
}
perform_install() {
local install=$1
local ANSIBLE_PLAYBOOK="ansible-playbook --ask-become-pass"
# Do not ask password on CircleCI
if [ "$CIRCLECI" = true ]; then
local ANSIBLE_PLAYBOOK="ansible-playbook"
fi
case "$install" in
"Standard")
# shellcheck disable=SC2086
$ANSIBLE_PLAYBOOK -i envs/local/etc/ansible/ \
-e play_dir="$(pwd)" \
-e lib_roles_path="$(pwd)/roles" \
$ANSIBLE_OPTS $SETUP_OPTS setup.yml
;;
"Hipster")
# shellcheck disable=SC2086
$ANSIBLE_PLAYBOOK -i envs/local/etc/ansible/ \
-e play_dir="$(pwd)" \
-e lib_roles_path="$(pwd)/roles" \
$ANSIBLE_OPTS hipster-setup.yml
;;
*)
echo invalid option
exit 1
;;
esac
}
cd "$(get_script_dir)"
./common/scripts/bootstrap.sh --skip-git-crypt
[ -d roles/docker/tasks ] || ./after-git-clone.sh
role=$1
if [ -z "$role" ]; then
PS3='Select your role: '
options=("Backend developer" "Frontend developer" "Algorithms developer" "System administrator" "All")
select role in "${options[@]}";
do
select_role "$role"
break
done
else
shift
select_role "$role"
fi
install=$1
if [ -n "$1" ]; then
shift
fi
SETUP_OPTS="--skip-tags=virtualbox"
if [ "$1" == "skip_docker" ]; then
SETUP_OPTS="$SETUP_OPTS,docker"
shift
fi
if [ "$1" == "skip_yed" ]; then
SETUP_OPTS="$SETUP_OPTS,yed"
shift
fi
remaining_opts="$*"
ANSIBLE_OPTS=${ANSIBLE_OPTS:-"$remaining_opts"}
ANSIBLE_OPTS="-e user=$USER -e user_home=$HOME $ANSIBLE_OPTS -e play_dir=$(pwd) $ANSIBLE_OPTS"
if [ "$CIRCLECI" ]; then
ANSIBLE_OPTS="$ANSIBLE_OPTS -e desktop_icon=false"
fi
if [ -z "$install" ]; then
PS3='Installation type: '
install_options=("Standard" "Hipster")
select install in "${install_options[@]}";
do
perform_install "$install"
break
done
else
perform_install "$install"
fi