-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·66 lines (57 loc) · 1.34 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
#!/bin/bash
#
# Select an enviornment to install onto.
set -e
set -u
readonly BASEDIR=$(dirname "$0")
source $BASEDIR/install/setup-mac.sh
source $BASEDIR/install/setup-linux.sh
source $BASEDIR/install/helpers/colors.sh
source $BASEDIR/install/helpers/handle-file.sh
main() {
while :; do
ask_for_env
done
}
ask_for_env() {
local readonly options=(
"Auto-Detect"
"Mac"
"Linux"
"Exit"
)
echo -e "${Cya}Which enviornment would you like to install onto?${RCol}"
select input in "${options[@]}"; do
case $input in
"${options[0]}" ) auto_detect; break;;
"${options[1]}" ) setup_mac; break;;
"${options[2]}" ) setup_linux; break;;
"${options[3]}" ) ask_if_sure; break;;
esac
done
}
ask_if_sure() {
local readonly options=(
"Heck Yes"
"Heck No"
)
echo -e "${Cya}Are you ${BCya}sure${Cya} you want to exit?${RCol}"
select input in "${options[@]}"; do
case $input in
"${options[0]}" ) echo "Goodbye friend"; exit 0;;
"${options[1]}" ) break;;
esac
done
}
auto_detect() {
if [ "$(uname)" == "Darwin" ]; then
echo -e "${Cya}Detected Mac OS${RCol}"
setup_mac
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
echo -e "${Cya}Detected Linux OS${RCol}"
setup_linux
else
>&2 echo -e "${Red}Failed to detect OS!${RCol}"
fi
}
main