Update-ScriptBase
This commit is contained in:
parent
d6cc192188
commit
5ef14cace2
2 changed files with 23 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Directory containing scripts
|
# Define the folder containing scripts
|
||||||
SCRIPT_DIR="/usr/local/bin/flatpacks"
|
SCRIPT_DIR="/usr/local/bin/flatpacks"
|
||||||
|
|
||||||
# Check if the directory exists
|
# Check if the directory exists
|
||||||
|
@ -9,29 +9,35 @@ if [[ ! -d "$SCRIPT_DIR" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get list of scripts
|
# Get the list of executable scripts
|
||||||
SCRIPTS=($(ls "$SCRIPT_DIR"))
|
SCRIPTS=($(find "$SCRIPT_DIR" -maxdepth 1 -type f -executable))
|
||||||
|
|
||||||
# Check if there are any scripts
|
# Check if there are any scripts
|
||||||
if [[ ${#SCRIPTS[@]} -eq 0 ]]; then
|
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
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build menu options
|
# Prepare menu options
|
||||||
MENU_OPTIONS=()
|
MENU_OPTIONS=()
|
||||||
for SCRIPT in "${SCRIPTS[@]}"; do
|
declare -A SCRIPT_MAP
|
||||||
# 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')
|
for script in "${SCRIPTS[@]}"; do
|
||||||
MENU_OPTIONS+=("$SCRIPT" "$DISPLAY_NAME")
|
# 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
|
done
|
||||||
|
|
||||||
# Show menu with the new title
|
# Show the menu using whiptail 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)
|
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
|
# Check if the user made a selection
|
||||||
if [[ -n "$SELECTED_SCRIPT" ]]; then
|
if [[ -n "$CHOICE" ]]; then
|
||||||
bash "$SCRIPT_DIR/$SELECTED_SCRIPT"
|
SCRIPT_PATH="${SCRIPT_MAP[$CHOICE]}"
|
||||||
else
|
"$SCRIPT_PATH"
|
||||||
whiptail --msgbox "No script selected." 10 40
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,3 +8,4 @@ sudo git clean -f -d
|
||||||
sudo git pull
|
sudo git pull
|
||||||
echo "> Applying Execution Autorisation to *_*"
|
echo "> Applying Execution Autorisation to *_*"
|
||||||
sudo find /usr/local/bin -type f -name "[a-z]*" -exec chmod +x {} \;
|
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 {} \;
|
Loading…
Add table
Reference in a new issue