From 296927a71deb46ddeb7135a21c573c5e3bb3d09c Mon Sep 17 00:00:00 2001 From: acidvegas Date: Tue, 21 Jan 2025 20:07:44 -0500 Subject: [PATCH] updated scripts aliases and general void install for myself --- enterthevoid | 183 +++++++++--------------------------- local/share/bash/bash_recon | 17 +--- 2 files changed, 46 insertions(+), 154 deletions(-) diff --git a/enterthevoid b/enterthevoid index cb72ae9..fd5f47c 100755 --- a/enterthevoid +++ b/enterthevoid @@ -4,50 +4,27 @@ set -xev # Configuration -ARCH=x86_64 # x86_64 or x86_64-musl -CPU=intel # amd or intel -DRIVE=/dev/sdb # can be a single drive or an array if using raidz with zfs +DRIVE=/dev/sdb # can be /dev/sda, /dev/nvme0n1, etc HOSTNAME=blackhole SWAP_SIZE=4 # In GB (set to 0 to disable) -ROOT_FS=btrfs # btrfs or ext4 TIMEZONE=America/New_York USERNAME=acidvegas WIFI_SSID= # Leave blank if you don't want to use wifi WIFI_PASS= -WIFI_DEV=wlan0 +WIFI_DEV=wlp3s0 -if [ -d /sys/firmware/efi ]; then - BOOT_OPTION=UEFI -else - BOOT_OPTION=BIOS -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 +# 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}" fi } - setup_network() { if [ ! -z "$WIFI_SSID" ]; then if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then @@ -58,130 +35,66 @@ setup_network() { fi } - setup_partition() { xbps-install -u xbps xbps-install -Su xbps-install parted - wipefs -a $DRIVE - if [ $BOOT_OPTION = "UEFI" ]; then - 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 $ROOT_FS 513MiB 100% - partprobe $DRIVE - mkfs.vfat ${DRIVE}1 - if [ $ROOT_FS = "btrfs" ]; then - mkfs.btrfs -f ${DRIVE}2 - 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 - mount ${DRIVE}1 /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 -} + PART1=$(get_partition $DRIVE 1) + PART2=$(get_partition $DRIVE 2) + wipefs -a $DRIVE + 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 +} setup_install() { REPO=https://repo-default.voidlinux.org/current - if [ $ARCH = 'x86_64-musl' ]; then - REPO=$REPO/musl - fi - mkdir -p /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" xchroot /mnt /bin/bash } - setup_chroot() { passwd xbps-install -u xbps xbps-install -Su - if [ $CPU = "intel" ]; then - xbps-install void-repo-nonfree - xbps-install -Su - xbps-install intel-ucode - ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/ - elif [ $CPU = "amd" ]; then - xbps-install linux-firmware-amd - fi + xbps-install void-repo-nonfree + xbps-install -Su + xbps-install intel-ucode + ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/ useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime - #ln -sf /etc/sv/dhcpcd /etc/runit/runsvdir/default/ hwclock --systohc printf "$HOSTNAME\n" > /etc/hostname 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 "LANG=en_US.UTF-8\n" > /etc/locale.conf - 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 + 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 + 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 if [ $SWAP_SIZE -gt 0 ]; then 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 chmod 0600 /swapfile mkswap /swapfile @@ -189,34 +102,24 @@ setup_chroot() { printf "/swapfile none swap sw 0 0\n" >> /etc/fstab fi - if [ $BOOT_OPTION = "UEFI" ]; then - xbps-install gummiboot - gummiboot install - cp /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/boot/bootx64.efi # copy the EFI for tricking compatability - 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-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 - xbps-reconfigure -fa exit } - - if [ "$#" -ne 1 ]; then - printf "usage: $0 [install|partition|chroot|final]\n" + printf "usage: $0 [network|partition|install|chroot|final]\n" exit 1 fi -check_config - case "$1" in network) setup_network ;; partition) setup_partition ;; install) setup_install ;; chroot) setup_chroot ;; 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 diff --git a/local/share/bash/bash_recon b/local/share/bash/bash_recon index f79f027..64bea10 100644 --- a/local/share/bash/bash_recon +++ b/local/share/bash/bash_recon @@ -55,20 +55,9 @@ crtsh() { } shardz() { - [ "$#" -ne 1 ] || ! echo "$1" | grep -q '^[1-9][0-9]*/[1-9][0-9]*$' && { - echo "Usage: process_with_output | shardz INDEX/TOTAL" >&2 - return 1 - } - - shard=${1%/*} - total=${1#*/} - - [ "$shard" -gt "$total" ] && { - echo "Error: INDEX cannot be greater than TOTAL" >&2 - return 1 - } - - sed -n "$shard~$total p" + # Usage: shardz INDEX/TOTAL + # curl https://example.com/large_file.txt | shardz 1/3 | httpx -title -ip -tech-detect -json -o shard-1.json + awk -v n="$1" -v t="$2" 'NR % t == n' } shodan() {