Repository navigation
Expand file tree
/
Copy pathsetup_utility.sh
More file actions
executable file
·208 lines (183 loc) · 5.35 KB
/
Copy pathsetup_utility.sh
File metadata and controls
executable file
·208 lines (183 loc) · 5.35 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
#!/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
export NON_INTERACTIVE_MODE=0
# 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"
# Make all .sh files in the subscripts folder executable
find "$folder_path" -type f -name "*.sh" -exec chmod +x {} \;
else
folder_path="$1"
first_run=false
fi
# Create an array to store filenames
OPTIONS=()
FULL_FILEPATHS=()
show_main_menu() {
whiptail --title "F4F Install Utility" --menu "Choose an option:" 0 0 0 "${OPTIONS[@]}" 3>&1 1>&2 2>&3
}
main() {
while true; do
clear
choice=$(show_main_menu)
if [ $? -eq 0 ]; then
if [[ -d "${FULL_FILEPATHS[$((choice - 1))]}" ]]; then
"$DIR/$(basename "$0")" "${FULL_FILEPATHS[$((choice - 1))]}" # Run this script again but in the selected folder
else
"${FULL_FILEPATHS[$((choice - 1))]}"
# Check the exit status of the script that was run
if [ $? -ne 0 ]; then
# If the exit status is not 0, then there was an error, stop the wizard and wait for user input before continuing
read -p "${blink}${bold}Press enter to continue ...${normal}"
fi
fi
else
# If the user pressed Cancel or Esc, exit the script
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
echo "Checking internet connection..."
wget -q --spider http://google.com
if [ $? -eq 0 ]; then
echo -e "${green}Online${normal}"
# Check if apt update was already successfully ran in the last 60 minutes and if so, do not run it again
if [ -f /var/lib/apt/periodic/update-success-stamp ]; then
last_update=$(stat -c %Y /var/lib/apt/periodic/update-success-stamp)
now=$(date +%s)
if [ $((now - last_update)) -lt 3600 ]; then
echo "Apt update was already successfully ran in the last 60 minutes, not running it again"
else
sudo apt-get update
fi
else
sudo apt-get update
fi
if ! command -v git &>/dev/null; then
echo "Git is not installed. Installing git..."
sudo apt-get install -y git
fi
if ! git -C "$DIR" diff --quiet || ! git -C "$DIR" diff --cached --quiet; then
echo "Error: Local changes detected. Commit or stash your changes before pulling."
exit 1
fi
git -C "$DIR" pull
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}Press 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-get install -y whiptail
fi
fi
main