-
Notifications
You must be signed in to change notification settings - Fork 0
/
hal2.sh
executable file
·73 lines (59 loc) · 1.87 KB
/
hal2.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
#!/bin/bash
DEVMODE=0
if [ "$EUID" -ne 0 ]; then
echo "Please run script with sudo."
exit 1
fi
sudo apt update
sudo apt install git -y
read -p "Run Raspifresh installation ? (see https://github.com/urlab/raspifresh) [y/N]: " -n 1 -r reply
if [[ $reply =~ ^[Yy]$ ]]; then
echo "\nExecuting Raspifresh..."
git clone https://github.com/urlab/raspifresh.git
cd raspifresh
./fresh.sh
cd ..
rm -rf raspifresh
fi
if [[ -n $reply && ! $reply =~ ^[Nn]$ ]]; then
echo "\nInvalid input. Exiting..."
exit 1
fi
programs=($(ls ./programs/ | grep "\.sh"))
# Descriptor is commented in the second line of the file
declare -a programs_descriptors
for ((i = 0; i < ${#programs[@]}; i++)); do
programs_descriptors+=("$(sed '2q;d' ./programs/${programs[$i]} | sed 's/^.//')")
done
echo "Programs available to installation : "
for ((i = 0; i < ${#programs_descriptors[@]}; i++)); do
echo "$i) ${programs_descriptors[$i]}"
done
read -p "Enter program numbers to install (separated by space) [0]: " -r programs_to_install
if [ -z "$programs_to_install" ]; then
programs_to_install=0
fi
if [[ $programs_to_install =~ [^0-9\ ] ]]; then
echo "Invalid input. Exiting..."
exit 1
fi
if [[ $DEVMODE -eq 1 ]]; then
echo "Exiting because dev mode is on."
exit 0
fi
sudo apt update && sudo apt install -y curl docker.io docker-compose
sudo curl -SL https://github.com/docker/compose/releases/download/v2.30.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo usermod -aG docker $USER
if [[ $programs_to_install =~ "0" ]]; then
for ((i = 0; i < ${#programs[@]}; i++)); do
echo "Installing ${programs_descriptors[$i]}..."
./programs/${programs[$i]}
done
else
for i in $programs_to_install; do
echo "Installing ${programs_descriptors[$i]}..."
./programs/${programs[$i]}
done
fi