From d6871d64d0eb5c6c04a61a0d7a04b2e3af8545cb Mon Sep 17 00:00:00 2001 From: lurk Date: Fri, 20 Sep 2024 23:27:28 -0700 Subject: [PATCH] mad changes --- README.md | 28 ++++++++ funcs.sh | 37 ++++++++++ install.sh | 107 ++++++++++++++++++++++++++++ stage3.sh | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 371 insertions(+) create mode 100644 README.md create mode 100644 funcs.sh create mode 100755 install.sh create mode 100644 stage3.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..7f27cb0 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# a horrible customized gentoo-install +i was too lazy to figure out how to fork it from github my apologies + +[source/upstream/whatever it's called i forgot](https://gitlab.com/harha_/gentoo-installer) + +[stole lots of flags and config stuff from here](https://www.reddit.com/r/Gentoo/comments/150r74m/guide_hyprland_nvidia_extremely_minimal_gentoo/) + +## todo + - DO NOT USE!!!!! I'M NOT DONE (actually it would probably work cause i didnt change anything) + - figure out how shell works + - cut down on unneeded features + - automatically install programs i like + - not break things (hopefully) + +## hopefully added features + - cut down on unneeded features + - fully automate certain portions (installing kernel/decent portage flags etc etc) + - default programs because i do not want to modify files just to get xorg working ever again + - actually working efibootmgr + +## some notes for me (in the future) +1. no mbr +2. no full disk encryption +3. only uses efistub (no bootloader) +4. amd64 openrc only (could probably modify this in less than 10 seconds by changing stage3 download) +5. assumes intel cpu and nvidia gpu + +gentoo is awful(ly good) diff --git a/funcs.sh b/funcs.sh new file mode 100644 index 0000000..a13bade --- /dev/null +++ b/funcs.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +check_args() { + if [[ "$1" -ne "$2" ]]; then + echo "check_args error, number of given arguments was $1, must be $2!" + exit 1 + fi +} + +log_msg() { + check_args "$#" "2" + + echo "$(date '+%d/%m/%Y %H:%M:%S') $1: $2" +} + +prompt_accept() { + check_args "$#" "1" + + read -p "$1: " choice + case "$choice" in + y|Y|yes|YES ) echo "y";; + n|N|no|NO ) echo "n";; + * ) echo "n";; + esac +} + +prompt_value() { + check_args "$#" "2" + + read -p "$1 ('.' for default: '$2'): " value + + if [[ "$value" == "." ]]; then + echo $2 + else + echo $value + fi +} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c605dbc --- /dev/null +++ b/install.sh @@ -0,0 +1,107 @@ +#!/bin/bash +set -e + +source funcs.sh + +log_msg INFO "Welcome to the simple Gentoo installer script!" +log_msg INFO "$(cat <<-END +This script assumes the following things: + - networking works + - gpt & uefi + - ext4 filesystems + - openrc +END +)" + +# +# initial install +# + +# make sure all scripts are executable +chmod +x *.sh + +# configure installer +export CFG_BLOCK_DEVICE="$(prompt_value "Target block device handle" "")" +export CFG_PART_PREFIX="$(prompt_value "Partition number prefix (eg. 'p' for NVMe, '' for HDD/SSD)" "")" +export CFG_BLOCK_PART="${CFG_BLOCK_DEVICE}${CFG_PART_PREFIX}" +export CFG_PART_BOOT_SIZE="$(prompt_value "Boot partition size (in MB)" "256")" +export CFG_PART_SWAP_SIZE="$(prompt_value "Swap partition size (in MB)" "4096")" +export CFG_PART_ROOT_SIZE="$(prompt_value "Root partition size (in MB)" "")" +export CFG_PART_HOME_SIZE="$(prompt_value "Home partition size (in %)" "100")%" +export CFG_LLVM="$(prompt_accept "Use LLVM instead of GNU CC")" +export CFG_TIMEZONE="$(prompt_value "System timezone" "America/Los_Angeles")" +export CFG_LOCALE="$(prompt_value "System locale" "en_US")" +export CFG_HOSTNAME="$(prompt_value "System hostname" "gentoo")" +export CFG_NETWORK_INTERFACE="$(prompt_value "Network interface name" "enp0s3")" +export CFG_KEYMAP="$(prompt_value "Keymap to use" "fi")" +export CFG_ROOT_PASSWORD="$(prompt_value "Root user password" "")" + +log_msg INFO "$(cat <> /var/log/installer.log + mkdir -p /boot/efi + mount ${CFG_BLOCK_PART}1 /boot/efi + +log_msg INFO "synchronize gentoo ebuild repo" >> /var/log/installer.log +emerge --ask n --sync + +# TODO: select profile + +log_msg INFO "update @world set (@system and @selected)" >> /var/log/installer.log +emerge --ask n --update --deep --newuse @world + +log_msg INFO "configure licenses" >> /var/log/installer.log +echo "ACCEPT_LICENSE=\"*\"" >> /etc/portage/make.conf + +log_msg INFO "configure timezone (glibc)" >> /var/log/installer.log +echo ${CFG_TIMEZONE} > /etc/timezone +emerge --ask n sys-libs/timezone-data + +log_msg INFO "configure locales (glibc)" >> /var/log/installer.log +echo "fi_FI.UTF-8 UTF-8" >> /etc/locale.gen +echo "fi_FI ISO-8859-1" >> /etc/locale.gen +echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen + + +log_msg INFO "reload environment" >> /var/log/installer.log +env-update && source /etc/profile && export PS1="(chroot) ${PS1}" + +# +# firmware install +# + +# +# kernel install +# + +log_msg INFO "install kernel sources" >> /var/log/installer.log +emerge --ask n sys-kernel/gentoo-sources + +log_msg INFO "select kernel sources" >> /var/log/installer.log +eselect kernel list +eselect kernel set 1 + +log_msg INFO "install genkernel" >> /var/log/installer.log +emerge --ask n sys-kernel/genkernel + +log_msg INFO "set /boot/efi in fstab" >> /var/log/installer.log +echo "${CFG_BLOCK_PART}1 /boot/efi vfat defaults 0 2" >> /etc/fstab + +if [[ "${CFG_LLVM}" == "y" ]]; then + log_msg INFO "compile kernel sources (llvm)" >> /var/log/installer.log + LLVM=1 LLVM_IAS=1 genkernel all \ + --kernel-as=llvm-as \ + --kernel-ar=llvm-ar \ + --kernel-cc=clang \ + --kernel-ld=ld.lld \ + --kernel-nm=llvm-nm \ + --utils-as=llvm-as \ + --utils-ar=llvm-ar \ + --utils-cc=clang \ + --utils-cxx=clang++ \ + --utils-ld=ld.lld \ + --utils-nm=llvm-nm +else + log_msg INFO "compile kernel sources (gcc)" >> /var/log/installer.log + genkernel all +fi + +# +# filesystem install +# + +log_msg INFO "set swap, / and cdrom in fstab" >> /var/log/installer.log +mkdir -p /mnt/cdrom +echo "${CFG_BLOCK_PART}"2 none swap sw 0 0 >> /etc/fstab +echo "${CFG_BLOCK_PART}"3 / ext4 noatime 0 1 >> /etc/fstab +echo /dev/cdrom /mnt/cdrom auto noauto,user 0 0 >> /etc/fstab + +# +# networking install +# + +log_msg INFO "set hostname" >> /var/log/installer.log +echo "hostname=\"${CFG_HOSTNAME}\"" > /etc/conf.d/hostname + +log_msg INFO "install networkmanager" >> /var/log/installer.log +emerge --ask n --noreplace net-misc/networkmanager + +log_msg INFO "install dhcpcd" >> /var/log/installer.log +emerge --ask n net-misc/dhcpcd + +log_msg INFO "install wireless" >> /var/log/installer.log +emerge --ask n net-wireless/iw net-wireless/wpa_supplicant + +log_msg INFO "configure networking" >> /var/log/installer.log + + +log_msg INFO "configure hosts" >> /var/log/installer.log +echo "127.0.0.1 ${CFG_HOSTNAME} localhost" >> /etc/hosts + +# +# system install +# + +log_msg INFO "set root password" >> /var/log/installer.log +echo "root:${CFG_ROOT_PASSWORD}" | chpasswd + +log_msg INFO "set keymap" >> /var/log/installer.log +sed -i '/^keymap/s/=.*$/=$"'"fi"'"/' /etc/conf.d/keymaps +rc-update add keymaps boot +rc-service keymaps restart + +log_msg INFO "install syslog" >> /var/log/installer.log +emerge --ask n app-admin/sysklogd +rc-update add sysklogd default + +log_msg INFO "install crond" >> /var/log/installer.log +emerge --ask n sys-process/cronie +rc-update add cronie default + +log_msg INFO "install file indexer" >> /var/log/installer.log +emerge --ask n sys-apps/mlocate + +log_msg INFO "install filesystem tools" >> /var/log/installer.log +emerge --ask n sys-fs/e2fsprogs +emerge --ask n sys-fs/dosfstools + +# +# bootloader install +# + + +log_msg INFO "install grub2 with efi" >> /var/log/installer.log +echo "GRUB_PLATFORMS=\"efi-64\"" >> /etc/portage/make.conf +emerge --ask n sys-boot/grub + +log_msg INFO "install EFI bootloader" >> /var/log/installer.log +grub-install --target=x86_64-efi --efi-directory=/boot/efi + +log_msg INFO "configure bootloader" >> /var/log/installer.log +grub-mkconfig -o /boot/grub/grub.cfg + +EOF