updated scripts aliases and general void install for myself

This commit is contained in:
Dionysus 2025-01-21 20:07:44 -05:00
parent 81a4d4cefd
commit 296927a71d
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
2 changed files with 46 additions and 154 deletions

View File

@ -4,50 +4,27 @@
set -xev set -xev
# Configuration # Configuration
ARCH=x86_64 # x86_64 or x86_64-musl DRIVE=/dev/sdb # can be /dev/sda, /dev/nvme0n1, etc
CPU=intel # amd or intel
DRIVE=/dev/sdb # can be a single drive or an array if using raidz with zfs
HOSTNAME=blackhole HOSTNAME=blackhole
SWAP_SIZE=4 # In GB (set to 0 to disable) SWAP_SIZE=4 # In GB (set to 0 to disable)
ROOT_FS=btrfs # btrfs or ext4
TIMEZONE=America/New_York TIMEZONE=America/New_York
USERNAME=acidvegas USERNAME=acidvegas
WIFI_SSID= # Leave blank if you don't want to use wifi WIFI_SSID= # Leave blank if you don't want to use wifi
WIFI_PASS= WIFI_PASS=
WIFI_DEV=wlan0 WIFI_DEV=wlp3s0
if [ -d /sys/firmware/efi ]; then # Helper function to handle drive partitions
BOOT_OPTION=UEFI get_partition() {
local drive=$1
local part_num=$2
if [[ $drive == *"nvme"* ]]; then
echo "${drive}p${part_num}"
else else
BOOT_OPTION=BIOS echo "${drive}${part_num}"
fi
check_config() {
if [ ! $ARCH = "x86_64" ] && [ ! $ARCH = "x86_64-musl" ]; then
printf "invalid ARCH\n" && exit 1
elif [ ! $CPU = "amd" ] && [ ! $CPU = "intel" ]; then
printf "invalid CPU\n" && exit 1
elif [ ! -b $DRIVE ]; then
printf "invalid DRIVE\n" && exit 1
elif [ -z $HOSTNAME ]; then
printf "invalid HOSTNAME\n" && exit 1
elif ! [ "$SWAP_SIZE" -eq "$SWAP_SIZE" ] 2>/dev/null; then
printf "invalid SWAP_SIZE\n" && exit 1
elif [ ! $ROOT_FS = "btrfs" ] && [ ! $ROOT_FS = "ext4" ] && [ ! $ROOT_FS = "zfs" ]; then
printf "invalid ROOT_FS\n" && exit 1
elif [ ! -f /usr/share/zoneinfo/$TIMEZONE ]; then
printf "invalid TIMEZONE\n" && exit 1
elif [ -z $USERNAME ]; then
printf "invalid USERNAME\n" && exit 1
elif [ ! -z $WIFI_SSID ]; then
if [ -z $(ip addr | grep '^[0-9]:' | awk '{print $2}' | tr -d ':' | grep $WIFI_DEV) ]; then
printf "invalid WIFI_DEV\n" && exit 1
fi
fi fi
} }
setup_network() { setup_network() {
if [ ! -z "$WIFI_SSID" ]; then if [ ! -z "$WIFI_SSID" ]; then
if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then
@ -58,130 +35,66 @@ setup_network() {
fi fi
} }
setup_partition() { setup_partition() {
xbps-install -u xbps xbps-install -u xbps
xbps-install -Su xbps-install -Su
xbps-install parted xbps-install parted
PART1=$(get_partition $DRIVE 1)
PART2=$(get_partition $DRIVE 2)
wipefs -a $DRIVE wipefs -a $DRIVE
if [ $BOOT_OPTION = "UEFI" ]; then
parted $DRIVE --script mklabel gpt parted $DRIVE --script mklabel gpt
parted $DRIVE --script mkpart primary fat32 1MiB 513MiB parted $DRIVE --script mkpart primary fat32 1MiB 513MiB
parted $DRIVE --script set 1 esp on parted $DRIVE --script set 1 esp on
parted $DRIVE --script mkpart primary $ROOT_FS 513MiB 100% parted $DRIVE --script mkpart primary ext4 513MiB 100%
partprobe $DRIVE partprobe $DRIVE
mkfs.vfat ${DRIVE}1 mkfs.vfat $PART1
if [ $ROOT_FS = "btrfs" ]; then mkfs.ext4 $PART2
mkfs.btrfs -f ${DRIVE}2 mount $PART2 /mnt
mount ${DRIVE}2 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
umount /mnt
mount -o subvol=@ ${DRIVE}2 /mnt
mkdir -p /mnt/{home,snapshots}
mount -o subvol=@home ${DRIVE}2 /mnt/home
mount -o subvol=@snapshots ${DRIVE}2 /mnt/snapshots
elif [ $ROOT_FS = "ext4" ]; then
mkfs.ext4 ${DRIVE}2
mount ${DRIVE}2 /mnt
fi
mkdir -p /mnt/boot/efi mkdir -p /mnt/boot/efi
mount ${DRIVE}1 /mnt/boot/efi mount $PART1 /mnt/boot/efi
elif [ $BOOT_OPTION = "BIOS" ]; then
parted $DRIVE --script mklabel msdos
parted $DRIVE --script mkpart primary $ROOT_FS 1MiB 100%
parted $DRIVE --script set 1 boot on
partprobe $DRIVE
if [ $ROOT_FS = "btrfs" ]; then
mkfs.btrfs -f ${DRIVE}1
mount ${DRIVE}1 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
umount /mnt
mount -o subvol=@ ${DRIVE}1 /mnt
mkdir -p /mnt/{home,snapshots}
mount -o subvol=@home ${DRIVE}1 /mnt/home
mount -o subvol=@snapshots ${DRIVE}1 /mnt/snapshots
elif [ $ROOT_FS = "ext4" ]; then
mkfs.ext4 ${DRIVE}1
mount ${DRIVE}1 /mnt
fi
fi
} }
setup_install() { setup_install() {
REPO=https://repo-default.voidlinux.org/current REPO=https://repo-default.voidlinux.org/current
if [ $ARCH = 'x86_64-musl' ]; then
REPO=$REPO/musl
fi
mkdir -p /mnt/var/db/xbps/keys mkdir -p /mnt/var/db/xbps/keys
cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/ cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
XBPS_ARCH=$ARCH xbps-install -S -r /mnt -R "$REPO" base-system linux xbps-install -S -r /mnt -R "$REPO" base-system linux
printf "entering chroot...remember to run setup_chroot() inside the chroot!\n" printf "entering chroot...remember to run setup_chroot() inside the chroot!\n"
xchroot /mnt /bin/bash xchroot /mnt /bin/bash
} }
setup_chroot() { setup_chroot() {
passwd passwd
xbps-install -u xbps xbps-install -u xbps
xbps-install -Su xbps-install -Su
if [ $CPU = "intel" ]; then
xbps-install void-repo-nonfree xbps-install void-repo-nonfree
xbps-install -Su xbps-install -Su
xbps-install intel-ucode xbps-install intel-ucode
ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/ ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/
elif [ $CPU = "amd" ]; then
xbps-install linux-firmware-amd
fi
useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
#ln -sf /etc/sv/dhcpcd /etc/runit/runsvdir/default/
hwclock --systohc hwclock --systohc
printf "$HOSTNAME\n" > /etc/hostname printf "$HOSTNAME\n" > /etc/hostname
printf "HOSTNAME=\"$HOSTNAME\"\nHARDWARECLOCK=\"UTC\"\nTIMEZONE=\"$TIMEZONE\"\nKEYMAP=us\nCGROUP_MODE=\"unified\"\n" > /etc/rc.conf printf "HOSTNAME=\"$HOSTNAME\"\nHARDWARECLOCK=\"UTC\"\nTIMEZONE=\"$TIMEZONE\"\nKEYMAP=us\nCGROUP_MODE=\"unified\"\n" > /etc/rc.conf
if [ $ARCH = 'x86_64' ]; then
printf "en_US.UTF-8 UTF-8\n" > /etc/default/libc-locales printf "en_US.UTF-8 UTF-8\n" > /etc/default/libc-locales
printf "LANG=en_US.UTF-8\n" > /etc/locale.conf printf "LANG=en_US.UTF-8\n" > /etc/locale.conf
xbps-reconfigure -f glibc-locales xbps-reconfigure -f glibc-locales
fi
if [ $BOOT_OPTION = "UEFI" ]; then
if [ $ROOT_FS = "btrfs" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) / $ROOT_FS defaults,noatime,subvol=@ 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) /home $ROOT_FS defaults,subvol=@home 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) /snapshots $ROOT_FS defaults,subvol=@snapshots 0 1\n"
elif [ $ROOT_FS = "ext4" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) / $ROOT_FS defaults,noatime 0 1\n"
fi
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) /boot/efi vfat defaults,noatime 0 1\n"
elif [ $BOOT_OPTION = "BIOS" ]; then
if [ $ROOT_FS = "btrfs" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) / btrfs defaults,noatime,subvol=@ 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) /home btrfs defaults,subvol=@home 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) /snapshots btrfs defaults,subvol=@snapshots 0 1\n"
elif [ $ROOT_FS = "ext4" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) / $ROOT_FS defaults,noatime 0 1\n"
fi
fi > /etc/fstab
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
printf "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n" >> /etc/fstab printf "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n" >> /etc/fstab
if [ $SWAP_SIZE -gt 0 ]; then if [ $SWAP_SIZE -gt 0 ]; then
touch /swapfile touch /swapfile
if [ $ROOT_FS = "btrfs" ]; then
chattr +C /swapfile # Needed?
fi
dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_SIZE}k status=progress dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_SIZE}k status=progress
chmod 0600 /swapfile chmod 0600 /swapfile
mkswap /swapfile mkswap /swapfile
@ -189,34 +102,24 @@ setup_chroot() {
printf "/swapfile none swap sw 0 0\n" >> /etc/fstab printf "/swapfile none swap sw 0 0\n" >> /etc/fstab
fi fi
if [ $BOOT_OPTION = "UEFI" ]; then xbps-install grub-x86_64-efi
xbps-install gummiboot grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --recheck
gummiboot install xbps-reconfigure -fa linux
cp /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/boot/bootx64.efi # copy the EFI for tricking compatability grub-mkconfig -o /boot/grub/grub.cfg
elif [ $BOOT_OPTION = "BIOS" ]; then
xbps-install grub
sleep 2 # I don't know why this is needed, but it is...grub-install fails and then works after running 2 seconds
grub-install /dev/$DRIVE
fi
xbps-reconfigure -fa
exit exit
} }
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
printf "usage: $0 [install|partition|chroot|final]\n" printf "usage: $0 [network|partition|install|chroot|final]\n"
exit 1 exit 1
fi fi
check_config
case "$1" in case "$1" in
network) setup_network ;; network) setup_network ;;
partition) setup_partition ;; partition) setup_partition ;;
install) setup_install ;; install) setup_install ;;
chroot) setup_chroot ;; chroot) setup_chroot ;;
final) umount -R /mnt; reboot ;; final) umount -R /mnt; reboot ;;
*) printf "usage: $0 [install|partition|chroot|final]\n"; exit 1 ;; *) printf "usage: $0 [network|partition|install|chroot|final]\n"; exit 1 ;;
esac esac

View File

@ -55,20 +55,9 @@ crtsh() {
} }
shardz() { shardz() {
[ "$#" -ne 1 ] || ! echo "$1" | grep -q '^[1-9][0-9]*/[1-9][0-9]*$' && { # Usage: shardz INDEX/TOTAL
echo "Usage: process_with_output | shardz INDEX/TOTAL" >&2 # curl https://example.com/large_file.txt | shardz 1/3 | httpx -title -ip -tech-detect -json -o shard-1.json
return 1 awk -v n="$1" -v t="$2" 'NR % t == n'
}
shard=${1%/*}
total=${1#*/}
[ "$shard" -gt "$total" ] && {
echo "Error: INDEX cannot be greater than TOTAL" >&2
return 1
}
sed -n "$shard~$total p"
} }
shodan() { shodan() {