talvez funcione
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 22s
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 22s
This commit is contained in:
@@ -105,10 +105,11 @@ fi
|
|||||||
echo -e "${GREEN}[✓] Crontab is running.${NC}"
|
echo -e "${GREEN}[✓] Crontab is running.${NC}"
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
declare -A FILES=(
|
SCRIPTS=("clean.sh" "backup.sh" "docker-updater.sh")
|
||||||
["clean.sh"]="System cleanup script - Removes temporary files and logs"
|
DESCRIPTIONS=(
|
||||||
["backup.sh"]="Backup script - Creates automated backups of important data"
|
"System cleanup script - Removes temporary files and logs"
|
||||||
["docker-updater.sh"]="Docker updater - Automatically updates Docker containers"
|
"Backup script - Creates automated backups of important data"
|
||||||
|
"Docker updater - Automatically updates Docker containers"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Function to display available scripts
|
# Function to display available scripts
|
||||||
@@ -117,12 +118,15 @@ display_script_menu() {
|
|||||||
echo -e "${LIGHT_BLUE}┌─────────────────────────────────────────────────────────────┐${NC}"
|
echo -e "${LIGHT_BLUE}┌─────────────────────────────────────────────────────────────┐${NC}"
|
||||||
echo -e "${LIGHT_BLUE}│ Available Scripts for Installation │${NC}"
|
echo -e "${LIGHT_BLUE}│ Available Scripts for Installation │${NC}"
|
||||||
echo -e "${LIGHT_BLUE}├─────────────────────────────────────────────────────────────┤${NC}"
|
echo -e "${LIGHT_BLUE}├─────────────────────────────────────────────────────────────┤${NC}"
|
||||||
local index=1
|
|
||||||
for script in "${!FILES[@]}"; do
|
for i in "${!SCRIPTS[@]}"; do
|
||||||
|
local index=$((i + 1))
|
||||||
|
local script="${SCRIPTS[$i]}"
|
||||||
|
local description="${DESCRIPTIONS[$i]}"
|
||||||
printf "${LIGHT_BLUE}│${NC} ${YELLOW}%d.${NC} %-15s ${GREY}%-35s${NC} ${LIGHT_BLUE}│${NC}\n" \
|
printf "${LIGHT_BLUE}│${NC} ${YELLOW}%d.${NC} %-15s ${GREY}%-35s${NC} ${LIGHT_BLUE}│${NC}\n" \
|
||||||
"$index" "$script" "${FILES[$script]}"
|
"$index" "$script" "$description"
|
||||||
((index++))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "${LIGHT_BLUE}│${NC} ${YELLOW}A.${NC} All scripts ${GREY}Install all available scripts${NC} ${LIGHT_BLUE}│${NC}"
|
echo -e "${LIGHT_BLUE}│${NC} ${YELLOW}A.${NC} All scripts ${GREY}Install all available scripts${NC} ${LIGHT_BLUE}│${NC}"
|
||||||
echo -e "${LIGHT_BLUE}│${NC} ${YELLOW}Q.${NC} Quit ${GREY}Exit without installing anything${NC} ${LIGHT_BLUE}│${NC}"
|
echo -e "${LIGHT_BLUE}│${NC} ${YELLOW}Q.${NC} Quit ${GREY}Exit without installing anything${NC} ${LIGHT_BLUE}│${NC}"
|
||||||
echo -e "${LIGHT_BLUE}└─────────────────────────────────────────────────────────────┘${NC}"
|
echo -e "${LIGHT_BLUE}└─────────────────────────────────────────────────────────────┘${NC}"
|
||||||
@@ -131,7 +135,6 @@ display_script_menu() {
|
|||||||
|
|
||||||
# Function to get user selection
|
# Function to get user selection
|
||||||
get_user_selection() {
|
get_user_selection() {
|
||||||
local scripts_array=($(printf '%s\n' "${!FILES[@]}" | sort))
|
|
||||||
local selected_files=()
|
local selected_files=()
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
@@ -150,7 +153,7 @@ get_user_selection() {
|
|||||||
|
|
||||||
# Handle select all option
|
# Handle select all option
|
||||||
if [[ "$user_input" == "A" ]]; then
|
if [[ "$user_input" == "A" ]]; then
|
||||||
selected_files=("${scripts_array[@]}")
|
selected_files=("${SCRIPTS[@]}")
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -159,9 +162,9 @@ get_user_selection() {
|
|||||||
local valid_selection=true
|
local valid_selection=true
|
||||||
|
|
||||||
for choice in $user_input; do
|
for choice in $user_input; do
|
||||||
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#scripts_array[@]}" ]; then
|
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#SCRIPTS[@]}" ]; then
|
||||||
local script_index=$((choice - 1))
|
local script_index=$((choice - 1))
|
||||||
local script_name="${scripts_array[$script_index]}"
|
local script_name="${SCRIPTS[$script_index]}"
|
||||||
if [[ ! " ${selected_files[@]} " =~ " ${script_name} " ]]; then
|
if [[ ! " ${selected_files[@]} " =~ " ${script_name} " ]]; then
|
||||||
selected_files+=("$script_name")
|
selected_files+=("$script_name")
|
||||||
fi
|
fi
|
||||||
@@ -187,7 +190,13 @@ get_user_selection() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}[✓] Selected scripts for installation:${NC}"
|
echo -e "${GREEN}[✓] Selected scripts for installation:${NC}"
|
||||||
for script in "${selected_files[@]}"; do
|
for script in "${selected_files[@]}"; do
|
||||||
echo -e " ${YELLOW}•${NC} $script - ${GREY}${FILES[$script]}${NC}"
|
# Find the description for this script
|
||||||
|
for i in "${!SCRIPTS[@]}"; do
|
||||||
|
if [[ "${SCRIPTS[$i]}" == "$script" ]]; then
|
||||||
|
echo -e " ${YELLOW}•${NC} $script - ${GREY}${DESCRIPTIONS[$i]}${NC}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user