#!/bin/bash # Define the folder containing scripts SCRIPT_DIR="/usr/local/bin" # Check if the directory exists if [[ ! -d "$SCRIPT_DIR" ]]; then echo "Directory $SCRIPT_DIR does not exist." exit 1 fi # Get the list of executable scripts SCRIPTS=($(find "$SCRIPT_DIR" -maxdepth 1 -type f -executable)) # Check if there are any scripts if [[ ${#SCRIPTS[@]} -eq 0 ]]; then whiptail --msgbox "No executable scripts found in $SCRIPT_DIR." 10 40 exit 0 fi # Prepare menu options MENU_OPTIONS=() for script in "${SCRIPTS[@]}"; do MENU_OPTIONS+=("$(basename "$script")" "$script") done # Show the menu using whiptail CHOICE=$(whiptail --title "Script Selector" --menu "Choose a script to run:" 15 50 5 "${MENU_OPTIONS[@]}" 3>&1 1>&2 2>&3) # Check if the user made a selection if [[ -n "$CHOICE" ]]; then SCRIPT_PATH="$SCRIPT_DIR/$CHOICE" whiptail --msgbox "Running: $SCRIPT_PATH" 10 40 "$SCRIPT_PATH" else whiptail --msgbox "No script selected." 10 40 fi