-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·155 lines (117 loc) · 3.47 KB
/
install.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# Run: ./install.sh help
while [[ ! -d ./.git/ && ! -d ./files/ && ! -d ./src/ ]]; do
if [[ "$PWD" == "/" ]]; then
echo "Repository root not found"
exit 1
fi
if ! cd ..; then
echo "An error occurred while doing 'cd ..'"
exit 1
fi
done
source ./src/remotes/_vars_colors.sh
function install() {
echo -e "${fgcolor_white_bold}[Installer]: Running Backup script (~/.arturonavax-env-backups/)...${fgcolor_reset}"
./utils/backup_config.sh &>/dev/null || :
echo -e "${fgcolor_white_bold}[Installer]: Backup ready${fgcolor_reset}"
set -o errexit
trap exit-error-message ERR SIGINT
# check arguments
./src/remotes/usage_install.sh "$@"
# get arguments
for arg in "$@"; do
case "$arg" in
requirements | r) install_requirements=1 ;;
fonts | f) install_fonts=1 ;;
terminal | t) install_terminal=1 ;;
editor | e) install_editor=1 ;;
osconfig | o) install_osconfig=1 ;;
all | a) install_all=1 ;;
esac
done
[[ "$#" == 0 ]] && install_editor=1
if [[ "$install_all" == 1 ]]; then
install_requirements=1
install_fonts=1
install_terminal=1
install_editor=1
install_osconfig=1
fi
# ---
echo -en "$fgcolor_yellow_bold"
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `install.sh` has finished
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
echo -e "${fgcolor_white_bold}[Installer]: ${fgcolor_green_bold}Installation privileges obtained"
echo -en "$fgcolor_reset"
# installs requirements
if [[ "$install_requirements" == 1 ]]; then
./src/requirements/requirements.sh
source ./src/_install_requirements.sh
echo
fi
source ./src/remotes/_required_commands.sh
required-commands git
echo -e "${fgcolor_white_bold}[Installer]: Downloading the latest version of the repository...${fgcolor_reset}"
git pull origin main
echo
# check requireds install_fonts
if [[ "$install_fonts" == 1 ]]; then
required-commands curl
required-sudo-commands fc-cache
fi
# check requireds install_terminal
if [[ "$install_terminal" == 1 ]]; then
./src/requirements/terminal.sh
fi
# check requireds install_editor
if [[ "$install_editor" == 1 ]]; then
./src/requirements/editor.sh
fi
# ---
# installs
if [[ "$install_fonts" == 1 ]]; then
./src/remotes/install_fonts.sh
echo
fi
if [[ "$install_terminal" == 1 ]]; then
./src/install_terminal.sh
echo
fi
if [[ "$install_editor" == 1 ]]; then
./src/install_editor.sh
fi
if [[ "$install_osconfig" == 1 ]]; then
echo
echo -e "${fgcolor_white_bold}[Installer]: Applying system settings...${fgcolor_reset}"
if [[ "$(uname -s)" == "Linux" ]]; then
bash ./src/remotes/linux_osconfig.sh 2>/dev/null
elif [[ "$(uname -s)" == "Darwin" ]]; then
bash ./src/remotes/macos_osconfig.sh 2>/dev/null
fi
echo -e "${fgcolor_white_bold}[Installer]: ${fgcolor_green_bold}✔️ Applied configurations!${fgcolor_reset}"
fi
if [[ "$(uname -s)" == "Darwin" ]]; then
echo
echo -e "${fgcolor_white_bold}[Installer]: Homebrew cleanup...${fgcolor_reset}"
brew cleanup
echo -e "${fgcolor_white_bold}[Installer]: ${fgcolor_green_bold}✔️ Homebrew cleaned!${fgcolor_reset}"
fi
}
function exit-error-message() {
echo -e "$(
cat <<EOF
${fgcolor_white_bold}[Installer Error]: ---
[Installer Error]: ${fgcolor_red_bold}The installation had an error and was interrupted, the installation was not completed.${fgcolor_white_bold}
[Installer Error]: ---${fgcolor_reset}
EOF
)"
exit 1
}
install "$@"