-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_utility.sh
executable file
·188 lines (167 loc) · 4.37 KB
/
setup_utility.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
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
#!/bin/bash
bold=$(tput bold)
normal=$(tput sgr0)
blink=$(tput blink)
red='\033[0;31m'
green='\033[0;32m'
light=$(echo $PROFILES | grep COLORSCHEME_LIGHT)
if [ -z "$light" ]
then
export NEWT_COLORS='
root=brightgreen,black
border=brightgreen,black
title=brightgreen,black
roottext=white,black
window=brightgreen,black
textbox=white,black
button=black,brightgreen
compactbutton=white,black
listbox=white,black
actlistbox=black,white
actsellistbox=black,brightgreen
checkbox=brightgreen,black
actcheckbox=black,brightgreen
entry=black,brightgreen
'
else
export NEWT_COLORS='
root=green,white
border=green,white
title=green,white
roottext=black,white
window=green,white
textbox=black,white
button=white,green
compactbutton=black,white
listbox=black,white
actlistbox=black,white
actsellistbox=white,green
checkbox=green,white
actcheckbox=white,green
entry=white,green
'
fi
# export NEWT_COLORS='
# root=brightgreen,black
# border=brightgreen,black
# title=brightgreen,black
# roottext=white,black
# window=brightgreen,black
# textbox=white,black
# button=black,brightgreen
# compactbutton=white,black
# listbox=white,black
# actlistbox=black,white
# actsellistbox=black,brightgreen
# checkbox=brightgreen,black
# actcheckbox=black,brightgreen
# entry=black,brightgreen
# '
# root=white,black
# border=black,lightgray
# window=lightgray,lightgray
# shadow=black,gray
# title=black,lightgray
# button=black,cyan
# actbutton=white,cyan
# compactbutton=black,lightgray
# checkbox=black,lightgray
# actcheckbox=lightgray,cyan
# entry=black,lightgray
# disentry=gray,lightgray
# label=black,lightgray
# listbox=black,lightgray
# actlistbox=black,cyan
# sellistbox=lightgray,black
# actsellistbox=lightgray,black
# textbox=black,lightgray
# acttextbox=black,cyan
# emptyscale=,gray
# fullscale=,cyan
# helpline=white,black
# roottext=lightgrey,black
# Specify the folder path where your files are located
DIR="$(dirname "$(readlink -f "$0")")"
folder_path=""
first_run=true
if [ -z "$1" ]
then
folder_path="$DIR/subscripts"
sudo chmod -R +x "$DIR/subscripts"
sudo chmod -R -x "$DIR/subscripts/7Udev_rules/DISREGARD_udev_rules"
sudo chmod +x "$DIR/subscripts/7Udev_rules/DISREGARD_udev_rules"
else
folder_path="$1"
first_run=false
fi
# Create an array to store filenames
OPTIONS=()
FULL_FILEPATHS=()
show_menu() {
whiptail --title "MRS UAV System Install Utility" --menu "Choose an option:" 0 0 0 "${OPTIONS[@]}" 3>&1 1>&2 2>&3
}
main() {
while true; do
clear
choice=$(show_menu)
if [ $? -eq 0 ]; then
echo ${FULL_FILEPATHS[$((choice - 1))]}
# ${FULL_FILEPATHS[$((choice - 1))]}
if [[ -d ${FULL_FILEPATHS[$((choice - 1))]} ]]; then
echo "is a directory"
./$0 ${FULL_FILEPATHS[$((choice - 1))]} #Run this script again but in the selected folder
else
${FULL_FILEPATHS[$((choice - 1))]}
fi
if [ $? -eq 0 ]; then
read -p "${blink}${bold}Hit enter to continue ...${normal}"
fi
else
# echo "Menu canceled."
exit 1
fi
done
}
# Read filenames from the folder and populate the array
index="1"
for file in "$folder_path"/*; do
# Add each filename to the array
disregard=$(echo $file | grep "DISREGARD")
if [ ! -z "$disregard" ]
then
continue
fi
OPTIONS+=("$index")
let "index++"
filename="${file##*"/"}"
filename="${filename%.*}"
filename="${filename//_/ }"
filename="${filename#[[:digit:]]}" #removes the first digit from script name
if [[ -d ${file} ]]; then
OPTIONS+=("$filename ...")
else
OPTIONS+=("$filename")
fi
FULL_FILEPATHS+=("$file")
done
if [ "$first_run" = true ] ; then
#Check connection to the internet
wget -q --spider http://google.com
if [ $? -eq 0 ]; then
echo -e "${green}Online${normal}"
sudo apt update
else
echo -e "${red}${bold}You are not connected to the internet!${normal} (No response from google.com)"
echo -e "${red}${bold}You will not be to install/update any new software!${normal}"
echo -e "${red}${bold}You can however still use some of the configuration scripts${normal}"
read -p "${blink}${bold}Hit enter to continue ...${normal}"
fi
#Check for whiptail
whiptail_installed=$(apt-cache policy whiptail | grep Installed | grep none)
if [ ! -z "$whiptail_installed" ]
then
echo "Whiptail NOT installed, will install now:"
sudo apt install whiptail
fi
fi
main