custom-scripts: add customization scripts infrastructure
This commit has been created from multiple commits on Joca’s branch and additional edits Co-authored-by: BodgeMaster <>master
parent
2cc32fe645
commit
517ac34e3d
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
### Configuration Scripts
|
||||||
|
|
||||||
|
Use this to Deploy rices/set up services/etc.
|
||||||
|
|
||||||
|
Each configuration script should follow this structure:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# NAME: Your Script Name
|
||||||
|
# DESC: A brief description of what the script does.
|
||||||
|
|
||||||
|
# Your script logic here
|
||||||
|
```
|
||||||
|
|
||||||
|
If `# NAME:` is not found, install stage 2 will fall back to displaying the script's filename.
|
||||||
|
If `# DESC:` is not found, "No description available." will be displayed instead.
|
||||||
|
|
||||||
|
Place the scripts under this folder, add the filename to `scripts.lst` (separate by newline) and they will show up in the installer.
|
|
@ -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
|
|
@ -0,0 +1 @@
|
||||||
|
i3wm.sh
|
|
@ -411,9 +411,15 @@ function get_stage2_file {
|
||||||
wget --output-document="$STAGE2_DIR/$1" "$GIT_REPO_BASE/$1" >> $LOGFILE 2>&1
|
wget --output-document="$STAGE2_DIR/$1" "$GIT_REPO_BASE/$1" >> $LOGFILE 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
get_stage2_file install-stage2.sh >> $LOGFILE 2>&1
|
get_stage2_file "install-stage2.sh" >> $LOGFILE 2>&1
|
||||||
chmod 744 "$STAGE2_DIR/install-stage2.sh" >> $LOGFILE 2>&1
|
chmod 744 "$STAGE2_DIR/install-stage2.sh" >> $LOGFILE 2>&1
|
||||||
|
|
||||||
|
# Stage 2 prefab environment/rice install scripts
|
||||||
|
get_stage2_file "custom-scripts/scripts.lst"
|
||||||
|
while read -r NEXT_SCRIPT; do
|
||||||
|
[ -n "$NEXT_SCRIPT" ] && get_stage2_file "custom-scripts/$NEXT_SCRIPT"
|
||||||
|
done < "$STAGE2_DIR/custom-scripts/scripts.lst"
|
||||||
|
|
||||||
mv /mnt/target/etc/sv/agetty-tty1/conf /mnt/target/etc/sv/agetty-tty1/conf.bak >> $LOGFILE 2>&1
|
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
|
echo 'if [ -x /sbin/agetty -o -x /bin/agetty ]; then
|
||||||
if [ "${tty}" = "tty1" ]; then
|
if [ "${tty}" = "tty1" ]; then
|
||||||
|
|
|
@ -78,4 +78,58 @@ if [ "$INTERNET" = "up" ]; then
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
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=()
|
||||||
|
|
||||||
|
# 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" | sed 's/^# NAME:[[:space:]]*//')
|
||||||
|
[ -z "$SCRIPT_NAME" ] && SCRIPT_NAME="$(basename "$script")"
|
||||||
|
|
||||||
|
# Extract description from "# DESC:" (first occurrence)
|
||||||
|
SCRIPT_DESC=$(grep -m1 '^# DESC:' "$script" | sed 's/^# DESC:[[:space:]]*//')
|
||||||
|
[ -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]} - ${DESCRIPTIONS[i]}"
|
||||||
|
done
|
||||||
|
echo "$(( ${#SCRIPTS[@]} + 1 ))) Exit"
|
||||||
|
|
||||||
|
# Get user input
|
||||||
|
read -p "Select an option [1-$((${#SCRIPTS[@]}+1))]: " CHOICE
|
||||||
|
|
||||||
|
# Run selected script
|
||||||
|
if (( CHOICE >= 1 && CHOICE <= ${#SCRIPTS[@]} )); then
|
||||||
|
echo "Running: ${NAMES[CHOICE-1]}"
|
||||||
|
bash "${SCRIPTS[CHOICE-1]}"
|
||||||
|
elif (( CHOICE == ${#SCRIPTS[@]} + 1 )); then
|
||||||
|
echo "Exiting..."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Invalid choice."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
bash --norc --noprofile
|
bash --norc --noprofile
|
||||||
|
|
Loading…
Reference in New Issue