forked from BodgeMaster/void-usb
Add config scripts to install-stage2 and install-stage1
parent
734d5b8332
commit
5aaacf72a0
|
@ -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,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.
|
|
@ -0,0 +1 @@
|
||||||
|
i3wm.sh
|
|
@ -414,6 +414,26 @@ function get_stage2_file {
|
||||||
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
|
||||||
|
|
||||||
|
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
|
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,75 @@ 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"
|
||||||
|
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
|
bash --norc --noprofile
|
||||||
|
|
Loading…
Reference in New Issue