-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmuar.sh
executable file
·103 lines (77 loc) · 2.89 KB
/
gmuar.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
#!/bin/bash
preselect_flag=''
print_usage() {
printf "Usage: ..."
}
while getopts 'p' flag; do
case "${flag}" in
p) preselect_flag='true' ;;
*) print_usage
exit 1 ;;
esac
done
# imports
. util/ui_select_widget.sh
. util/checks.sh
. descriptions.sh
# now loop through the above array
for category in "${categories_arr[@]}"
do
# --------- START-----------------
PRESELECTED=""
declare -i avail_count=0
declare -A cat_descriptions
# check if any packages are already installed
for key in "${!gmu_packagenames[@]}"; do
if [[ ${gmu_categories[$key]} == $category ]];then
. "categories/$category/$key.sh"
"$key.is_installed" ${gmu_packagenames[$key]} $key
if [[ ${gmu_descriptions[$key]} != *"[INSTALLED]"* ]] && [[ -n "$preselect_flag" ]]; then
PRESELECTED="${PRESELECTED} $key"
fi
cat_descriptions[$key]=${gmu_descriptions[$key]}
avail_count=$((avail_count + 1))
fi
done
# if nothing to install, move to the next category
if (( avail_count < 1 )); then
echo -e "\nnothing to install in $category\n"
continue
fi
# finally the menu
echo -e "\n\n\e[4mSELECT THE [$category] PROGRAMS YOU WOULD LIKE TO INSTALL\e[24m\n\nuse SPACEBAR to '▣'select or '□'unselect. When you're done, click ENTER or press ESC to cancel.\n"
ui_widget_select -c -m -k "${!cat_descriptions[@]}" -s $PRESELECTED -i "${cat_descriptions[@]}"
if [[ ${UI_WIDGET_RC[@]} ]]; then
read -p "The above items have been selected for installation. Continue? Type [Y/y] to continue: " -n 1 -r
else
read -p "No items in category [$category] have been selected. Press any key to continue to the next category or ESC to exit the program" -n 1 -r
if [[ $REPLY =~ $'\e' ]];then
exit 0
else
unset cat_descriptions
continue
fi
fi
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Continuing installation of selected item(s)"
for key in "${UI_WIDGET_RC[@]}"; do
# import the script with the routine to execute. routines with .ub come from here
. "categories/$category/$key.sh"
# one more check if you want to continue installing something that has already been installed
DESCRIP="${cat_descriptions[$key]}"
if [[ $DESCRIP == *"[INSTALLED]"* ]] && continue_install "$DESCRIP"; then
echo -e "\nskipping install of $DESCRIP\n"; continue;
fi
# execute the .ub routine for ubuntu programs
"$key.ub"
unset cat_descriptions
done
else
echo "You need to type Y or y to continue. Exiting."
unset cat_descriptions
continue
fi
# --------- END-----------------
done