-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·335 lines (249 loc) · 8.56 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·335 lines (249 loc) · 8.56 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/usr/bin/env bash
set -e # exit when any command fails
# shellcheck disable=SC1091
source ./scripts/general/colors.sh
if [ "$1" == "AUTOINSTALL" ]; then
export CATAPULT_AUTOINSTALL=true
export MAKEVAR_AUTO_UPDATE=1
else
export CATAPULT_AUTOINSTALL=false
fi
# Check if script is run with sudo
if [ $EUID -eq 0 ]; then
echo -e "${C_RED}"
echo -e "Don't run this script with sudo, it will ask for sudo password when needed."
read -rp $'\n'"Press Ctrl + C to cancel or Press ENTER to continue..."
echo -e "${C_RST}"
else
# This is to ask sudo password only once at the beginning of the script
sudo -S echo -n ""
fi
# Creating .makerc-personal file if it doesn't exist
if [[ ! -f personal/.makerc-personal ]]; then
echo -n -e "${C_YELLOW}"
echo -e "Creating personal/.makerc-personal file"
echo -n -e "${C_RST}"
mkdir -p personal
touch personal/.makerc-personal
fi
#########
# MacOS #
#########
if [[ $(uname) == "Darwin" ]]; then
echo -n -e "${C_YELLOW}"
echo -e "Removing MacOS sudo requirement for Catapult on MacOS..."
echo -e "${C_RST}"
if grep -q "MAKEVAR_SUDO_COMMAND" personal/.makerc-personal; then
sed -i "" "s#MAKEVAR_SUDO_COMMAND.*#MAKEVAR_SUDO_COMMAND :=#" personal/.makerc-personal
else
echo "MAKEVAR_SUDO_COMMAND :=" >> personal/.makerc-personal
fi
brew-install() {
echo -n -e "${C_YELLOW}"
echo -e "Installing Homebrew..."
echo -n -e "${C_RST}"
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [[ -x "/usr/local/bin/brew" ]]; then
eval "$(/usr/local/bin/brew shellenv)" # Intel Macs
elif [[ -x "/opt/homebrew/bin/brew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)" # Apple Silicon Macs
else
echo -n -e "${C_RED}"
echo -e "Homebrew not found in default path after installation."
echo -e "Trying to locate Homebrew with $(command -v brew) later"
echo -n -e "${C_RST}"
fi
}
brew-packages-install() {
if [[ -x "$(command -v brew)" ]]; then
echo -n -e "${C_YELLOW}"
echo -e "Installing MacOS packages with homebrew..."
echo -n -e "${C_RST}"
# shellcheck disable=SC2086
$(command -v brew) install $PACKAGES
else
echo -n -e "${C_RED}"
echo -e "Homebrew not installed, cannot install:"
echo -e "$PACKAGES"
echo -n -e "${C_RST}"
exit 0
fi
}
PACKAGES="git git-lfs make jq curl md5sha1sum"
echo -n -e "${C_YELLOW}"
echo -e "Installing homebrew?"
echo
if [[ "$CATAPULT_AUTOINSTALL" == true ]]; then
brew-install
brew-packages-install
else
options=(
"Yes"
"No"
)
select _ in "${options[@]}"; do
case "$REPLY" in
yes|y|1) brew-install; break;;
no|n|2) read -rp $'\n'"If you don't install homebrew you'll need to install Docker manually - Press ENTER to continue"$'\n'; break;;
esac
done
echo -n -e "${C_GREEN}"
echo -e "Installing following packages with homebrew:"
echo -e "$PACKAGES"
echo
options=(
"Yes"
"No, I'll install these packages myself"
)
select _ in "${options[@]}"; do
case "$REPLY" in
yes|y|1) brew-packages-install; break;;
no|n|2) read -rp $'\n'"Make sure $PACKAGES are installed - Press ENTER to continue"$'\n'; break;;
esac
done
fi
echo -e "${C_RST}"
fi
#########
# Linux #
#########
if [[ $(uname) == "Linux" ]]; then
if ! [ -x "$(command -v sudo)" ]; then
echo -e "${C_RED}"
echo -e "sudo is not installed, install it and run this script again."
echo -e "${C_RST}"
exit 0
fi
###################
# Debian based OS #
###################
if grep -q "debian" /etc/os-release; then
PACKAGES="git git-lfs make jq curl sudo gpg ssh"
debian-packages-install() {
echo -n -e "${C_YELLOW}"
echo -e "Installing required deb packages..."
echo -n -e "${C_RST}"
sudo apt-get update
# shellcheck disable=SC2068,SC2086
sudo apt-get install $PACKAGES -y
if [ -n "$WSL_DISTRO_NAME" ]; then
sudo apt-get install keychain -y
fi
}
echo -e "${C_GREEN}"
echo -e "Installing following packages:"
echo -e "$PACKAGES"
echo
if [[ "$CATAPULT_AUTOINSTALL" == true ]]; then
debian-packages-install
else
options=(
"Yes"
"No, I'll install these packages myself"
)
select _ in "${options[@]}"; do
case "$REPLY" in
yes|y|1) debian-packages-install; break;;
no|n|2) read -rp $'\n'"Make sure ${PACKAGES} are installed - Press ENTER to continue"$'\n'; break;;
esac
done
fi
#############
# Archlinux #
#############
elif grep -q "arch" /etc/os-release; then
PACKAGES="git git-lfs make jq curl sudo"
arch-packages-install() {
echo -n -e "${C_YELLOW}"
echo -e "Installing required pacman packages..."
echo -n -e "${C_RST}"
# shellcheck disable=SC2086
sudo pacman -S $PACKAGES --noconfirm
}
echo -e "${C_GREEN}"
echo -e "Installing following packages:"
echo -e "$PACKAGES"
echo -e
if [[ "$CATAPULT_AUTOINSTALL" == true ]]; then
arch-packages-install
else
options=(
"Yes"
"No, I'll install these packages myself"
)
select _ in "${options[@]}"; do
case "$REPLY" in
yes|y|1) arch-packages-install; break;;
no|n|2) read -rp $'\n'"Make sure $PACKAGES are installed - Press ENTER to continue"$'\n'; break;;
esac
done
fi
###################
# RedHat based OS #
###################
elif grep -q -E "(rhel|fedora)" /etc/os-release; then
PACKAGES="git git-lfs make jq curl sudo gpg openssh-server dnf-plugins-core"
rhel-packages-install() {
echo -n -e "${C_YELLOW}"
echo -e "Installing required rhel packages..."
echo -n -e "${C_RST}"
sudo dnf makecache
# shellcheck disable=SC2086
sudo dnf install $PACKAGES -y
}
echo -e "${C_GREEN}"
echo -e "Installing following packages:"
echo -e "$PACKAGES"
echo
if [[ "$CATAPULT_AUTOINSTALL" == true ]]; then
rhel-packages-install
else
options=(
"Yes"
"No, I'll install these packages myself"
)
select _ in "${options[@]}"; do
case "$REPLY" in
yes|y|1) rhel-packages-install; break;;
no|n|2) read -rp $'\n'"Make sure $PACKAGES are installed - Press ENTER to continue"$'\n'; break;;
esac
done
fi
#########
# Other #
#########
else
OS_VERSION=$(grep "^ID=" /etc/os-release | cut -d "=" -f2)
PACKAGES="git git-lfs make jq curl sudo gpg ssh"
PACKAGES_LFS="git lfs install"
echo -e "${C_RED}"
echo -e "You are using unsupported or untested (Linux) operating system - ${C_CYAN}${OS_VERSION}${C_RED}. Catapult may still work if you configure it manually"
echo -e
echo -e "You'll need to follow these steps:"
echo -e
echo -e "1) Install following packages (The names might be different for your OS): ${C_YELLOW}$PACKAGES${C_RED}"
echo -e "2) Initialize git LFS with: ${C_YELLOW}$PACKAGES_LFS${C_RED}"
echo -e
read -rp $'\n'"Once you have installed the required packages press any key to continue..."$'\n'
fi
echo -e "${C_RST}"
fi
echo -n -e "${C_YELLOW}"
echo "Configuring githooks & LFS..."
echo -n -e "${C_RST}"
touch ~/.gitconfig
git config core.hooksPath .githooks
git lfs install
if [[ $(uname) == "Darwin" ]]; then
# Installing Docker without sudo for MacOS
scripts/general/configure-docker.sh $CATAPULT_AUTOINSTALL
else
# Installing Docker with sudo for non-MacOS
sudo scripts/general/configure-docker.sh $CATAPULT_AUTOINSTALL
fi
# Print the message to the user
make help
echo -ne "${C_GREEN}"
echo -e "Preparations finished successfully"
echo -e "Run ${C_CYAN}make start${C_GREEN} to start and configure Catapult"
echo -ne "${C_RST}"