-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL
executable file
·80 lines (65 loc) · 2.06 KB
/
INSTALL
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
#!/usr/bin/env bash
print_divider_pre() {
echo " "
echo " "
echo "==============================================="
}
print_divider_post() {
echo "==============================================="
echo " "
echo " "
}
print_user_selected() {
echo "User selected items:"
for item in "${selected_items[@]}"; do
echo "- $item"
done
}
install_all() {
print_divider_pre
echo "Executing: install_all.sh"
bash "install_all.sh"
print_divider_post
exit 0
}
# Find all 'install.sh' files and record their parent folder names
install_scripts=($(find . -name "install.sh" -exec dirname {} \;))
# Initialize an empty array to store user-selected items
selected_items=()
# Loop to let the user select items until they choose to quit
while true; do
# Display the list of parent folders
print_divider_pre
echo "Available install.sh scripts:"
for ((i=0; i<${#install_scripts[@]}; i++)); do
echo "[$((i+1))] ${install_scripts[i]}"
done
print_user_selected
print_divider_post
read -p "Enter the number of the script to select (or 'quit' to exit): " choice
# Check if the user wants to quit
if [ "$choice" == "quit" ]; then
break
fi
# Check if the user wants to install all
if [ "$choice" == "all" ]; then
install_all
break
fi
# Validate the user input
if [[ ! "$choice" =~ ^[0-9]+$ || "$choice" -lt 1 || "$choice" -gt ${#install_scripts[@]} ]]; then
echo "Invalid input. Please enter a valid number or 'quit' to exit or 'all' install all of them."
continue
fi
# Add the selected item to the list
selected_items+=("${install_scripts[choice-1]}")
echo "Selected: ${install_scripts[choice-1]}"
done
# Execute 'install.sh' in each selected folder
for item in "${selected_items[@]}"; do
print_divider_pre
echo "Executing $item/install.sh"
bash "$item/install.sh"
print_divider_post
done
echo "Script execution complete."