-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
120 lines (99 loc) · 2.51 KB
/
install
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
#!/bin/sh
reset='\033[0m' # Reset
red='\033[0;31m' # Red
green='\033[0;32m' # Green
yellow='\033[0;33m' # Yellow
purple='\033[0;35m' # Purple
if [ $# = 0 ]; then
echo
echo "${yellow}You must specify the options to execute.${reset}"
echo
echo "Example: ${purple}rpia${reset} --autologin=B2 --server=node --client=js --splash=off --chrome --smb --reboot"
echo
echo
exit 0
fi
clear
echo
echo "[${purple}Started${reset}] RPI Auto-Setup"
reboot=false
destroy=false
success=""
skipped=""
failed=""
# Root folder
root=~
# Setup folder
rpias=$root/rpia
# Modules folder
mods=$rpias/modules
# Disable Reboot
if [ -f "/sbin/reboot" ]; then
sudo mv /sbin/reboot /sbin/reboot.disabled
fi
# Iterate arguments
for arg in "$@"; do
key="${arg%%=*}"
value="${arg#*=}"
strip="${key#--}"
# Check if arg starts with --
if [ "$strip" != "$arg" ]; then
if [ -f "$mods/$strip/install" ]; then
echo
echo "[${green}Executing${reset}] $strip $value"
echo
sudo bash "$mods/$strip/install" $root $rpias $value
success="$success $arg"
elif [ -f "$mods/$strip-$value/install" ]; then
echo
echo "[${green}Executing${reset}] $strip $value"
echo
sudo bash "$mods/$strip-$value/install" $root $rpias $value
success="$success $arg"
else
if [ "$key" = "--reboot" ]; then
reboot=true
continue
fi
if [ "$key" = "--destroy" ]; then
destroy=true
continue
fi
echo
echo "[${red}Failed${reset}] Invalid arg: $arg"
skipped="$skipped $arg"
fi
else
echo
echo "[${red}Failed${reset}] Invalid arg: $arg"
echo
skipped="$skipped $arg"
fi
done
# Print Success
echo
echo "[${green}Completed${reset}] RPI Auto-Setup $(printf '%s ' "$success")"
echo
# Print Skipped
if [ "$skipped" != "" ]; then
echo "[${yellow}Skipped${reset}]: $(printf '%s ' "$skipped")"
echo
fi
# Print Failed
if [ "$failed" != "" ]; then
echo "[${red}Failed${reset}]: $(printf '%s ' "$failed")"
echo
fi
# Enable Reboot
if [ -f "/sbin/reboot.disabled" ]; then
sudo mv /sbin/reboot.disabled /sbin/reboot
fi
# Destroy files
if [ $destroy = true ]; then
sudo rm -rf $rpias
sudo rm -rf /usr/local/bin/rpia
fi
# Reboot device
if [ $reboot = true ]; then
sudo reboot
fi