diff --git a/custom-scripts/i3wm.sh b/custom-scripts/i3wm.sh new file mode 100644 index 0000000..77a21bf --- /dev/null +++ b/custom-scripts/i3wm.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# NAME: Install i3wm +# DESC: This script installs i3wm and basic utilities. + + echo "Updating Void" + xbps-install -Suv + xbps-install -S + + +echo -e "Installing i3wm" + +xbps-install -S xinit xorg base-devel i3 i3status i3-gaps termite diff --git a/custom-scripts/readme.md b/custom-scripts/readme.md new file mode 100644 index 0000000..16e65e3 --- /dev/null +++ b/custom-scripts/readme.md @@ -0,0 +1,18 @@ + +### Configuration Scripts + +Use this to Deploy rices/set up services/etc. + +Each configuration script should follow this structure: + +```bash +#!/bin/bash +# NAME: Your Script Name +# DESC: A brief description of what the script does. + +# Your script logic here +``` + +If NAME and DESC are not found, the script will default to the script's filename. + +Place the scripts under this folder, add the filename to `scripts` (Separate by newline) and they will show up on the installer. \ No newline at end of file diff --git a/custom-scripts/scripts b/custom-scripts/scripts new file mode 100644 index 0000000..fb5255a --- /dev/null +++ b/custom-scripts/scripts @@ -0,0 +1 @@ +i3wm.sh \ No newline at end of file diff --git a/install-stage1.sh b/install-stage1.sh index 73f37cc..9962911 100644 --- a/install-stage1.sh +++ b/install-stage1.sh @@ -414,6 +414,26 @@ function get_stage2_file { get_stage2_file install-stage2.sh >> $LOGFILE 2>&1 chmod 744 "$STAGE2_DIR/install-stage2.sh" >> $LOGFILE 2>&1 +function download_scripts { + local scripts_file="$1" + + # Read the scripts file line by line + while IFS= read -r script; do + # Call the function to download each script + get_stage2_file "custom-scripts/$script" + done < "$scripts_file" +} + +# Create the custom-scripts directory +CUSTOM_SCRIPTS_DIR="$STAGE2_DIR/custom-scripts" +mkdir -p "$CUSTOM_SCRIPTS_DIR" + +# Download the scripts file into the custom-scripts folder +SCRIPTS_FILE="scripts" # The name of the scripts file in the custom-scripts folder +get_stage2_file "custom-scripts/$SCRIPTS_FILE" + +download_scripts "$CUSTOM_SCRIPTS_DIR/$SCRIPTS_FILE" + mv /mnt/target/etc/sv/agetty-tty1/conf /mnt/target/etc/sv/agetty-tty1/conf.bak >> $LOGFILE 2>&1 echo 'if [ -x /sbin/agetty -o -x /bin/agetty ]; then if [ "${tty}" = "tty1" ]; then diff --git a/install-stage2.sh b/install-stage2.sh index e52d2c2..109e64b 100644 --- a/install-stage2.sh +++ b/install-stage2.sh @@ -78,4 +78,75 @@ if [ "$INTERNET" = "up" ]; then echo "done" fi + +STAGE2_DIR="/opt/void-usb/installer/" # Change this to your desired directory +CONFIG_DIR="$STAGE2_DIR/custom-scripts" +SCRIPTS=() +NAMES=() +DESCRIPTIONS=() + +# Find all scripts and extract their names & descriptions +echo "Scanning for configuration scripts in $CONFIG_DIR..." +for script in "$CONFIG_DIR"/*.sh; do + [ -f "$script" ] || continue # Skip if no .sh files found + SCRIPTS+=("$script") + + # Extract name from "# NAME:" (first occurrence) + SCRIPT_NAME=$(grep -m1 '^# NAME:' "$script" | cut -d':' -f2- | xargs) + [ -z "$SCRIPT_NAME" ] && SCRIPT_NAME="$(basename "$script")" + + # Extract description from "# DESC:" (first occurrence) + SCRIPT_DESC=$(grep -m1 '^# DESC:' "$script" | cut -d':' -f2- | xargs) + [ -z "$SCRIPT_DESC" ] && SCRIPT_DESC="No description available." + + NAMES+=("$SCRIPT_NAME") + DESCRIPTIONS+=("$SCRIPT_DESC") +done + +# Check if no scripts were found +if [ ${#SCRIPTS[@]} -eq 0 ]; then + echo "No configuration scripts found in $CONFIG_DIR." + exit 1 +fi + +# Display menu dynamically +echo "Available configurations:" +for i in "${!SCRIPTS[@]}"; do + echo "$((i+1))) ${NAMES[i]}" +done +echo "$(( ${#SCRIPTS[@]} + 1 ))) Install ALL" +echo "$(( ${#SCRIPTS[@]} + 2 ))) 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 + 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 + echo "Invalid choice." + exit 1 +fi + bash --norc --noprofile