Update-ScriptBase

This commit is contained in:
Tyleo Dv. Delaware 2025-05-29 17:36:19 +02:00
parent d6cc192188
commit 5ef14cace2
2 changed files with 23 additions and 16 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash
# Directory containing scripts
# Define the folder containing scripts
SCRIPT_DIR="/usr/local/bin/flatpacks"
# Check if the directory exists
@ -9,29 +9,35 @@ if [[ ! -d "$SCRIPT_DIR" ]]; then
exit 1
fi
# Get list of scripts
SCRIPTS=($(ls "$SCRIPT_DIR"))
# 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 scripts found in $SCRIPT_DIR" 10 40
whiptail --msgbox "No executable scripts found in $SCRIPT_DIR." 10 40
exit 0
fi
# Build menu options
# Prepare menu options
MENU_OPTIONS=()
for SCRIPT in "${SCRIPTS[@]}"; do
# Remove underscores and capitalize first letter of each word
DISPLAY_NAME=$(echo "$SCRIPT" | sed 's/_/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1')
MENU_OPTIONS+=("$SCRIPT" "$DISPLAY_NAME")
declare -A SCRIPT_MAP
for script in "${SCRIPTS[@]}"; do
# Get base name, remove underscores, and capitalize first letter of each word
DISPLAY_NAME=$(basename "$script" | sed 's/_/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2)); print}')
# Exclude scripts with "Toolbox" in the name
if [[ "$DISPLAY_NAME" != *"Toolbox"* ]]; then
MENU_OPTIONS+=("$DISPLAY_NAME" "")
SCRIPT_MAP["$DISPLAY_NAME"]="$script"
fi
done
# Show menu with the new title
SELECTED_SCRIPT=$(whiptail --title "TyOS Flatpacks Selections" --noitem --menu "Choose a script to run:" 20 60 10 "${MENU_OPTIONS[@]}" 3>&1 1>&2 2>&3)
# Show the menu using whiptail with the new title
CHOICE=$(whiptail --title "TyOS Flatpacks Selections" --menu "Choose A Script To Run:" 15 50 5 "${MENU_OPTIONS[@]}" 3>&1 1>&2 2>&3)
# Check if a script was selected
if [[ -n "$SELECTED_SCRIPT" ]]; then
bash "$SCRIPT_DIR/$SELECTED_SCRIPT"
else
whiptail --msgbox "No script selected." 10 40
# Check if the user made a selection
if [[ -n "$CHOICE" ]]; then
SCRIPT_PATH="${SCRIPT_MAP[$CHOICE]}"
"$SCRIPT_PATH"
fi

View file

@ -8,3 +8,4 @@ sudo git clean -f -d
sudo git pull
echo "> Applying Execution Autorisation to *_*"
sudo find /usr/local/bin -type f -name "[a-z]*" -exec chmod +x {} \;
sudo find /usr/local/bin/flatpacks -type f -name "[a-z]*" -exec chmod +x {} \;