From ccf59ce5217e437c91b64570e36fcb4b62867503 Mon Sep 17 00:00:00 2001 From: Jose Henrique Date: Sat, 26 Jul 2025 14:09:55 -0300 Subject: [PATCH] rolling back previous changes --- scripts-download.sh | 124 ++++---------------------------------------- 1 file changed, 10 insertions(+), 114 deletions(-) diff --git a/scripts-download.sh b/scripts-download.sh index a5f6050..225e8f6 100644 --- a/scripts-download.sh +++ b/scripts-download.sh @@ -105,121 +105,17 @@ fi echo -e "${GREEN}[✓] Crontab is running.${NC}" # Variables -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" -) +FILES=("clean.sh" "backup.sh" "docker-updater.sh") -# Function to display available scripts -display_script_menu() { - echo "" - echo -e "${LIGHT_BLUE}┌─────────────────────────────────────────────────────────────┐${NC}" - echo -e "${LIGHT_BLUE}│ Available Scripts for Installation │${NC}" - echo -e "${LIGHT_BLUE}├─────────────────────────────────────────────────────────────┤${NC}" - - 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" "$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}" - echo "" -} - -# Function to get user selection -get_user_selection() { - local selected_files=() - - while true; do - display_script_menu - echo -e "${GREY}[i] Enter your choice(s) separated by spaces (e.g., '1 3' or 'A' for all):${NC}" - read -p "Selection: " -r user_input - - # Convert to uppercase for easier processing - user_input=$(echo "$user_input" | tr '[:lower:]' '[:upper:]') - - # Handle quit option - if [[ "$user_input" == "Q" ]]; then - echo -e "${YELLOW}[!] Installation cancelled by user.${NC}" - exit 0 - fi - - # Handle select all option - if [[ "$user_input" == "A" ]]; then - selected_files=("${SCRIPTS[@]}") - break - fi - - # Process individual selections - selected_files=() - local valid_selection=true - - for choice in $user_input; do - if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#SCRIPTS[@]}" ]; then - local script_index=$((choice - 1)) - local script_name="${SCRIPTS[$script_index]}" - if [[ ! " ${selected_files[@]} " =~ " ${script_name} " ]]; then - selected_files+=("$script_name") - fi - else - echo -e "${RED}[x] Invalid selection: '$choice'. Please try again.${NC}" - valid_selection=false - break - fi - done - - if $valid_selection && [ ${#selected_files[@]} -gt 0 ]; then - break - elif $valid_selection; then - echo -e "${RED}[x] No valid scripts selected. Please try again.${NC}" - fi - - echo "" - read -p "Press Enter to continue..." -r - echo "" - done - - # Display selected scripts for confirmation - echo "" - echo -e "${GREEN}[✓] Selected scripts for installation:${NC}" - for script in "${selected_files[@]}"; do - # 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 "" - - # Confirmation prompt - while true; do - read -p "Continue with installation? [Y/n]: " -r confirm - case $confirm in - [Yy]*|"") break ;; - [Nn]*) - echo -e "${YELLOW}[!] Installation cancelled by user.${NC}" - exit 0 - ;; - *) echo -e "${RED}[x] Please answer Y or n.${NC}" ;; - esac - done - - echo "${selected_files[@]}" -} - -# Get user selection -echo -e "${GREY}[i] Script selection and installation setup...${NC}" -selected_files_result=$(get_user_selection) -read -a selected_files <<< "$selected_files_result" +# Prompt user to select files to download +selected_files=() +echo -e "${GREY}[i] Select files to download and install on crontab:${NC} " +for FILE in "${FILES[@]}"; do + read -p "Do you want to download and install $FILE? [Y/n]: " choice