-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathibramenu.sh
executable file
·94 lines (83 loc) · 1.76 KB
/
ibramenu.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
#!/bin/bash
######################################################################
# Title : IBRAMENU
# By : DiscDuck, Taos15
# License : General Public License GPL-3.0-or-later
# Another fine product brought to you by IBRACORP™
######################################################################
# Include ibrafunc for all the awesome functions
source /opt/ibracorp/ibramenu/ibrafunc.sh
# Functions
# Declare and fill the array
build_menu() {
for file in *; do
menu_choice=("${menu_choice[@]}" "$file")
done
}
# Build and display Menu
menu_from_array() {
declare -a menu_choice
PS3="Enter 1-$#, B for going back up a level or X for Exit: "
select item; do
case $REPLY in
x | X)
echo "Exiting..."
break
;;
b | B)
if [ "$PWD/" = $menu_entry_point ]; then
read -p "Already at Top Menu. Press enter to continue..."
break
else
cd ..
break
fi
;;
[1-$#])
if [ "${item:0:7}" = "Submenu" ]; then
cd "$item/"
break
else
execute_script
break
fi
;;
*)
echo "Not a valid choice"
;;
esac
done
}
# Execute the script from the folder
execute_script() {
msgbox "$item"
cd "$item"
readme
if [ $? = 0 ]; then
script_command="./$item.sh"
"$script_command"
read -p "Press enter to continue..."
fi
cd ..
}
# Define Variables
if [ $1 ]; then
menu_entry_point="$1"
else
menu_entry_point="/opt/ibracorp/ibramenu/MenuOptions/"
fi
cd "$menu_entry_point"
# Check Disclaimer
disclaimer
# Check Environment
environment_check
# IBRAMOTD
ibramotd
# Menu
until [ $REPLY = x ] || [ $REPLY = X ]; do
ibralogo
checkupdate
unset menu_choice
build_menu
menu_from_array "${menu_choice[@]}"
done