#!/usr/bin/bash ######################## # What this script is: # # An automatic installer for Gentoo Stable with the following features: # 1. Gentoo with GNOME # 2. Waybar, VeraCrypt # 3. The ability to build a custom and deployable image onto any machine # 4. Easily create a bootable USB drive # 5. Automatic Partitioning # 6. Steam/Wine/Lutris Install # # INSTRUCTIONS # # For new disk installs, initialize the disk to setup partitions from the main menu. # # Before running the install, ensure that you have Internet access. # # Please be sure to change USER,USER_PASSWORD, and ROOT_PASSWORD strings in this file # # To install a new OS to a disk, run gentoo-gnome.sh and choose option 1 from the main menu # ######################## #Configure this section ######################## PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TARGET='/install' mkdir $TARGET ###################################### echo HARD_DISK=$2 ###################################### USER="verita84" USER_PASSWORD="123456" ROOT_PASSWORD="123456" WIRELESS_PASSWORD='123456' SSID='123456' WIRELESS_INTERFACE='wlan0' COMPRESSION='compress=zstd:10' SERVICES+=(gdm cronie libvirt smartd cronie cups NetworkManager dev-zram0.swap) MAKEOPTS="-j$(cat /proc/cpuinfo | grep -i processor | grep -vi 'model' | wc -l)" ROOT_PARTITION_SIZE=30 FEATURES="distcc getbinpkg -binpkg-request-signature" EMERGE_DEFAULT_OPTS="--getbinpkg --jobs 10" #USEFLAG CONFIGURATION USE_FLAGS="gnome kernel-install boot proprietary-codecs libei gdk-pixbuf kernel-install gles2 pulseaudio keyring gtk vpx bluray libaom libdrm libilbc libplacebo libsoxr libv4l libxml2 lv2 openh264 encode iconv ladspa libass libcaca mp3 openal opus theora v4l vorbis xvid x264 gstreamer networkmanager tray wayland alsa X sound-server screencast systemd firmware btrfs policykit networkmanager zlib pipewire minizip network browser " #VIDEO_CARDS="amdgpu radeon radensi"" # #PACKAGE CONFIGURATION BASE_PACKAGES=" sys-power/powertop net-vpn/tor app-shells/bash-completion app-shells/starship sys-apps/fwupd sys-power/cpupower net-p2p/syncthing media-libs/libmypaint media-libs/gexiv2 gnome-base/gnome-keyring app-vim/airline mail-mta/postfix app-admin/sysstat sys-apps/smartmontools sys-process/cronie net-fs/nfs-utils net-firewall/iptables dev-python/pip sys-fs/inotify-tools net-analyzer/nmap app-misc/screen app-portage/gentoolkit sys-fs/dosfstools app-admin/sudo sys-apps/systemd sys-apps/zram-generator app-eselect/eselect-repository dev-vcs/git sys-block/parted sys-block/zram-init sys-process/btop net-vpn/wireguard-tools app-editors/vim app-misc/screenfetch net-misc/yt-dlp sys-fs/btrfs-progs net-print/cups " DESKTOP_APPS=" gnome-base/gnome-light gnome-shell-extension-appindicator gnome-browser-connector sys-power/power-profiles-daemon gnome-system-monitor gnome-shell-extension-dash-to-panel app-text/xournalpp gnome-base/gnome-keyring gnome-extra/gnome-tweaks gnome-extra/gnome-calculator gnome-base/gdm app-arch/file-roller gnome-extra/gnome-shell-extensions gnome-extra/gnome-tweaks www-client/vivaldi-snapshot net-im/element-desktop-bin app-editors/vscodium app-office/libreoffice-bin app-crypt/veracrypt media-video/vlc net-im/telegram-desktop-bin app-admin/keepassxc media-gfx/gimp " # PACKAGES="$BASE_PACKAGES $DESKTOP_APPS" TMPFS_SIZE="32G" CPU_TYPE="x86-64" TAR_EXCLUDES="--exclude=/run/user/* --exclude=/run/media/* --exclude=/var/db/repos/* --exclude=/var/lib/systemd/coredump/* --exclude=/var/cache/distfiles --exclude=/var/lib/flatpak --exclude=/.snapshots --exclude=/snapshots --exclude=/var/backups --exclude=/volumes/* --exclude=/mnt/* --exclude=/var/tmp/* --exclude=/tmp/* --exclude=/raid/* --exclude=/root/* --exclude=/var/cache/apt/archives/* --exclude=/proc/* --exclude=/.snapshots/* --exclude=/var/lib/libvirt/* --exclude=/dev/* --exclude=/sys/* --exclude=/home/* --exclude=/var/lib/postgresql --exclude=/var/lib/containers " DISTCC_HOSTS+=(192.168.0.44/2 192.168.0.146/2 192.168.0.153/2 192.168.0.148/2 192.168.0.63/2 192.168.0.51/4 192.168.0.80/12) DISTCC_LISTEN="192.168.0.0/24" DISTCC_CORES="30" #Add Masked Packages to the Array MASKED_PACKAGES+=(media-video/ffmpeg www-client/vivaldi-snapshot net-im/element-desktop-bin games-util/game-device-udev-rules games-util/lutris games-util/steam-launcher net-im/telegram-desktop-bin) partitionDetection() { #This is used for the installer to do script-based actions EFI=$(blkid | grep $HARD_DISK | sort | cut -d ":" -f1 | head -1 | tail -1) BTRFS=$(blkid | grep $HARD_DISK | sort | cut -d ":" -f1 | head -2 | tail -1) } partitionDetection create-os-snapshots() { echo mkdir $2 DATE=$(date +%Y-%m-%d-%H) echo "[Creating new OS snapshot to $1/gentoo-$HOSTNAME-$DATE.tgz]" echo echo NEW_TAR_EXCLUDES="$TAR_EXCLUDES --exclude=/minio --exclude=$TARGET/* --exclude=/var/lib/docker " echo time tar cvpzf $1/gentoo-$HOSTNAME-$DATE.tgz $NEW_TAR_EXCLUDES / } homeBackup() { echo echo "[Copying USER data from /home to $TARGET/@home]" echo rsync -a --delete /home/ --exclude=.cache --exclude=.local/share/flatpak --exclude=.local/share/containers $TARGET/\@home/ } os-backup() { umount $TARGET echo echo "[Mounting.....]" echo mount -o $COMPRESSION $BTRFS $TARGET if [ "$1" = "home" ]; then homeBackup fi create-os-snapshots "$2" "$3" ls $TARGET/ umount $TARGET } os-restore() { rm -rf $TARGET/usr $TARGET/sbin $TARGET/lib32 $TARGET/libx32 $TARGET/lib $TARGET/vmlinuz* $TARGET/initrd* $TARGET/bin $TARGET/var $TARGET/root $TARGET/opt $TARGET/etc $TARGET/run clear systemMounts echo "[Restoring OS tarfile from $2]" echo tar xfvp $2 -C $TARGET/ if [ "$3" = "home" ]; then echo "[Restoring /home]" echo rsync -a --delete /home/ $TARGET/home/ fi cp -f gentoo-gnome.sh $TARGET/ fstab chmod +x $TARGET/gentoo-gnome.sh chroot $TARGET /gentoo-gnome.sh bootloader $1 $2 $5 chroot $TARGET /gentoo-gnome.sh btrfs-tweaks chroot $TARGET /gentoo-gnome.sh accounts chown -R $USER:$USER $TARGET/home/$USER rm -f $TARGET/gentoo-gnome.sh } systemMounts() { echo echo "[Checking for BTRFS Partition]" if [[ -e "$BTRFS" ]]; then echo "BTRFS device found" echo echo "Mounting Boot,EFI,HOME" echo mount $BTRFS $TARGET btrfs_filesytem mkdir -p $TARGET/efi mount $EFI $TARGET/efi #CONFIGURE DATA DIRS (HOME) mkdir $TARGET/home mount -o subvol=@home $BTRFS $TARGET/home mkdir $TARGET/home/$USER mkdir $TARGET/dev mkdir $TARGET/proc mkdir $TARGET/sys mkdir -p $TARGET/var/tmp/portage mount -o rbind /dev $TARGET/dev mount -o rbind /dev/pts $TARGET/dev/pts mount -o rbind /proc $TARGET/proc mount -o rbind /sys $TARGET/sys mount -t efivarfs none $TARGET/sys/firmware/efi/efivars mount -t tmpfs -o size=$TMPFS_SIZE tmpfs $TARGET/var/tmp/portage else echo echo "Aborting Install, $BTRFS not found!" echo echo exit 1 fi } unmaskPackages() { echo "" >$TARGET/etc/portage/package.accept_keywords for i in "${MASKED_PACKAGES[@]}"; do echo "$i ~amd64" >>$TARGET/etc/portage/package.accept_keywords done } distccConfigure() { if [ -z "$DISTCC_LISTEN" ]; then echo echo echo echo "[Not Using DistCC]" echo else echo echo "[Building DistCC]" echo echo if [ -f "$TARGET/usr/bin/distccd" ]; then echo "Distcc already installed" else chroot $TARGET /usr/bin/emerge -DN sys-devel/distcc fi echo "" >$TARGET/etc/distcc/hosts for i in "${DISTCC_HOSTS[@]}"; do echo $i >>$TARGET/etc/distcc/hosts done echo "[Killing Distccd]" /usr/sbin/killall -9 distccd echo echo "[Starting Distccd]" echo chroot $TARGET /usr/bin/distccd --no-detach --daemon --port 3632 -N 15 --allow $DISTCC_LISTEN & echo echo "[Finished Building DistCC]" echo echo fi } installCockpit() { COCKPIT_PACKAGES+=(app-admin/cockpit-navigator app-admin/cockpit app-crypt/sscg) for i in "${COCKPIT_PACKAGES[@]}"; do echo "$i ~amd64" >>/etc/portage/package.accept_keywords done eselect repository enable inode64-overlay eselect repository enable gig emerge --sync inode64-overlay emerge --sync gig emerge $COCKPIT_PACKAGES --autounmask-write etc-update -q --automode -5 emerge $COCKPIT_PACKAGES } installNvidia() { ACCEPT_KEYWORDS="~amd64" emerge x11-drivers/nvidia-drivers nvidia-cuda-toolkit www-apps/jellyfin net-im/coturn --autounmask-write etc-update -q --automode -5 ACCEPT_KEYWORDS="~amd64" emerge x11-drivers/nvidia-drivers nvidia-cuda-toolkit www-apps/jellyfin net-im/coturn } configurePortage() { sed -i "s/-O2/-march=$CPU_TYPE -O2/i" $TARGET/etc/portage/make.conf echo 'ACCEPT_KEYWORDS="amd64"' >>$TARGET/etc/portage/make.conf echo "FEATURES=\"$FEATURES\"" >>$TARGET/etc/portage/make.conf echo "EMERGE_DEFAULT_OPTS=\"$EMERGE_DEFAULT_OPTS\"" >>$TARGET/etc/portage/make.conf echo "L10N=\"en en-US\"" >>$TARGET/etc/portage/make.conf mkdir -p $TARGET/var/tmp/portage if [ -f "./repos.conf" ]; then echo echo "Found Local Gentoo Repo" mkdir -p $TARGET/etc/portage/repos.conf mkdir -p $TARGET/etc/portage/binrepos.conf cp -f repos.conf $TARGET/etc/portage/repos.conf/ cp -f gentoobinhost.conf $TARGET/etc/portage/binrepos.conf/gentoobinhost.conf echo "GENTOO_MIRRORS=\"https://mirrors.poster.place/\"" >>$TARGET/etc/portage/make.conf echo echo fi chroot $TARGET /usr/bin/emerge --sync echo echo "Configuring Binary Package GPG keys" echo chroot $TARGET /usr/bin/getuto distccConfigure `` echo "USE=\"$USE_FLAGS\"" >>$TARGET/etc/portage/make.conf if [ -z "$DISTCC_LISTEN" ]; then echo echo "Not using DistCC" echo echo "MAKEOPTS=\"$MAKEOPTS\"" >>$TARGET/etc/portage/make.conf else echo echo "Using DistCC" echo MAKEOPTS="-j30 -l$(cat /proc/cpuinfo | grep -i processor | grep -vi 'model' | wc -l)" echo "MAKEOPTS=\"$MAKEOPTS\"" >>$TARGET/etc/portage/make.conf fi echo echo echo echo "[Configuring Profiles]" echo echo echo GENTOO_PROFILE=$(chroot $TARGET /usr/bin/eselect profile list | grep -i desktop | grep -Evi 'plasma' | grep systemd | grep -i merged | head -1 | cut -d '[' -f2 | cut -d ']' -f1) chroot $TARGET /usr/bin/eselect profile set $GENTOO_PROFILE mkdir -p $TARGET/etc/portage/package.license echo "*/* *" >$TARGET/etc/portage/package.license/license rm -rf $TARGET/etc/portage/package.accept_keywords mkdir -p $TARGET/etc/portage/package.mask echo "dev-lang/rust" >$TARGET/etc/portage/package.mask/rust } buildGentoo() { echo "[Install Base System]" echo echo echo echo echo echo "[Building Base System]" echo echo chroot $TARGET /usr/bin/emerge --update --deep --newuse @world --autounmask-write chroot $TARGET etc-update -q --automode -5 chroot $TARGET /usr/bin/emerge --update --deep --newuse @world locale chroot $TARGET /usr/sbin/systemd-machine-id-setup echo echo echo echo "[Installing Kernel]" echo echo chroot $TARGET /usr/bin/emerge -uDN dracut gentoo-kernel-bin sys-kernel/linux-firmware --autounmask-write chroot $TARGET etc-update -q --automode -5 chroot $TARGET /usr/bin/emerge -uDN dracut gentoo-kernel-bin sys-kernel/linux-firmware unmaskPackages echo echo echo echo "[Installing Packages]" echo echo cp -f gentoo-gnome.sh $TARGET/usr/bin/gentoo-gnome.sh chroot $TARGET /usr/bin/bash /usr/bin/gentoo-gnome.sh install-packages echo echo echo echo "[Installing the Boot Loader]" echo echo chroot $TARGET /usr/bin/bash /usr/bin/gentoo-gnome.sh bootloader $1 $ROOT_NAME $BTRFS echo echo echo "[Configuring Accounts and post-setup tasks]" echo echo echo 'bash /usr/bin/gentoo-gnome.sh accounts' >>$TARGET/setup.sh echo 'bash /usr/bin/gentoo-gnome.sh desktop' >>$TARGET/setup.sh echo 'bash /usr/bin/gentoo-gnome.sh btrfs-tweaks' >>$TARGET/setup.sh chmod +x $TARGET/usr/bin/gentoo-gnome.sh chmod +x $TARGET/setup.sh chroot $TARGET /setup.sh rm -f $TARGET/setup.sh } installPackages(){ /usr/bin/emerge -uDN $PACKAGES --autounmask-write /usr/sbin/etc-update -q --automode -5 /usr/bin/emerge -uDN $PACKAGES } snapshots() { echo echo "Creating Snapshots....." echo DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S)) btrfs sub snapshot / /.snapshots/root-${DATE} } remove-snapshots() { btrfs sub delete /.snapshots/* rm -f /boot/loader/entries/root-* } btrfs_filesytem() { btrfs sub create $TARGET/@$ROOT_NAME btrfs sub create $TARGET/@.snapshots btrfs sub create $TARGET/@libvirt btrfs sub create $TARGET/@home btrfs sub create $TARGET/@root echo echo "Binding BTRFS Root" echo umount $TARGET mount -o $COMPRESSION,subvol=@$ROOT_NAME $BTRFS $TARGET } services() { echo '[zram0]' >/etc/systemd/zram-generator.conf echo 'zram-size = ram * 2' >>/etc/systemd/zram-generator.conf for i in "${SERVICES[@]}"; do systemctl enable --now $i done #Required for Audio to work systemctl --user enable --now pipewire.socket pipewire-pulse.socket wireplumber.service systemctl --user enable --now pipewire.service } desktop() { services } installSteam() { eselect repository enable steam-overlay emerge --sync steam-overlay emerge -uDN games-util/steam-launcher app-emulation/wine-vanilla games-util/lutris --autounmask-write etc-update -q --automode -5 emerge -uDN @world emerge -uDN games-util/steam-launcher app-emulation/wine-vanilla games-util/lutris } locale() { echo "ln -sf /usr/share/zoneinfo/US/Mountain /etc/localtime" >>$TARGET/setup.sh echo "hwclock --systohc" >>$TARGET/setup.sh echo "en_US.UTF-8 UTF-8" >$TARGET/etc/locale.gen echo "locale-gen" >>$TARGET/setup.sh } fstab() { mkdir $TARGET/etc echo "UUID=$(/sbin/blkid -s UUID -o value ${EFI}) /efi vfat umask=0077 0 1" >>$TARGET/etc/fstab echo "$BTRFS / btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@$ROOT_NAME 0 1" >>$TARGET/etc/fstab echo "$BTRFS /.snapshots btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@.snapshots 0 1" >>$TARGET/etc/fstab echo "$BTRFS /var/lib/libvirt btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@libvirt 0 1" >>$TARGET/etc/fstab echo "tmpfs /var/log tmpfs defaults,dev,exec 0 0" >>$TARGET/etc/fstab echo "tmpfs /tmp tmpfs defaults 0 0" >>$TARGET/etc/fstab echo "tmpfs /var/tmp/portage tmpfs defaults,size=$TMPFS_SIZE 0 0" >>$TARGET/etc/fstab #echo "$BTRFS /home btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@home 0 1" >>$TARGET/etc/fstab echo "$BTRFS /root btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@root 0 1" >>$TARGET/etc/fstab } accounts() { echo echo "Set Password for $USER" useradd -m -s /bin/bash $USER echo "$USER:$USER_PASSWORD" | chpasswd gpasswd -a $USER wheel gpasswd -a $USER network gpasswd -a $USER video gpasswd -a $USER libvirt gpasswd -a $USER netdev gpasswd -a $USER adm gpasswd -a $USER video echo "$USER ALL=(ALL) ALL" >/etc/sudoers echo "root ALL=(ALL) ALL" >>/etc/sudoers echo echo "Setting ROOT Password:" echo "root:$ROOT_PASSWORD" | chpasswd /usr/bin/hostnamectl set-hostname $ROOT_NAME } btrfs-tweaks() { DISABLE_COW=("/var/lib/docker" "/volumes" "/var/lib/mysql" "/var/lib/libvirt") for i in "${DISABLE_COW[@]}"; do chattr -R +C $i done } initialize-disk() { ROOT_PARTITION_SIZE="$ROOT_PARTITION_SIZE GB" SWAP_SIZE=$(expr $(cat /proc/meminfo | head -1 | cut -d ':' -f2 | sed 's/ //g' | sed 's/kB//') / 1024) SWAP_SIZE_END="$(expr $SWAP_SIZE + $ROOT_PARTITION_SIZE) GB" echo "Start: $SWAP_SIZE END: $SWAP_SIZE_END" parted /dev/$HARD_DISK mklabel gpt parted -a optimal /dev/$HARD_DISK mkpart primary fat32 1MiB 200MiB parted -a optimal /dev/$HARD_DISK mkpart root ext3 200MiB $ROOT_PARTITION_SIZE parted -a optimal /dev/$HARD_DISK set 1 esp on parted -a optimal /dev/$HARD_DISK mkpart swap ext3 $ROOT_PARTITION_SIZE $SWAP_SIZE_END parted -a optimal /dev/$HARD_DISK mkpart home ext3 $SWAP_SIZE 100% partitionDetection echo echo "Formatting....." echo y | mkfs.btrfs $BTRFS --force echo "Formatting $EFI" echo echo y | mkfs.vfat $EFI echo echo "Initialize Complete. Please reboot your machine to avoid any issues" echo } wifi() { iwctl --passphrase $WIRELESS_PASSWORD station $WIRELESS_INTERFACE connect $SSID } show-help() { clear echo echo "[gentoo-gnome.sh arguments]" echo echo "./gentoo-gnome.sh wifi" echo "./gentoo-gnome.sh bootloader [disk] [ROOT_NAME] [ROOT_MAPPER_NAME]" echo "./gentoo-gnome.sh initialize" echo "./gentoo-gnome.sh tar [device name] [location]" echo "./gentoo-gnome.sh snapshot" echo "./gentoo-gnome.sh reomve-snapshot" echo "./gentoo-gnome.sh btrfs-tweaks" echo } tweaks() { clear echo echo "Gentoo Installer System Tweaks]" echo echo "[1] Reinstall Bootloader" echo "[2] Chroot into existing OS" echo "[3] Compile the Kernel" echo "[4] Upgrade gentoo-gnome.sh" echo read -p 'Your Choice: ' choice if [[ $choice = 1 ]]; then set-devices bootloader $1 $ROOT_NAME $BTRFS elif [[ $choice = 2 ]]; then set-devices systemMounts /usr/bin/chroot $TARGET /bin/bash elif [[ $choice = 3 ]]; then compile-kernel elif [[ $choice = 4 ]]; then rm -f gentoo-gnome.sh rm -f repos.conf rm -f gentoobinhost.conf rm -f /tmp/latest-stage3-amd64-desktop-systemd.txt wget https://git.poster.place/verita84/gnome/raw/branch/main/gentoo-gnome.sh wget https://git.poster.place/verita84/gnome/raw/branch/main/repos.conf/repos.conf wget https://git.poster.place/verita84/gnome/raw/branch/main/repos.conf/gentoobinhost.conf BASE_URL="https://mirrors.poster.place/releases/amd64/autobuilds/current-stage3-amd64-desktop-systemd-mergedusr" wget "$BASE_URL/latest-stage3-amd64-desktop-systemd-mergedusr.txt" wget $BASE_URL/$(cat latest-stage3-amd64-desktop-systemd-mergedusr.txt | grep tar.xz | tail -1 | cut -d '.' -f1-3 | cut -d '"' -f2 | cut -d ' ' -f1) -O /tmp/stage3.tar.xz else tweaks fi } download-setup() { clear echo "[Choose Deployment Type]" echo echo set-devices STAGE3_URL=$(curl https://www.gentoo.org/downloads/ | grep -i stage3-amd64-systemd | head -1 | cut -d '"' -f2-3 | cut -d '"' -f1) STAGE3_FILE="/tmp/stage3.tar.xz" if [ -f "$STAGE3_FILE" ]; then echo echo "Stage 3 already downloaded....." echo else wget -O /tmp/stage3.tar.xz "$STAGE3_URL" fi if [ -f "$STAGE3_FILE" ]; then echo echo echo "Extracting Tar File.........." echo echo systemMounts echo echo "Extracting $STAGE3_FILE" echo tar xf $STAGE3_FILE -C $TARGET/ fstab cp -f /etc/resolv.conf $TARGET/etc/ configurePortage cp -f gentoo-gnome.sh $TARGET/usr/bin/ fi } menu() { clear echo echo "[Welcome to the Poster.place Gentoo Installer System]" echo echo "[1] Setup Disk" echo "[2] Download Gentoo Installation Files" echo "[3] Install System" echo "[4] Automatic Install" echo "[5] Backup" echo "[6] Restore" echo "[7] Tools and Tweaks" echo "[8] Initialize Disk" echo read -p 'Your Choice: ' choice if [[ $choice = 1 ]]; then set-devices read -p "Press enter key to Continue" menug elif [[ $choice = 2 ]]; then download-setup read -p "Press enter key to Continue" menu elif [[ $choice = 3 ]]; then set-devices buildGentoo read -p "Press enter key to Continue" menu elif [[ $choice = 4 ]]; then set-devices download-setup buildGentoo exit 1 elif [[ $choice = 5 ]]; then clear echo "[Backup OS]" echo read -p 'Backup Home Directory? : ' -e -i 'n' home_backup read -p 'OS Backup Directory Location : ' -e -i "/mnt" backup_directory if [[ $home_backup = *n* ]]; then os-backup "none" "$backup_directory" "$ROOT_NAME" else os-backup "home" "$backup_directory" "$ROOT_NAME" fi elif [[ $choice = 6 ]]; then clear echo "[Restore from Backup]" echo echo rm -f /tmp/disk set-devices read -p 'Hostname for Restore: ' -e -i "gentoo" HOSTNAME read -p 'Restore Directory Image Source: ' -e -i "/mnt" restore_directory FILE_SCAN=$(ls $restore_directory/gentoo-$HOSTNAME-* | tail -1) read -p 'Restore Home Directory? : ' -e -i 'n' home_restore read -p 'Backup file name to restore: ' -e -i "$FILE_SCAN" backup_name if [[ $home_restore = *n* ]]; then os-restore "$HARD_DISK" "$backup_name" "none" "$restore_directory" "$BTRFS" else os-restore "$HARD_DISK" "$backup_name" "home" "$restore_directory" "$BTRFS" fi elif [[ $choice = 7 ]]; then tweaks elif [[ $choice = 8 ]]; then clear echo "[Initialize Disk]" echo echo set-devices initialize-disk read -p "Press enter key to Continue" menu else menu fi } set-devices() { if [ -f "/tmp/disk" ]; then HARD_DISK=$(cat /tmp/disk | head -1) ROOT_NAME=$(cat /tmp/disk | tail -1) else i=0 while [ $i != "n" ]; do clear echo echo "Disks and Partitions:" echo cat /proc/partitions echo echo "Erase the line and press enter to skip to the next detected disk" echo i=$(expr $i + 1) read -p 'Disk Device to Use: ' -e -i $(lsblk | grep -i disk | grep -Evi 'zram|swap' | cut -d ' ' -f1 | head -$i | tail -1) device if [[ ! -z $device ]]; then i="n" fi done read -p 'BTRFS Root Volume name: ' -e -i "gentoo" root_name HARD_DISK=$device ROOT_NAME=$root_name echo $HARD_DISK >/tmp/disk echo $ROOT_NAME >>/tmp/disk fi partitionDetection } bootloader() { echo echo "Configuring Bootloader......." echo echo #MACHINE_ID=$(cat /etc/machine-id) MACHINE_ID=$(ls /efi | grep -Evi 'loader|efi') KERNEL=$(eselect kernel list | cut -d ']' -f2 | cut -d "*" -f1 | cut -d "-" -f2 | tail -1) KERNEL_VERSION=$(ls /efi/$MACHINE_ID) ROOT_NAME=$1 BTRFS=$2 LOADER_FILE="/efi/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" echo "MachineID=$MACHINE_ID" echo "KERNEL IS $KERNEL" echo "Root_Name=$ROOT_NAME" echo "BTRFS=$BTRFS" echo "UEFI Kernel: $KERNEL_VERSION" sleep 5 echo "default $MACHINE_ID" >/efi/loader/loader.conf echo "timeout 3" >>/efi/loader/loader.conf echo "title Gentoo Linux" >$LOADER_FILE echo "version $KERNEL_VERSION" >>$LOADER_FILE echo "sort-key ${ROOT_NAME}" >>$LOADER_FILE echo "options root=UUID=$(/sbin/blkid -s UUID -o value $BTRFS) rootflags=subvol=@${ROOT_NAME} rw " >>$LOADER_FILE echo "machine-id $MACHINE_ID" >>$LOADER_FILE echo "linux /$MACHINE_ID/$KERNEL_VERSION/linux" >>$LOADER_FILE echo "initrd /$MACHINE_ID/$KERNEL_VERSION/initrd" >>$LOADER_FILE bootctl install } compile-kernel() { cd /usr/src eselect kernel set 1 cd /usr/src/linux if [ -f "/usr/src/linux/.config" ]; then make oldconfig else make allyesconfig fi time make -j30 CC="distcc gcc" time make -j30 CC="distcc gcc" modules_install time make install } if [ "$1" = "desktop" ]; then desktop elif [ "$1" = "tar" ]; then create-os-snapshots "$3" "$2" elif [ "$1" = "upgrade-system" ]; then upgrade-system elif [ "$1" = "wifi" ]; then wifi elif [ "$1" = "accounts" ]; then accounts elif [ "$1" = "hibernate" ]; then hibernate-setup elif [ "$1" = "bootloader" ]; then bootloader "$2" "$3" "$4" elif [ "$1" = "snapshot" ]; then snapshots elif [ "$1" = "steam" ]; then installSteam elif [ "$1" = "install-packages" ]; then installPackages elif [ "$1" = "cockpit" ]; then installCockpit elif [ "$1" = "btrfs-tweaks" ]; then btrfs-tweaks elif [ "$1" = "compile-kernel" ]; then compile-kernel elif [ "$1" = "remove-snapshot" ]; then remove-snapshots elif [ "$1" = "help" ]; then show-help else menu fi