rolling back previous changes
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,121 +105,17 @@ fi
|
|||||||
echo -e "${GREEN}[✓] Crontab is running.${NC}"
|
echo -e "${GREEN}[✓] Crontab is running.${NC}"
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
SCRIPTS=("clean.sh" "backup.sh" "docker-updater.sh")
|
FILES=("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
|
# Prompt user to select files to download
|
||||||
display_script_menu() {
|
selected_files=()
|
||||||
echo ""
|
echo -e "${GREY}[i] Select files to download and install on crontab:${NC} "
|
||||||
echo -e "${LIGHT_BLUE}┌─────────────────────────────────────────────────────────────┐${NC}"
|
for FILE in "${FILES[@]}"; do
|
||||||
echo -e "${LIGHT_BLUE}│ Available Scripts for Installation │${NC}"
|
read -p "Do you want to download and install $FILE? [Y/n]: " choice </dev/tty
|
||||||
echo -e "${LIGHT_BLUE}├─────────────────────────────────────────────────────────────┤${NC}"
|
if [[ "$choice" == "y" || "$choice" == "Y" || -z "$choice" ]]; then
|
||||||
|
selected_files+=("$FILE")
|
||||||
for i in "${!SCRIPTS[@]}"; do
|
fi
|
||||||
local index=$((i + 1))
|
done
|
||||||
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"
|
|
||||||
|
|
||||||
if [ ${#selected_files[@]} -eq 0 ]; then
|
if [ ${#selected_files[@]} -eq 0 ]; then
|
||||||
echo -e "${RED}[x] No files selected. Exiting...${NC}"
|
echo -e "${RED}[x] No files selected. Exiting...${NC}"
|
||||||
|
Reference in New Issue
Block a user