Several Modifications

- Renamed Scripts to scripts.lst
- Script now restores tty configuration
- Removed xargs
- Removed install all option
master
Joca 2025-02-17 21:43:39 -03:00
parent 5aaacf72a0
commit 0facbea16a
Signed by: jocadbz
GPG Key ID: B1836DCE2F50BDF7
2 changed files with 19 additions and 24 deletions

View File

@ -81,6 +81,7 @@ fi
STAGE2_DIR="/opt/void-usb/installer/" # Change this to your desired directory
CONFIG_DIR="$STAGE2_DIR/custom-scripts"
SCRIPT_LIST="$CONFIG_DIR/scripts.lst"
SCRIPTS=()
NAMES=()
DESCRIPTIONS=()
@ -92,11 +93,11 @@ for script in "$CONFIG_DIR"/*.sh; do
SCRIPTS+=("$script")
# Extract name from "# NAME:" (first occurrence)
SCRIPT_NAME=$(grep -m1 '^# NAME:' "$script" | cut -d':' -f2- | xargs)
SCRIPT_NAME=$(grep -m1 '^# NAME:' "$script" | sed 's/^# NAME:[[:space:]]*//')
[ -z "$SCRIPT_NAME" ] && SCRIPT_NAME="$(basename "$script")"
# Extract description from "# DESC:" (first occurrence)
SCRIPT_DESC=$(grep -m1 '^# DESC:' "$script" | cut -d':' -f2- | xargs)
SCRIPT_DESC=$(grep -m1 '^# DESC:' "$script" | sed 's/^# DESC:[[:space:]]*//')
[ -z "$SCRIPT_DESC" ] && SCRIPT_DESC="No description available."
NAMES+=("$SCRIPT_NAME")
@ -112,36 +113,18 @@ fi
# Display menu dynamically
echo "Available configurations:"
for i in "${!SCRIPTS[@]}"; do
echo "$((i+1))) ${NAMES[i]}"
echo "$((i+1))) ${NAMES[i]} - ${DESCRIPTIONS[i]}"
done
echo "$(( ${#SCRIPTS[@]} + 1 ))) Install ALL"
echo "$(( ${#SCRIPTS[@]} + 2 ))) Exit"
echo "$(( ${#SCRIPTS[@]} + 1 ))) Exit"
# Get user input
read -p "Select an option (1-${#SCRIPTS[@]}): " choice
# Run selected script
if (( choice >= 1 && choice <= ${#SCRIPTS[@]} )); then
echo "------------------------------"
echo " **${NAMES[choice-1]}**"
echo " ${DESCRIPTIONS[choice-1]}"
echo "------------------------------"
read -p "Proceed? (y/N) " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
echo "Running: ${NAMES[choice-1]}"
bash "${SCRIPTS[choice-1]}"
else
echo "Cancelled."
fi
elif (( choice == ${#SCRIPTS[@]} + 1 )); then
echo "Running all scripts..."
for i in "${!SCRIPTS[@]}"; do
echo "------------------------------"
echo " **${NAMES[i]}**"
echo " ${DESCRIPTIONS[i]}"
echo "------------------------------"
bash "${SCRIPTS[i]}"
done
elif (( choice == ${#SCRIPTS[@]} + 2 )); then
echo "Exiting..."
exit 0
else
@ -149,4 +132,16 @@ else
exit 1
fi
# Stage 2 Tasks
echo "Setting up user..."
read -p "Enter username: " NEW_USER
useradd -m -G wheel "$NEW_USER"
passwd "$NEW_USER"
echo "Cleaning up installation files..."
rm -rf "$STAGE2_DIR"
echo "Restoring TTY1 configuration..."
mv /mnt/target/etc/sv/agetty-tty1/conf.bak /mnt/target/etc/sv/agetty-tty1/conf >> $LOGFILE 2>&1
bash --norc --noprofile