-
Notifications
You must be signed in to change notification settings - Fork 1
/
quick-run.sh
84 lines (69 loc) · 2.94 KB
/
quick-run.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
#!/bin/bash
# ██ ██ █████ ██████ ██████ ██ ██ ██ ██████ ███████ ██ ██ ███████ ██████ ███████
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██
# ███████ ███████ ██████ ██████ ██ ██ █ ██ ██ ██ ███ ███████ █████ ██████ █████
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███ ██████ ███████ ██ ██ ███████ ██ ██ ███████
# Quick Run Script -- Debian Linux
# Last Updated [03-03-2024]
# Designed to be curled and other scripts can be run from it from the repo
# Check if the script is running as root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
# OS Check
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
fi
# Install git and dialog using OS package manager (Debian based and RHEL Based only)
if [ "$OS" = "Debian GNU/Linux" ] || [ "$OS" = "Ubuntu" ]; then
apt update && apt install -y sudo curl git dialog
else
echo "OS not supported"
exit 1
fi
# Clone the repo to /opt
git clone https://github.com/ao554/harrilabstuff.git /opt/harrilabstuff
# If Repository is already cloned, pull the latest
if [ -d /opt/harrilabstuff ]; then
cd /opt/harrilabstuff
git pull
fi
# Change directory to the repo
cd /opt/harrilabstuff
# Using OS Check, cd to the correct directory
if [ "$OS" = "Debian GNU/Linux" ] || [ "$OS" = "Ubuntu" ]; then
cd Debian
else
echo "OS not supported"
exit 1
fi
# Collect list of available scripts for dialog into an array
scripts=(*.sh)
# Create a menu items array
menu_items=()
for i in "${!scripts[@]}"; do
menu_items+=("$i" "${scripts[$i]}")
done
# Run dialog to give options to run other scripts
dialog --title "Select a script to run" \
--menu "Choose one of the following options:" 15 40 4 \
"${menu_items[@]}" 2> /tmp/selection
# Check the exit status of dialog
if [ $? -eq 0 ]; then
# Run the selected script
bash "${scripts[$(cat /tmp/selection)]}"
else
# Exit the script if cancel was pressed
echo "Scripts are located at /opt/harrilabstuff"
exit 0
fi
# return to the previous dialog after the script has finished
if [ $? -eq 0 ]; then
bash /opt/harrilabstuff/quick-run.sh
fi
# Clean up
exit 0