Compare commits

...

4 Commits

Author SHA1 Message Date
Joca 51fbc1f2cf
Add the ability to choose between different architectures 2025-02-21 14:19:48 -03:00
Joca 0facbea16a
Several Modifications
- Renamed Scripts to scripts.lst
- Script now restores tty configuration
- Removed xargs
- Removed install all option
2025-02-17 21:43:39 -03:00
Joca 5aaacf72a0
Add config scripts to install-stage2 and install-stage1 2025-01-28 22:25:56 -03:00
Joca 734d5b8332
Remove Package Selections, removed non-ascii
characters
2025-01-28 18:59:16 -03:00
23 changed files with 135 additions and 310 deletions

12
custom-scripts/i3wm.sh Normal file
View File

@ -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

18
custom-scripts/readme.md Normal file
View File

@ -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.

View File

@ -0,0 +1 @@
i3wm.sh

View File

@ -62,7 +62,7 @@ fi
echo " echo "
This script will now download and install Void Linux on your USB stick. This script will now download and install Void Linux on your USB stick.
Any data that is currently on the stick will be lost and it wont be Any data that is currently on the stick will be lost and it won't be
usable from Windows or MacOS. usable from Windows or MacOS.
Before we begin, the following packages need to be installed (if not installed already): Before we begin, the following packages need to be installed (if not installed already):
@ -210,12 +210,33 @@ xmirror
#TODO: also remove CPU architecture #TODO: also remove CPU architecture
TARGET_MIRROR="$(sed 's/repository=//;s|/musl$||' /etc/xbps.d/00-repository-main.conf)" TARGET_MIRROR="$(sed 's/repository=//;s|/musl$||' /etc/xbps.d/00-repository-main.conf)"
#TODO: select installation type
TARGET_TYPE="x86_64" options=("x86_64" "x86_64 musl" "x86_32")
while true; do
echo "Select your desired architecture."
for i in "${!options[@]}"; do
echo "$((i+1))) ${options[$i]}"
done
read -p "Input your choice: " choice
# Funny loop in bash...
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#options[@]}" ]; then
TARGET_TYPE="${options[$((choice-1))]}"
break
else
echo "Selection invalid."
fi
done
echo "You selected: $TARGET_TYPE"
#TODO: also add CPU architecture #TODO: also add CPU architecture
if grep "musl" <<< "$TARGET_TYPE"; then if grep "musl" <<< "$TARGET_TYPE"; then
TARGET_MIRROR="$TARGET_MIRROR/musl" TARGET_MIRROR="$TARGET_MIRROR/musl"
# Probably not the smartest idea, but since there is just one option for musl,
# I figured out this should do.
TARGET_TYPE="x86_64"
fi fi
echo -n "Copying repository keys... " echo -n "Copying repository keys... "
@ -372,7 +393,7 @@ mkdir /mnt/target/boot/efi/LOADER >> $LOGFILE 2>&1
echo "GRUB has been deliberately installed to a non-standard location. echo "GRUB has been deliberately installed to a non-standard location.
This avoids default kernel hooks breaking the custom config." > /mnt/target/boot/efi/LOADER/README.TXT This avoids default kernel hooks breaking the custom config." > /mnt/target/boot/efi/LOADER/README.TXT
# no idea if any of these are even necessary/relevant but it cant hurt... # no idea if any of these are even necessary/relevant but it can't hurt...
TARGET_PRELOAD_GRUB_MODULES="usb usbms uhci ehci ohci part_gpt f2fs ahci ata pata" TARGET_PRELOAD_GRUB_MODULES="usb usbms uhci ehci ohci part_gpt f2fs ahci ata pata"
run_in_target grub-install --target=i386-pc --boot-directory=/boot/efi/LOADER --disk-module=native --modules="'$TARGET_PRELOAD_GRUB_MODULES'" "'/dev/$TARGET_DISK'" >> $LOGFILE 2>&1 run_in_target grub-install --target=i386-pc --boot-directory=/boot/efi/LOADER --disk-module=native --modules="'$TARGET_PRELOAD_GRUB_MODULES'" "'/dev/$TARGET_DISK'" >> $LOGFILE 2>&1
run_in_target grub-install --target=i386-efi --boot-directory=/boot/efi/LOADER --disk-module=native --efi-directory=/boot/efi --removable --no-nvram --modules="'$TARGET_PRELOAD_GRUB_MODULES'" "'/dev/$TARGET_DISK'" >> $LOGFILE 2>&1 run_in_target grub-install --target=i386-efi --boot-directory=/boot/efi/LOADER --disk-module=native --efi-directory=/boot/efi --removable --no-nvram --modules="'$TARGET_PRELOAD_GRUB_MODULES'" "'/dev/$TARGET_DISK'" >> $LOGFILE 2>&1
@ -414,23 +435,25 @@ 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
get_stage2_file package_selections/sections.lst function download_scripts {
readarray -t SECTIONS < "$STAGE2_DIR/package_selections/sections.lst" local scripts_file="$1"
for I in ${!SECTIONS[@]}; do
get_stage2_file "package_selections/${SECTIONS[$I]}/description.txt" # 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"
}
get_stage2_file "package_selections/${SECTIONS[$I]}/options.lst" # Create the custom-scripts directory
readarray -t OPTIONS < "$STAGE2_DIR/package_selections/${SECTIONS[$I]}/options.lst" CUSTOM_SCRIPTS_DIR="$STAGE2_DIR/custom-scripts"
for J in ${!OPTIONS[@]}; do mkdir -p "$CUSTOM_SCRIPTS_DIR"
get_stage2_file "package_selections/${SECTIONS[$I]}/${OPTIONS[$J]}"
done
get_stage2_file "package_selections/${SECTIONS[$I]}/additional_files.lst" # Download the scripts file into the custom-scripts folder
readarray -t FILES < "$STAGE2_DIR/package_selections/${SECTIONS[$I]}/additional_files.lst" SCRIPTS_FILE="scripts" # The name of the scripts file in the custom-scripts folder
for J in ${!FILES[@]}; do get_stage2_file "custom-scripts/$SCRIPTS_FILE"
get_stage2_file "package_selections/${SECTIONS[$I]}/${FILES[$J]}"
done download_scripts "$CUSTOM_SCRIPTS_DIR/$SCRIPTS_FILE"
done
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

View File

@ -78,42 +78,70 @@ if [ "$INTERNET" = "up" ]; then
echo "done" echo "done"
fi fi
readarray -t SECTIONS < /opt/void-usb/installer/package_selections/sections.lst
for I in ${!SECTIONS[@]}; do
readarray -t OPTIONS < "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/options.lst"
AVAILABLE_OPTIONS=()
for J in ${!OPTIONS[@]}; do
source "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/${OPTIONS[$J]}"
if check; then
AVAILABLE_OPTIONS+=("${OPTIONS[$J]}")
fi
done
if [ -z "${AVAILABLE_OPTIONS[1]}" ]; then STAGE2_DIR="/opt/void-usb/installer/" # Change this to your desired directory
# no need to ask, there is only one option anyway CONFIG_DIR="$STAGE2_DIR/custom-scripts"
CHOICE="${AVAILABLE_OPTIONS[0]}" SCRIPT_LIST="$CONFIG_DIR/scripts.lst"
else SCRIPTS=()
clear NAMES=()
cat "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/description.txt" DESCRIPTIONS=()
echo ""
for J in ${!AVAILABLE_OPTIONS[@]}; do
source "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/${AVAILABLE_OPTIONS[$J]}"
echo "$J: $DESCRIPTION"
done
CHOICE=""
while [ -z "$CHOICE" ]; do
echo ""
echo "Select by entering the corresponding number."
read -p "> " CHOICE_NUMBER
grep "^[0-9]*$" <<< "$CHOICE_NUMBER" && CHOICE="${AVAILABLE_OPTIONS[$CHOICE_NUMBER]}"
done
fi
source "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/$CHOICE" # Find all scripts and extract their names & descriptions
if [ -n "$PACKAGES" ]; then echo "Scanning for configuration scripts in $CONFIG_DIR..."
xbps-install --yes $PACKAGES for script in "$CONFIG_DIR"/*.sh; do
fi [ -f "$script" ] || continue # Skip if no .sh files found
post_install 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 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[@]}): " 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
# 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 bash --norc --noprofile

View File

@ -1,19 +0,0 @@
# Package Selections
These are intended to give the user a bunch of choices when installing the
system. For example whether to use XFE or a more fully featured set of applications.
## Sections
Sections contain choices of a specific category. The sections are stored in
folders containing the sections description and its options.
For each section, only one of the options can be chosen.
The file `sections.lst` holds a list of all available sections in the order
in which the user will be asked about them.
## Options
Options are shell scripts that are sourced by the stage 2 installer.
They hold variables for description, package list, pre-install checks,
and additional post-install actions.
Options are shown in the order in which they appear in `options.lst`.

View File

@ -1,3 +0,0 @@
resources/common_packages
resources/xinitrc
resources/bashrc

View File

@ -1 +0,0 @@
Choose a desktop setup to install

View File

@ -1,13 +0,0 @@
function check {
[ "$INTERNET" = "down" ] && return 1
return 0
}
DESCRIPTION="Fully featured desktop with IceWM"
# TODO
PACKAGES="$(cat /opt/void-usb/installer/package_selections/desktop/resources/common_packages) pavucontrol network-manager-applet vlc lxterminal bash-completion gufw conky icewm firefox arandr xscreensaver-elogind volctl"
function post_install {
echo "desktop/icewm-light" >> /tmp/stage-2-choices
}

View File

@ -1,13 +0,0 @@
function check {
[ "$INTERNET" = "down" ] && return 1
return 0
}
DESCRIPTION="Small desktop with IceWM"
# TODO
PACKAGES="$(cat /opt/void-usb/installer/package_selections/desktop/resources/common_packages) pulsemixer xterm icewm firefox htop xfe"
function post_install {
echo "desktop/icewm-light" >> /tmp/stage-2-choices
}

View File

@ -1,11 +0,0 @@
function check {
return 0
}
DESCRIPTION="Leave the system as-is (no desktop)"
PACKAGES=""
function post_install {
echo "desktop/none" >> /tmp/stage-2-choices
}

View File

@ -1,3 +0,0 @@
icewm-full
icewm-lite
none

View File

@ -1,94 +0,0 @@
# ALWAYS RUN
# ==========
# things to always set up, even for non-interactive shells
EDITOR=nano
PAGER=less
if grep -F ".local/bin" <<< "$PATH"; then
true
else
PATH="$HOME/.local/bin:$PATH"
fi
export EDITOR PAGER PATH
# CHECK INTERACTIVE
# =================
# Don't do anything after this if not running an interactive shell.
case $- in
*i*) ;;
*) return ;;
esac
# START XORG
# ==========
# TODO
# check if login shell
# if yes, check if .xinitrc exists
# if yes, check if xorg is already running
# if no, startx
# ALIASES
# =======
alias aliases="nano $HOME/.bashrc_aliases && source $HOME/.bashrc_aliases"
[ -f $HOME/.bashrc_aliases ] && source $HOME/.bashrc_aliases
# BASH COMPLETION
# ===============
# include bash completions if they exist
# (may need to be adjusted to where the bash completions are stored on the current system)
# Default for FreeBSD:
if [ -f /usr/local/share/bash-completion/bash_completion.sh ]; then
source /usr/local/share/bash-completion/bash_completion.sh
# Default for Linux:
elif [ -f /usr/share/bash-completion/bash_completion ]; then
source /usr/share/bash-completion/bash_completion
fi
# VARIABLES
# =========
# don't put duplicate lines or lines starting with a space in history
HISTCONTROL=ingnoreboth
# unlimited history
HISTSIZE=-1
HISTFILESIZE=-1
# set a fancy prompt
PROMPT_COMMAND="PS1=\"[\[\e[03$(
if [ $EUID -eq 0 ]
then
echo -n '1;02m'
else
if [ -n "$(groups | grep 'wheel\|sudo')" ];
then
echo -n '2;01m'
else
echo -n '6;01m'
fi
fi
)\]\u@\h\[\e[0m\]]:\$(
PROMPT_ERRORLEVEL=\$?
if [ \$PROMPT_ERRORLEVEL -eq 0 ]
then
echo -n '\[\e[032;02m\]'
else
echo -n '\[\e[031;02m\]'
fi
echo -n \$PROMPT_ERRORLEVEL
echo -n '\[\e[00m\]'
):\[\e[034;01m\]\$(pwd)\[\e[0m\]:$(
if [ $EUID -eq 0 ]
then
echo -n '\[\e[02m\]#\[\e[0m\]'
else
echo -n '\[\e[02m\]$\[\e[0m\]'
fi
)> \""
# SHELL OPTIONS
# =============
shopt -s histappend
shopt -s checkwinsize
shopt -s globstar

View File

@ -1 +0,0 @@
setxkbmap xauth xorg-video-drivers mesa mesa-dri xorg-server elogind xorg-input-drivers xrandr acpilight xhost xinit xrdb xinput xgamma xset iceauth sessreg transset xcmsdb xkbutils xmodmap dejavu-fonts-ttf elogind xdg-utils dbus-elogind dbus-elogind-libs dbus-elogind-x11 pipewire

View File

@ -1,18 +0,0 @@
#!/bin/sh
if grep -F ".local/bin" <<< "$PATH"; then
true
else
PATH="$HOME/.local/bin:$PATH"
fi
export PATH
if [ -d "$HOME/.xinitrc.d" ]; then
for FILE in "$HOME/.xinitrc.d"/*; do
[ -x "$FILE" ] && "$FILE" &
done
fi
# The line below is placed by the package selection script.

View File

@ -1,10 +0,0 @@
Do you want to install the proprietary Nvidia driver?
By default, Void Linux ships with the open-source nouveau driver.
This is nice because it gets the system up and running when using an
Nvidia GPU but, due to Nvidias secrecy, nouveau isnt particularly good.
Installing the proprietary driver is recommended if you want to use Nvidia GPUs.
This will enable the nonfree repository.
Different versions are available. You can only choose one.

View File

@ -1,11 +0,0 @@
function check {
return 0
}
DESCRIPTION="Dont install."
PACKAGES=""
function post_install {
echo "nvidia/none" >> /tmp/stage-2-choices
}

View File

@ -1,18 +0,0 @@
function check {
[ "$INTERNET" = "down" ] && return 1
if xbps-query glibc >/dev/null 2>&1; then
return 0
else
return 1
fi
}
DESCRIPTION="Latest Nvidia driver, supports GTX ??? series and up"
#TODO: void-repo-nonfree
PACKAGES="nvidia"
function post_install {
#TODO: nvidia modeset kernel parameter?
echo "nvidia/nvidia" >> /tmp/stage-2-choices
}

View File

@ -1,18 +0,0 @@
function check {
[ "$INTERNET" = "down" ] && return 1
if xbps-query glibc >/dev/null 2>&1; then
return 0
else
return 1
fi
}
DESCRIPTION="Legacy Nvidia driver, version 390, supports GTX ??? series"
#TODO: void-repo-nonfree
PACKAGES="nvidia390"
function post_install {
#TODO: nvidia modeset kernel parameter?
echo "nvidia/nvidia390" >> /tmp/stage-2-choices
}

View File

@ -1,18 +0,0 @@
function check {
[ "$INTERNET" = "down" ] && return 1
if xbps-query glibc >/dev/null 2>&1; then
return 0
else
return 1
fi
}
DESCRIPTION="Legacy Nvidia driver, version 470, supports GTX ??? series"
#TODO: void-repo-nonfree
PACKAGES="nvidia470"
function post_install {
#TODO: nvidia modeset kernel parameter?
echo "nvidia/nvidia470" >> /tmp/stage-2-choices
}

View File

@ -1,4 +0,0 @@
none
nvidia
nvidia470
nvidia390

View File

@ -1,2 +0,0 @@
nvidia
desktop