void

- enter the void 🪐
git clone git://git.acid.vegas/archlinux.git
Log | Files | Refs | Archive

enterthevoid (3511B)

      1 #!/bin/bash
      2 # enter the void - developed by acidvegas (https://git.acid.vegas/void)
      3 
      4 set -xev
      5 
      6 # Configuration
      7 DRIVE=/dev/sdb # can be /dev/sda, /dev/nvme0n1, etc
      8 HOSTNAME=blackhole
      9 SWAP_SIZE=4 # In GB (set to 0 to disable)
     10 TIMEZONE=America/New_York
     11 USERNAME=acidvegas
     12 WIFI_SSID= # Leave blank if you don't want to use wifi
     13 WIFI_PASS=
     14 WIFI_DEV=wlp3s0
     15 
     16 # Helper function to handle drive partitions
     17 get_partition() {
     18 	local drive=$1
     19 	local part_num=$2
     20 	
     21 	if [[ $drive == *"nvme"* ]]; then
     22 		echo "${drive}p${part_num}"
     23 	else
     24 		echo "${drive}${part_num}"
     25 	fi
     26 }
     27 
     28 setup_network() {
     29 	if [ ! -z "$WIFI_SSID" ]; then
     30 		if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then
     31 			printf "Wifi is blocked, attempting to unblock... (make sure to handle this after reboot)\n"
     32 			rfkill unblock wifi
     33 		fi
     34 		wpa_passphrase "$WIFI_SSID" "$WIFI_PASS" | wpa_supplicant -i $WIFI_DEV -c /dev/stdin
     35 	fi
     36 }
     37 
     38 setup_partition() {
     39 	xbps-install -u xbps
     40 	xbps-install -Su
     41 	xbps-install parted
     42 
     43 	PART1=$(get_partition $DRIVE 1)
     44 	PART2=$(get_partition $DRIVE 2)
     45 
     46 	wipefs -a $DRIVE
     47 	parted $DRIVE --script mklabel gpt
     48 	parted $DRIVE --script mkpart primary fat32 1MiB 513MiB
     49 	parted $DRIVE --script set 1 esp on
     50 	parted $DRIVE --script mkpart primary ext4 513MiB 100%
     51 	partprobe $DRIVE
     52 	mkfs.vfat $PART1
     53 	mkfs.ext4 $PART2
     54 	mount $PART2 /mnt
     55 	mkdir -p /mnt/boot/efi
     56 	mount $PART1 /mnt/boot/efi
     57 }
     58 
     59 setup_install() {
     60 	REPO=https://repo-default.voidlinux.org/current
     61 	mkdir -p /mnt/var/db/xbps/keys
     62 	cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
     63 
     64 	xbps-install -S -r /mnt -R "$REPO" base-system linux
     65 
     66 	printf "entering chroot...remember to run setup_chroot() inside the chroot!\n"
     67 	xchroot /mnt /bin/bash
     68 }
     69 
     70 setup_chroot() {
     71 	passwd
     72 	xbps-install -u xbps
     73 	xbps-install -Su
     74 
     75 	xbps-install void-repo-nonfree
     76 	xbps-install -Su
     77 	xbps-install intel-ucode
     78 	ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/
     79 
     80 	useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel
     81 	ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
     82 	hwclock --systohc
     83 	printf "$HOSTNAME\n" > /etc/hostname
     84 	printf "HOSTNAME=\"$HOSTNAME\"\nHARDWARECLOCK=\"UTC\"\nTIMEZONE=\"$TIMEZONE\"\nKEYMAP=us\nCGROUP_MODE=\"unified\"\n" > /etc/rc.conf
     85 
     86 	printf "en_US.UTF-8 UTF-8\n" > /etc/default/libc-locales
     87 	printf "LANG=en_US.UTF-8\n" > /etc/locale.conf
     88 	xbps-reconfigure -f glibc-locales
     89 
     90 	PART1=$(get_partition $DRIVE 1)
     91 	PART2=$(get_partition $DRIVE 2)
     92 	printf "UUID=$(blkid -s UUID -o value $PART2) / ext4 defaults,noatime 0 1\n" > /etc/fstab
     93 	printf "UUID=$(blkid -s UUID -o value $PART1) /boot/efi vfat defaults,noatime 0 1\n" >> /etc/fstab
     94 	printf "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n" >> /etc/fstab
     95 
     96 	if [ $SWAP_SIZE -gt 0 ]; then
     97 		touch /swapfile
     98 		dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_SIZE}k status=progress
     99 		chmod 0600 /swapfile
    100 		mkswap /swapfile
    101 		swapon /swapfile
    102 		printf "/swapfile none swap sw 0 0\n" >> /etc/fstab
    103 	fi
    104 
    105 	xbps-install grub-x86_64-efi
    106 	grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --recheck
    107 	xbps-reconfigure -fa linux
    108 	grub-mkconfig -o /boot/grub/grub.cfg
    109 
    110 	exit
    111 }
    112 
    113 if [ "$#" -ne 1 ]; then
    114 	printf "usage: $0 [network|partition|install|chroot|final]\n"
    115 	exit 1
    116 fi
    117 
    118 case "$1" in
    119     network)   setup_network ;;
    120     partition) setup_partition ;;
    121     install)   setup_install ;;
    122     chroot)    setup_chroot ;;
    123     final)     umount -R /mnt; reboot ;;
    124     *)         printf "usage: $0 [network|partition|install|chroot|final]\n"; exit 1 ;;
    125 esac