2024-02-29 03:45:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# enter the void - developed by acidvegas (https://git.acid.vegas/void)
|
|
|
|
|
|
|
|
set -xev
|
|
|
|
|
|
|
|
# Configuration
|
2025-01-22 01:07:44 +00:00
|
|
|
DRIVE=/dev/sdb # can be /dev/sda, /dev/nvme0n1, etc
|
2024-02-29 03:45:58 +00:00
|
|
|
HOSTNAME=blackhole
|
|
|
|
SWAP_SIZE=4 # In GB (set to 0 to disable)
|
|
|
|
TIMEZONE=America/New_York
|
|
|
|
USERNAME=acidvegas
|
|
|
|
WIFI_SSID= # Leave blank if you don't want to use wifi
|
|
|
|
WIFI_PASS=
|
2025-01-22 01:07:44 +00:00
|
|
|
WIFI_DEV=wlp3s0
|
|
|
|
|
|
|
|
# Helper function to handle drive partitions
|
|
|
|
get_partition() {
|
|
|
|
local drive=$1
|
|
|
|
local part_num=$2
|
|
|
|
|
|
|
|
if [[ $drive == *"nvme"* ]]; then
|
|
|
|
echo "${drive}p${part_num}"
|
|
|
|
else
|
|
|
|
echo "${drive}${part_num}"
|
2024-02-29 03:45:58 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_network() {
|
|
|
|
if [ ! -z "$WIFI_SSID" ]; then
|
|
|
|
if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then
|
|
|
|
printf "Wifi is blocked, attempting to unblock... (make sure to handle this after reboot)\n"
|
|
|
|
rfkill unblock wifi
|
|
|
|
fi
|
|
|
|
wpa_passphrase "$WIFI_SSID" "$WIFI_PASS" | wpa_supplicant -i $WIFI_DEV -c /dev/stdin
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_partition() {
|
|
|
|
xbps-install -u xbps
|
|
|
|
xbps-install -Su
|
|
|
|
xbps-install parted
|
|
|
|
|
2025-01-22 01:07:44 +00:00
|
|
|
PART1=$(get_partition $DRIVE 1)
|
|
|
|
PART2=$(get_partition $DRIVE 2)
|
|
|
|
|
2024-02-29 03:45:58 +00:00
|
|
|
wipefs -a $DRIVE
|
2025-01-22 01:07:44 +00:00
|
|
|
parted $DRIVE --script mklabel gpt
|
|
|
|
parted $DRIVE --script mkpart primary fat32 1MiB 513MiB
|
|
|
|
parted $DRIVE --script set 1 esp on
|
|
|
|
parted $DRIVE --script mkpart primary ext4 513MiB 100%
|
|
|
|
partprobe $DRIVE
|
|
|
|
mkfs.vfat $PART1
|
|
|
|
mkfs.ext4 $PART2
|
|
|
|
mount $PART2 /mnt
|
|
|
|
mkdir -p /mnt/boot/efi
|
|
|
|
mount $PART1 /mnt/boot/efi
|
2024-02-29 03:45:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_install() {
|
|
|
|
REPO=https://repo-default.voidlinux.org/current
|
|
|
|
mkdir -p /mnt/var/db/xbps/keys
|
|
|
|
cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
|
|
|
|
|
2025-01-22 01:07:44 +00:00
|
|
|
xbps-install -S -r /mnt -R "$REPO" base-system linux
|
2024-02-29 03:45:58 +00:00
|
|
|
|
|
|
|
printf "entering chroot...remember to run setup_chroot() inside the chroot!\n"
|
|
|
|
xchroot /mnt /bin/bash
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_chroot() {
|
|
|
|
passwd
|
|
|
|
xbps-install -u xbps
|
|
|
|
xbps-install -Su
|
|
|
|
|
2025-01-22 01:07:44 +00:00
|
|
|
xbps-install void-repo-nonfree
|
|
|
|
xbps-install -Su
|
|
|
|
xbps-install intel-ucode
|
|
|
|
ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/
|
2024-02-29 03:45:58 +00:00
|
|
|
|
|
|
|
useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel
|
|
|
|
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
|
|
|
|
hwclock --systohc
|
|
|
|
printf "$HOSTNAME\n" > /etc/hostname
|
2024-10-21 18:46:35 +00:00
|
|
|
printf "HOSTNAME=\"$HOSTNAME\"\nHARDWARECLOCK=\"UTC\"\nTIMEZONE=\"$TIMEZONE\"\nKEYMAP=us\nCGROUP_MODE=\"unified\"\n" > /etc/rc.conf
|
2024-02-29 03:45:58 +00:00
|
|
|
|
2025-01-22 01:07:44 +00:00
|
|
|
printf "en_US.UTF-8 UTF-8\n" > /etc/default/libc-locales
|
|
|
|
printf "LANG=en_US.UTF-8\n" > /etc/locale.conf
|
|
|
|
xbps-reconfigure -f glibc-locales
|
2024-02-29 03:45:58 +00:00
|
|
|
|
2025-01-22 01:07:44 +00:00
|
|
|
PART1=$(get_partition $DRIVE 1)
|
|
|
|
PART2=$(get_partition $DRIVE 2)
|
|
|
|
printf "UUID=$(blkid -s UUID -o value $PART2) / ext4 defaults,noatime 0 1\n" > /etc/fstab
|
|
|
|
printf "UUID=$(blkid -s UUID -o value $PART1) /boot/efi vfat defaults,noatime 0 1\n" >> /etc/fstab
|
2024-02-29 03:45:58 +00:00
|
|
|
printf "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n" >> /etc/fstab
|
|
|
|
|
|
|
|
if [ $SWAP_SIZE -gt 0 ]; then
|
|
|
|
touch /swapfile
|
|
|
|
dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_SIZE}k status=progress
|
|
|
|
chmod 0600 /swapfile
|
|
|
|
mkswap /swapfile
|
|
|
|
swapon /swapfile
|
|
|
|
printf "/swapfile none swap sw 0 0\n" >> /etc/fstab
|
|
|
|
fi
|
|
|
|
|
2025-01-22 01:07:44 +00:00
|
|
|
xbps-install grub-x86_64-efi
|
|
|
|
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --recheck
|
|
|
|
xbps-reconfigure -fa linux
|
|
|
|
grub-mkconfig -o /boot/grub/grub.cfg
|
2024-02-29 03:45:58 +00:00
|
|
|
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$#" -ne 1 ]; then
|
2025-01-22 01:07:44 +00:00
|
|
|
printf "usage: $0 [network|partition|install|chroot|final]\n"
|
2024-02-29 03:45:58 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
network) setup_network ;;
|
|
|
|
partition) setup_partition ;;
|
|
|
|
install) setup_install ;;
|
|
|
|
chroot) setup_chroot ;;
|
|
|
|
final) umount -R /mnt; reboot ;;
|
2025-01-22 01:07:44 +00:00
|
|
|
*) printf "usage: $0 [network|partition|install|chroot|final]\n"; exit 1 ;;
|
2024-02-29 03:45:58 +00:00
|
|
|
esac
|