talvez funcione
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 22s

This commit is contained in:
2025-07-26 14:07:05 -03:00
parent 819816572e
commit 59213e254f

View File

@@ -105,10 +105,11 @@ fi
echo -e "${GREEN}[✓] Crontab is running.${NC}"
# Variables
declare -A FILES=(
["clean.sh"]="System cleanup script - Removes temporary files and logs"
["backup.sh"]="Backup script - Creates automated backups of important data"
["docker-updater.sh"]="Docker updater - Automatically updates Docker containers"
SCRIPTS=("clean.sh" "backup.sh" "docker-updater.sh")
DESCRIPTIONS=(
"System cleanup script - Removes temporary files and logs"
"Backup script - Creates automated backups of important data"
"Docker updater - Automatically updates Docker containers"
)
# Function to display available scripts
@@ -117,12 +118,15 @@ display_script_menu() {
echo -e "${LIGHT_BLUE}┌─────────────────────────────────────────────────────────────┐${NC}"
echo -e "${LIGHT_BLUE}│ Available Scripts for Installation │${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" \
"$index" "$script" "${FILES[$script]}"
((index++))
"$index" "$script" "$description"
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}Q.${NC} Quit ${GREY}Exit without installing anything${NC} ${LIGHT_BLUE}${NC}"
echo -e "${LIGHT_BLUE}└─────────────────────────────────────────────────────────────┘${NC}"
@@ -131,7 +135,6 @@ display_script_menu() {
# Function to get user selection
get_user_selection() {
local scripts_array=($(printf '%s\n' "${!FILES[@]}" | sort))
local selected_files=()
while true; do
@@ -150,7 +153,7 @@ get_user_selection() {
# Handle select all option
if [[ "$user_input" == "A" ]]; then
selected_files=("${scripts_array[@]}")
selected_files=("${SCRIPTS[@]}")
break
fi
@@ -159,9 +162,9 @@ get_user_selection() {
local valid_selection=true
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_name="${scripts_array[$script_index]}"
local script_name="${SCRIPTS[$script_index]}"
if [[ ! " ${selected_files[@]} " =~ " ${script_name} " ]]; then
selected_files+=("$script_name")
fi
@@ -187,7 +190,13 @@ get_user_selection() {
echo ""
echo -e "${GREEN}[✓] Selected scripts for installation:${NC}"
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
echo ""