From 48c7b640f8624305197400af72ffeae35ea5698c Mon Sep 17 00:00:00 2001 From: verita84 Date: Mon, 12 Feb 2024 22:31:53 -0700 Subject: [PATCH] Update arch.sh --- arch.sh | 1058 ++++++++++++++++++++----------------------------------- 1 file changed, 387 insertions(+), 671 deletions(-) diff --git a/arch.sh b/arch.sh index 100f6d4..0e9e2f7 100755 --- a/arch.sh +++ b/arch.sh @@ -1,33 +1,17 @@ #!/bin/bash -######################## -# What this script is: -# -# An automatic installer for Gentoo Stable with the following features: -# 1. BTRFS with Grub Snapshots -# 2. KDE Desktop -# 3. The ability to build a custom and deployable image onto any machine -# 4. Easily create a bootable USB drive -# 5. Automatic Partitioning -# -# 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.sh and choose option 1 from the main menu -# +clear ######################## #Configure this section ######################## -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -TARGET='/install' -mkdir $TARGET +TARGET='/mnt' ###################################### +clear echo -HARD_DISK=$2 +HARD_DISK=nvme0n1 +EFI="/dev/$(lsblk | grep $HARD_DISK | head -2 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)" +BTRFS="/dev/$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)" +ROOT_NAME='arch' +USB_BACKUP='/dev/disk/by-uuid/770db62e-1893-42ce-be37-c70fa6578fba' ###################################### USER="verita84" USER_PASSWORD="123456" @@ -35,725 +19,457 @@ ROOT_PASSWORD="123456" WIRELESS_PASSWORD='123456' SSID='123456' WIRELESS_INTERFACE='wlan0' -COMPRESSION='compress=zstd:10' -FLATPAKS+=() -SERVICES+=(cronie gdm libvirt smartd cronie cups grub-btrfsd sddm NetworkManager dev-zram0.swap) -MAKEOPTS="-j$(cat /proc/cpuinfo | grep -i processor | grep -vi 'model' | wc -l)" -KDE_DESKTOP_USE_FLAGS="-samba -telemetry -bluetooth wxwidgets jumbo-build kernel-install hwaccel sasl -gpm proprietary-codecs screencast systemd x264 pulseaudio firmware nfsv4 caps -zeroconf dbus sound-server X -browser-integration desktop-portal minimal -gnome qt5 kde dvd alsa gui -wayland device-mapper efiemu themes truetype btrfs seccomp cgroup-hybrid geoclue -webengine boot browser keeshare network opengl" -GNOME_DESKTOP_USE_FLAGS="keyring -samba minizip -gnome-online-accounts -telemetry -bluetooth wxwidgets jumbo-build kernel-install hwaccel sasl -gpm proprietary-codecs screencast systemd x264 pulseaudio firmware nfsv4 caps -zeroconf dbus sound-server X -browser-integration desktop-portal minimal gtk gnome qt5 -kde dvd alsa gui wayland device-mapper efiemu themes truetype btrfs seccomp cgroup-hybrid geoclue -webengine boot browser keeshare network opengl" -SERVER_USE_FLAGS="-samba -gtk kernel-install -pipewire -bluetooth udev -sound -ipv6 sasl usb usbredir spice vhost-net virtfs -vnc -wayland -gpm -proprietary-codecs -screencast systemd pulseaudio sound-server -x264 firmware nfsv4 caps -zeroconf dbus -X -browser-integration desktop-portal minimal -gnome -qt5 -kde -dvd -alsa -gui device-mapper efiemu themes truetype btrfs seccomp cgroup-hybrid geoclue -webengine boot -browser -keeshare network -opengl" -BASE_PACKAGES=" app-containers/netavark 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 x11-apps/xhost app-misc/screen app-portage/gentoolkit sys-fs/dosfstools app-admin/sudo sys-apps/systemd sys-boot/plymouth sys-apps/zram-generator app-eselect/eselect-repository dev-vcs/git sys-boot/refind sys-block/parted sys-boot/grub sys-block/zram-init sys-process/btop net-vpn/wireguard-tools sys-apps/flatpak app-editors/vim app-misc/fastfetch net-misc/yt-dlp app-containers/crun app-containers/podman sys-fs/btrfs-progs net-print/cups " -GNOME_DESKTOP_PACKAGES=" app-text/evince gnome-extra/gnome-system-monitor dev-libs/qtkeychain gnome-extra/gnome-browser-connector sys-power/power-profiles-daemon gnome-extra/gnome-shell-extensions gnome-extra/gnome-calculator gnome-extra/gnome-tweaks app-office/libreoffice media-gfx/gimp gnome-light www-client/firefox app-editors/vscodium app-admin/keepassxc net-im/telegram-desktop-bin net-misc/nextcloud-client media-video/vlc " -KDE_DESKTOP_PACKAGES=" x11-drivers/xf86-input-evdev kde-apps/kcalc kde-apps/dolphin kde-apps/ark www-client/firefox plasma-meta app-editors/vscodium kde-apps/konsole media-gfx/krita kde-apps/kdegraphics-meta app-admin/keepassxc app-office/calligra net-im/telegram-desktop-bin net-misc/nextcloud-client net-im/neochat x11-misc/sddm media-video/vlc " -#Change/Set Desktop: GNOME/KDE -DESKTOP_ENVIRONMENT="gnome" -DESKTOP_PACKAGES=$GNOME_DESKTOP_PACKAGES -DESKTOP_USE_FLAGS=$GNOME_DESKTOP_USE_FLAGS -# -USE_FLAGS="" -PACKAGES="" -INSTALL_TYPE="desktop" -TMPFS_SIZE="32G" -CPU_TYPE="znver3" -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+=(dev-libs/nss www-client/firefox net-im/element-desktop-bin media-libs/harfbuzz games-util/game-device-udev-rules dev-lang/python dev-python/pyrate-limiter dev-python/moddb dev-python/pypresence games-util/lutris games-util/steam-launcher app-misc/fastfetch net-im/telegram-desktop-bin dev-libs/yyjson) +DISK_PASSWORD='123456' -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) - BOOT=$(blkid | grep $HARD_DISK | sort | cut -d ":" -f1 | head -2 | tail -1) - BTRFS=$(blkid | grep $HARD_DISK | sort | cut -d ":" -f1 | head -3 | tail -1) +#AUR Configuration +AUR="/home/$USER/aur" +aur_array+=( trizen ) +FLATPAKS+=( app/org.mozilla.firefox org.gnome.Evolution app/com.vscodium.codium app/org.libreoffice.LibreOffice org.gajim.Gajim org.gajim.Gajim.Plugin.omemo org.telegram.desktop app/im.riot.Riot app/io.mpv.Mpv app/org.gimp.GIMP fr.handbrake.ghb org.kde.kdenlive ) + +#Packages +SHARED_DESKTOP_APPS=" gnome yt-dlp " +PACKAGES=" neofetch toolbox fuse python-axolotl python-qrcode sysstat postgresql redis nfs-utils syncthing samba redis aardvark-dns cockpit cockpit-machines cockpit-podman flatpak bluez bluez-utils powertop blueman pulseaudio-bluetooth avahi pulseaudio pulseaudio-bluetooth cups acpi packagekit cockpit-packagekit cockpit-pcp cockpit-storaged acpid cpupower podman podman-compose samba nfs-utils avahi cronie pulseaudio acpilight aardvark-dns sof-firmware ghostscript arch-install-scripts zsh grml-zsh-config btrfs-progs unzip nfs-utils bash-completion openssh python-pynacl parted dosfstools wget curl cifs-utils ntp mkinitcpio vim-airline rsync screen base linux-lts linux-firmware udev git networkmanager nss-mdns efibootmgr wireless_tools wpa_supplicant autoconf automake binutils fakeroot file findutils flex gawk gcc gettext grep groff gzip libtool m4 make patch pkgconf sed sudo texinfo which networkmanager-openvpn gobject-introspection ntp screen docbook-xsl alsa-utils" +VIRTUALIZATION=" gnu-netcat virt-manager libvirt iptables-nft dnsmasq dmidecode edk2-ovmf qemu-base jack " +PACKAGES=$PACKAGES$SHARED_DESKTOP_APPS$VIRTUALIZATION +SERVICES+=( cronie zram bluetooth cpupower podman powertop podman-hack gdm acpid avahi-daemon cups NetworkManager ntpd libvirtd sshd ); + +auto_login(){ + sed -i "/#WaylandEnable=false/a AutomaticLoginEnable=True" $TARGET/etc/gdm/custom.conf + sed -i "/True/a AutomaticLogin=$USER" $TARGET/etc/gdm/custom.conf } -partitionDetection - -auto_login() { - mkdir -p $TARGET/etc/sddm.conf.d - echo "[Autologin]" >$TARGET/etc/sddm.conf.d/autologin - echo "User=$USER" >>$TARGET/etc/sddm.conf.d/autologin - echo "Session=plasma.desktop" >>$TARGET/etc/sddm.conf.d/autologin - echo "Relogin=false" >>$TARGET/etc/sddm.conf.d/autologin +clean-old-usb-snapshots(){ + echo;echo "[Cleaning up old USB snapshots.....]";echo + btrfs sub delete $TARGET/$ROOT_NAME-$1 + btrfs sub delete $TARGET/flatpak + echo;echo "[Cleaning up old EFI data.....]";echo + rm -rf $TARGET/efi-$1 } -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 / +clean-old-snapshots() { + echo;echo "[Cleaning up old snapshots.....]";echo + btrfs sub delete /.snapshots/$ROOT_NAME-$1 + btrfs sub delete /.snapshots/flatpak +} + +create-usb-snapshots(){ + echo;echo "[Creating new ROOT and Flatpak snapshots.....]";echo + btrfs sub snap -r / /.snapshots/$ROOT_NAME-$1 + btrfs sub snap -r /var/lib/flatpak /.snapshots/flatpak +} + +send-snapshots(){ + echo;echo "[Sending snapshot to $USB_BACKUP]";echo + btrfs send /.snapshots/$ROOT_NAME-$1 | btrfs receive $TARGET + echo;echo "[Sending Flatpaks to $USB_BACKUP]";echo + btrfs send /.snapshots/flatpak | btrfs receive $TARGET +} + +copy-efi-to-usb(){ + echo;echo "[Copying EFI data....]";echo + mkdir $TARGET/efi-$1 + mkdir $TARGET/$1 + cp -rf /boot/* $TARGET/efi-$1/ } 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/ + echo;echo "[Copying USER data....]";echo + rsync -av --delete /home/ /mnt/home/ } -os-backup() { - umount $TARGET +usb-backup() { + umount $TARGET - echo - echo "[Mounting.....]" - echo - mount -o $COMPRESSION $BTRFS $TARGET + echo;echo "[Mounting $USB_BACKUP]";echo + mount $USB_BACKUP $TARGET - if [ "$1" = "home" ]; then - homeBackup - fi - create-os-snapshots "$2" "$3" - - ls $TARGET/ - umount $TARGET + homeBackup + clean-old-snapshots "$1" + clean-old-usb-snapshots "$1" + create-usb-snapshots "$1" + send-snapshots "$1" + clean-old-snapshots "$1" + copy-efi-to-usb "$1" + cp -f /usr/bin/arch.sh $TARGET/$1 + 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.sh $TARGET/ - fstab - chmod +x $TARGET/gentoo.sh - chroot $TARGET /gentoo.sh bootloader $1 $2 $5 - chroot $TARGET /gentoo.sh btrfs-tweaks - chroot $TARGET /gentoo.sh accounts - chown -R $USER:$USER $TARGET/home/$USER - auto_login - rm -f $TARGET/gentoo.sh +usb-restore() { + partitions + rsync -av ../$ROOT_NAME-$1/ $TARGET/ --exclude=/home --delete + rsync -av ../flatpak/ $TARGET/var/lib/flatpak/ --delete + cp -rf ../efi-$1/* $TARGET/boot/ + fstab + cp -f arch.sh $TARGET/ + arch-chroot $TARGET /arch.sh bootloader + arch-chroot $TARGET /arch.sh btrfs-tweaks + #arch-chroot $TARGET /arch.sh aur + rm -f $TARGET/arch.sh + unmount } -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/boot - mount -t ext4 $BOOT $TARGET/boot - mkdir -p $TARGET/boot/efi - mount $EFI $TARGET/boot/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 +installSoftware() { + while true; do + if [ ! -f "$TARGET/usr/bin/zsh" ]; then + echo "Downloading packages......." + printf '\n Y' | /usr/sbin/pacstrap $TARGET $PACKAGES + sleep 10 + else + break + fi + done } -unmaskPackages() { - echo "" >$TARGET/etc/portage/package.accept_keywords - for i in "${MASKED_PACKAGES[@]}"; do - echo "$i ~amd64" >>$TARGET/etc/portage/package.accept_keywords - done - +install() { + partitions + sed -i '/^SigLevel/s/^\(.*\)$/#\1\n/' /etc/pacman.conf + sed -i '/#SigLevel/a SigLevel = Never' /etc/pacman.conf + pacman -Sy archlinux-keyring --noconfirm + installSoftware + locale + accounts + auto_login + zram + custom_service_files + services + btrfs-tweaks + cpuPower + setup_script + unmount } -finishInstall() { - unmaskPackages - distccConfigure - chroot $TARGET /usr/bin/bash /tmp/packages.sh -} - -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 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 & - fi -} - -installCockpit() { - COCKPIT_PACKAGES+=(app-admin/cockpit-podman 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 -} - -buildGentoo() { - - if [ ! -d "$TARGET/var/db/repos/gentoo/x11-misc" ]; then - chroot $TARGET /usr/bin/emerge --sync - fi - - distccConfigure - - echo - echo - echo - echo "[Configuring Profiles]" - echo - echo - echo - if [[ $INSTALL_TYPE = *desktop* ]]; then - GENTOO_PROFILE=$(chroot $TARGET /usr/bin/eselect profile list | grep -i $DESKTOP_ENVIRONMENT | grep systemd | grep -i merged | head -1 | cut -d '[' -f2 | cut -d ']' -f1) - chroot $TARGET /usr/bin/eselect profile set $GENTOO_PROFILE - echo ">=x11-misc/$(find $TARGET/var/db/repos/gentoo/x11-misc/appmenu-gtk-module/ | grep ebuild | tail -1 | cut -d '/' -f9 | sed 's/.ebuild//i') wayland" >>$TARGET/etc/portage/package.use/zz-autounmask - else - chroot $TARGET /usr/bin/eselect profile set $(/usr/bin/eselect profile list | grep -Evi 'gnome|plasma' | grep systemd | grep -i merged | head -1 | cut -d '[' -f2 | cut -d ']' -f1) - fi - - mkdir -p $TARGET/etc/portage/package.license - echo "*/* *" >$TARGET/etc/portage/package.license/license - rm -rf $TARGET/etc/portage/package.accept_keywords - - echo - echo - echo - echo "[Installing Kernel]" - echo - echo - chroot $TARGET /usr/bin/emerge gentoo-kernel-bin sys-kernel/linux-firmware - - echo - echo - echo - echo "[Building Base System]" - echo - echo - chroot $TARGET /usr/bin/emerge --verbose --update --deep --newuse @world --autounmask-write - chroot $TARGET etc-update -q --automode -5 - chroot $TARGET /usr/bin/emerge --verbose --update --deep --newuse @world - locale - - echo "/usr/bin/emerge $PACKAGES --autounmask-write" >$TARGET/tmp/packages.sh - echo "/usr/sbin/etc-update -q --automode -5" >>$TARGET/tmp/packages.sh - echo "/usr/bin/emerge $PACKAGES" >>$TARGET/tmp/packages.sh +pacman-snapshot-hook(){ + echo "[Trigger]" > /usr/share/libalpm/hooks/04-snapshot.hook + echo "Operation = Upgrade" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "Operation = Install" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "Operation = Remove" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "Type = Package" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "Target = *" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "[Action]" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "Description = Creating Snapshot" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "When = PreTransaction" >> /usr/share/libalpm/hooks/04-snapshot.hook + echo "Exec = /usr/bin/arch.sh snapshot" >> /usr/share/libalpm/hooks/04-snapshot.hook } snapshots() { - echo - echo "Creating Snapshots....." - echo - DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S)) - btrfs sub snapshot / /.snapshots/root-${DATE} + echo + echo "Creating Snapshots....." + echo + DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S)) + btrfs sub snapshot / /.snapshots/root-${DATE} + bootloader_entry "${DATE}" ".snapshots/root-${DATE}" } remove-snapshots() { - btrfs sub delete /.snapshots/* - rm -f /boot/loader/entries/root-* + btrfs sub delete /.snapshots/* + rm -f /boot/loader/entries/root-* +} + +chroot() { + printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root + mounts + arch-chroot $TARGET /bin/bash } flatpaks() { - echo - echo "Installing Flatpaks......" - echo - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - for i in "${FLATPAKS[@]}"; do - echo $i - flatpak install --user $i -y - done + for i in "${FLATPAKS[@]}"; do + flatpak install $i -y + done } -grub-snapshots() { - cd /opt - git clone https://github.com/Antynea/grub-btrfs.git - cd /opt/grub-btrfs - make - make install - systemctl enable --now grub-btrfsd.service +bootloader_entry(){ + ## $1=Boot Entry Name + ## $2=Volume Name + echo "default arch.conf" >/boot/loader/loader.conf + echo 'timeout 3 ' >>/boot/loader/loader.conf + echo "title $1" >/boot/loader/entries/$1.conf + echo 'linux /vmlinuz-linux-lts' >>/boot/loader/entries/$1.conf + echo 'initrd /initramfs-linux-lts.img' >>/boot/loader/entries/$1.conf + echo "options mitigations=off cryptdevice=UUID=$(blkid | grep ${BTRFS} | cut -d '"' -f2):root root=\"LABEL=arch\" rootflags=subvol=@$2 rw" >>/boot/loader/entries/$1.conf } + bootloader() { - if [ -z "$1" ]; then - echo - echo "Error: No Disk specified!" - echo - else - ROOT_NAME="$2" - plymouth-set-default-theme solar - echo "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash mitigations=off\"" >/etc/default/grub - echo "GRUB_CMDLINE_LINUX=init=/usr/lib/systemd/systemd root=UUID=$(/sbin/blkid | grep $BTRFS | cut -d '"' -f2) rootflags=subvol=@${ROOT_NAME}" >>/etc/default/grub - echo "GRUB_ENABLE_CRYPTODISK=n" >>/etc/default/grub - echo "GRUB_DISABLE_OS_PROBER=true" >>/etc/default/grub - echo "GRUB_TIMEOUT=1" >>/etc/default/grub - echo "GRUB_THEME=/boot/grub/themes/starfield/theme.txt" >>/etc/default/grub - grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=gentoo - grub-mkconfig -o /boot/grub/grub.cfg - refind-install - fi + echo 'HOOKS=(base udev modconf block encrypt btrfs filesystems keyboard keymap lvm2 fsck)' >/etc/mkinitcpio.conf + mkinitcpio -P + bootctl install + bootloader_entry "$ROOT_NAME" "arch" +} + function setup_script() { + cp -f arch.sh $TARGET/usr/bin/ + + echo 'bash /usr/bin/arch.sh bootloader' >>$TARGET/setup.sh + #echo 'bash /usr/bin/arch.sh aur' >>$TARGET/setup.sh + echo 'bash /usr/bin/arch.sh flatpaks' >>$TARGET/setup.sh + echo 'bash /usr/bin/arch.sh btrfs-tweaks' >>$TARGET/setup.sh + echo 'bash /usr/bin/arch.sh pacman-snapshot-hook' >>$TARGET/setup.sh + + chmod +x $TARGET/usr/bin/arch.sh + chmod +x $TARGET/setup.sh + arch-chroot $TARGET /setup.sh + sed -i '/#NoUpgrade/a IgnorePkg = linux-lts' $TARGET/etc/pacman.conf + rm -f $TARGET/setup.sh +} + +function cpuPower() { + #CPU POWERSAVE AND ACPI Events + echo "governor='powersave'" >>$TARGET/etc/default/cpupower + echo "min_freq='400MHz'" >>$TARGET/etc/default/cpupower + echo "max_freq='2GHz'" >>$TARGET/etc/default/cpupower } 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 - btrfs sub create $TARGET/@containers - btrfs sub create $TARGET/@flatpak - echo - echo "Binding BTRFS Root" - echo - umount $TARGET - mount -o $COMPRESSION,subvol=@$ROOT_NAME $BTRFS $TARGET + btrfs sub create $TARGET/@$ROOT_NAME + btrfs sub create $TARGET/@.snapshots + btrfs sub create $TARGET/@flatpak + btrfs sub create $TARGET/@libvirt + btrfs sub create $TARGET/@home + btrfs sub create $TARGET/@root + btrfs sub create $TARGET/@postgres + btrfs sub create $TARGET/@containers + echo + echo "Binding BTRFS Root" + echo + umount /mnt + mount -o subvol=@$ROOT_NAME /dev/mapper/root $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 --global enable --now pipewire.socket - systemctl --global enable --now pipewire.service - systemctl --global enable --now wireplumber.service +mounts() { + echo + echo "Mounting......." + mount /dev/mapper/root $TARGET + btrfs_filesytem + mkdir -p $TARGET/boot + mount $EFI $TARGET/boot + #CONFIGURE DATA DIRS (HOME AND FLATPAK) + mkdir $TARGET/home + mount -o subvol=@home /dev/mapper/root $TARGET/home + mkdir -p $TARGET/var/lib/flatpak + mount -o subvol=@flatpak /dev/mapper/root $TARGET/var/lib/flatpak } -desktop() { - services -} - -installSteam() { - eselect repository enable steam-overlay - emerge --sync steam-overlay - emerge games-util/steam-launcher app-emulation/wine-vanilla games-util/lutris --autounmask-write - etc-update -q --automode -5 - emerge -DN @world - emerge games-util/steam-launcher app-emulation/wine-vanilla games-util/lutris +unmount() { + echo + echo "Unmounting....." + umount $TARGET/proc + umount $TARGET/dev + umount $TARGET/sys + umount $TARGET/boot + umount $TARGET/home + umount -R $TARGET/* + umount -R $TARGET/var/lib/flatpak + umount -R $TARGET + umount -R $TARGET } 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 + 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 + echo "LANG=en_US.UTF-8" >$TARGET/etc/locale.conf +} + +partitions() { + echo + echo "Setting Up Partitions....." + printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root + + unmount + + echo + echo "Formatting $EFI" + echo + echo y | mkfs.vfat $EFI + + mounts + + #Configure /etc/fstab + fstab } fstab() { - mkdir $TARGET/etc - echo "UUID=$(/sbin/blkid | grep ${BOOT} | cut -d '"' -f2) /boot ext4 defaults 0 1" >$TARGET/etc/fstab - echo "UUID=$(/sbin/blkid | grep ${EFI} | cut -d '"' -f4) /boot/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 "$BTRFS /var/lib/flatpak btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@flatpak 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 "tmpfs /home/${USER}/.cache tmpfs rw,user,exec 0 0" >>$TARGET/etc/fstab - echo "tmpfs /home/${USER}/Downloads tmpfs rw,user,exec 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 - echo "$BTRFS /var/lib/containers btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@containers 0 1" >>$TARGET/etc/fstab + mkdir $TARGET/etc + echo "UUID=$(blkid | grep ${EFI} | cut -d '"' -f4) /boot vfat umask=0077 0 1" >$TARGET/etc/fstab + echo "/dev/mapper/root / btrfs noatime,nodiratime,autodefrag,compress,subvol=@$ROOT_NAME 0 1" >>$TARGET/etc/fstab + echo "/dev/mapper/root /.snapshots btrfs noatime,nodiratime,autodefrag,compress,subvol=@.snapshots 0 1" >>$TARGET/etc/fstab + echo "/dev/mapper/root /var/lib/flatpak btrfs noatime,nodiratime,autodefrag,compress,subvol=@flatpak 0 1" >>$TARGET/etc/fstab + echo "/dev/mapper/root /var/lib/libvirt btrfs noatime,nodiratime,autodefrag,compress,subvol=@libvirt 0 1" >>$TARGET/etc/fstab + echo "tmpfs /var/log tmpfs defaults 0 0" >>$TARGET/etc/fstab + echo "tmpfs /var/cache/pacman/pkg tmpfs defaults 0 0" >>$TARGET/etc/fstab + echo "/dev/mapper/root /home btrfs noatime,nodiratime,autodefrag,compress,subvol=@home 0 1" >>$TARGET/etc/fstab + echo "/dev/mapper/root /root btrfs noatime,nodiratime,autodefrag,compress,subvol=@root 0 1" >>$TARGET/etc/fstab + echo "/dev/mapper/root /var/lib/postgres btrfs noatime,nodiratime,autodefrag,compress,subvol=@postgres 0 1" >>$TARGET/etc/fstab + echo "/dev/mapper/root /var/lib/containers btrfs noatime,nodiratime,autodefrag,compress,subvol=@containers 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 + echo + echo "Set Password for $USER" + echo "useradd -m -s /bin/bash $USER" >>$TARGET/setup.sh + echo "echo \"$USER:$USER_PASSWORD\"| chpasswd " >>$TARGET/setup.sh + echo "gpasswd -a $USER wheel" >>$TARGET/setup.sh + echo "gpasswd -a $USER network" >>$TARGET/setup.sh + echo "gpasswd -a $USER video" >>$TARGET/setup.sh + echo "gpasswd -a $USER libvirt" >>$TARGET/setup.sh + echo "$USER ALL=(ALL) ALL" >$TARGET/etc/sudoers + echo "root ALL=(ALL) ALL" >>$TARGET/etc/sudoers + echo + echo "Setting ROOT Password:" + echo "echo \"root:$ROOT_PASSWORD\"| chpasswd " >>$TARGET/setup.sh + + #Change Shell to ZSH + echo "printf "$USER_PASSWORD" | chsh -s /bin/zsh $USER" >>$TARGET/setup.sh + echo "printf "$ROOT_PASSWORD" | chsh -s /bin/zsh " >>$TARGET/setup.sh +} + +printer() { + printer=$(sudo ippfind) + sudo lpadmin -p printer -E -v $printer } btrfs-tweaks() { - DISABLE_COW=("/var/lib/docker" "/var/lib/containers" "/volumes" "/var/lib/mysql" "/var/lib/libvirt") +DISABLE_COW=("/var/lib/docker" "/var/lib/containers" "/var/lib/postgres" "/var/lib/mysql" "/var/lib/libvirt"); + + for i in "${DISABLE_COW[@]}" + do + chattr -R +C $i + done +} + + +custom_service_files() { + echo "systemctl set-default graphical.target" >>$TARGET/setup.sh + + echo "[Unit]" >$TARGET/etc/systemd/system/powertop.service + echo "Description=Powertop tunings" >>$TARGET/etc/systemd/system/powertop.service + echo "[Service]" >>$TARGET/etc/systemd/system/powertop.service + echo "Type=oneshot" >>$TARGET/etc/systemd/system/powertop.service + echo "ExecStart=/usr/bin/powertop --auto-tune" >>$TARGET/etc/systemd/system/powertop.service + echo "[Install]" >>$TARGET/etc/systemd/system/powertop.service + echo "WantedBy=multi-user.target" >>$TARGET/etc/systemd/system/powertop.service + + echo "[Unit]" >$TARGET/etc/systemd/system/podman-hack.service + echo "Description=Podman Hack" >>$TARGET/etc/systemd/system/podman-hack.service + echo "[Service]" >>$TARGET/etc/systemd/system/podman-hack.service + echo "Type=oneshot" >>$TARGET/etc/systemd/system/podman-hack.service + echo "ExecStartPre=/usr/bin/sysctl -w kernel.unprivileged_userns_clone=1" >>$TARGET/etc/systemd/system/podman-hack.service + echo "ExecStartPre=/usr/bin/touch /etc/subuid /etc/subgid" >>$TARGET/etc/systemd/system/podman-hack.service + echo "ExecStartPre=/usr/bin/usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $USER" >>$TARGET/etc/systemd/system/podman-hack.service + echo "ExecStartPre=/usr/bin/chmod 4755 /usr/bin/newgidmap" >>$TARGET/etc/systemd/system/podman-hack.service + echo "ExecStart=/usr/bin/chmod 4755 /usr/bin/newuidmap" >>$TARGET/etc/systemd/system/podman-hack.service + echo "[Install]" >>$TARGET/etc/systemd/system/podman-hack.service + echo "WantedBy=multi-user.target" >>$TARGET/etc/systemd/system/podman-hack.service + + echo "[Unit]" >$TARGET/etc/systemd/system/zram.service + echo "Description=Swap with zram" >>$TARGET/etc/systemd/system/zram.service + echo "After=multi-user.target" >>$TARGET/etc/systemd/system/zram.service + echo "[Service]" >>$TARGET/etc/systemd/system/zram.service + echo "Type=oneshot" >>$TARGET/etc/systemd/system/zram.service + echo "RemainAfterExit=true" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStartPre=/usr/bin/modprobe zram" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStartPre=/usr/bin/bash -c 'echo 2G > /sys/block/zram0/disksize'" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStartPre=/sbin/mkswap /dev/zram0" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStart=/sbin/swapon /dev/zram0" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStop=/sbin/swapoff /dev/zram0" >>$TARGET/etc/systemd/system/zram.service + echo "[Install]" >>$TARGET/etc/systemd/system/zram.service + echo "WantedBy=multi-user.target" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStop=/sbin/swapoff /dev/zram0" >>$TARGET/etc/systemd/system/zram.service + echo "ExecStop=/sbin/rmmod zram" >>$TARGET/etc/systemd/system/zram.service + +} + +services() { + for i in "${SERVICES[@]}" + do + echo "systemctl enable $i" >>$TARGET/setup.sh + done - for i in "${DISABLE_COW[@]}"; do - chattr -R +C $i - done } initialize-disk() { - parted /dev/$HARD_DISK mklabel gpt - parted -a optimal /dev/$HARD_DISK mkpart primary fat32 1MiB 200MiB - parted -a optimal /dev/$HARD_DISK mkpart primary ext3 200MiB 700MiB - parted -a optimal /dev/$HARD_DISK set 1 esp on - parted -a optimal /dev/$HARD_DISK mkpart P2 ext3 700MiB 100% - #parted -a optimal /dev/$HARD_DISK mkpart P2 ext3 98% 100% - partitionDetection - echo - echo "Formatting....." - echo y | mkfs.btrfs $BTRFS --force - echo "Formatting $EFI" - echo - echo y | mkfs.vfat $EFI - echo "Formatting $BOOT" - echo y | mkfs.ext4 $BOOT - echo - echo "Initialize Complete. Please reboot your machine to avoid any issues" - echo + parted /dev/$HARD_DISK mklabel gpt + parted /dev/$HARD_DISK mkpart primary fat32 1MiB 200MiB + parted /dev/$HARD_DISK set 1 esp on + parted /dev/$HARD_DISK mkpart P2 ext3 200MiB 100% + BTRFS="$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)" + printf "$DISK_PASSWORD\n$DISK_PASSWORD" | cryptsetup luksFormat /dev/${BTRFS} + printf "$DISK_PASSWORD" | cryptsetup open /dev/${BTRFS} root + echo + echo "Formatting....." + echo y | mkfs.btrfs -L arch /dev/mapper/root --force } wifi() { - iwctl --passphrase $WIRELESS_PASSWORD station $WIRELESS_INTERFACE connect $SSID + iwctl --passphrase $WIRELESS_PASSWORD station $WIRELESS_INTERFACE connect $SSID +} + +aur() { + mkdir -p $AUR + for i in "${aur_array[@]}"; do + cd $AUR + git clone "https://aur.archlinux.org/$i.git" + cd $i + git pull + env EUID=1 makepkg -fsi --noconfirm --skippgpcheck + done +} + +zram() { + echo "zram" >$TARGET/etc/modules-load.d/zram.conf + echo "options zram num_devices=1" >$TARGET/etc/modprobe.d/zram.conf + echo 'KERNEL=="zram0", ATTR{disksize}="2024M" RUN="/usr/bin/mkswap /dev/zram0", TAG+="systemd""' >$TARGET/etc/udev/rules.d/99-zram.rules } show-help() { - clear - echo - echo "[gentoo.sh arguments]" - echo - echo "./gentoo.sh wifi" - echo "./gentoo.sh bootloader [disk] [ROOT_NAME] [ROOT_MAPPER_NAME]" - echo "./gentoo.sh initialize" - echo "./gentoo.sh tar [device name] [location]" - echo "./gentoo.sh snapshot" - echo "./gentoo.sh reomve-snapshot" - echo "./gentoo.sh btrfs-tweaks" - echo + echo + echo "arch.sh arguments:" + echo + echo "./arch.sh install" + echo "./arch.sh backup [device name]" + echo "./arch.sh restore [device name" + echo "./arch.sh chroot" + echo "./arch.sh wifi" + echo "./arch.sh bootloader" + echo "./arch.sh initialize" + echo "./arch.sh snapshot" + echo "./arch.sh reomve-snapshot" + echo "./arch.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 - read -p 'Your Choice: ' choice - if [[ $choice = 1 ]]; then - set-devices - bootloader $HARD_DISK $ROOT_NAME $BTRFS - elif [[ $choice = 2 ]]; then - set-devices - systemMounts - /usr/bin/chroot $TARGET /bin/bash - elif [[ $choice = 3 ]]; then - compile-kernel - else - tweaks - 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 Base System" - echo "[4] Install Desktop Environment and Packages" - echo "[5] Install the bootloader and User Accounts" - echo "[6] Backup" - echo "[7] Restore" - echo "[8] Tools and Tweaks" - echo "[9] Initialize Disk" - echo - read -p 'Your Choice: ' choice - - if [[ $choice = 1 ]]; then - set-devices - read -p "Press enter key to Continue" - menu - elif [[ $choice = 2 ]]; then - clear - echo "[Choose Deployment Type]" - echo - echo - read -p 'Desktop or Server : ' -e -i 'desktop' INSTALL_TYPE - if [[ $INSTALL_TYPE = *desktop* ]]; then - USE_FLAGS=$DESKTOP_USE_FLAGS - PACKAGES=$BASE_PACKAGES$DESKTOP_PACKAGES - INSTALL_TYPE="desktop" - else - USE_FLAGS=$SERVER_USE_FLAGS - PACKAGES=$BASE_PACKAGES - INSTALL_TYPE="server" - fi - set-devices - STAGE3_URL=$(curl https://www.gentoo.org/downloads/ | grep -i stage3-amd64-systemd | head -1 | cut -d '"' -f2-3 | cut -d '"' -f1) - wget -O /tmp/stage3.tar.xz "$STAGE3_URL" - STAGE3_FILE="/tmp/stage3.tar.xz" - - if [ -f "$STAGE3_FILE" ]; then - echo - echo - echo "Extracting Tar File.........." - echo - echo - systemMounts - tar xf $STAGE3_FILE -C $TARGET/ - fstab - sed -i "s/-O2/-march=$CPU_TYPE -O2/i" $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 - echo "FEATURES=\"distcc\"" >>$TARGET/etc/portage/make.conf - echo "L10N=\"en en-US\"" >>$TARGET/etc/portage/make.conf - fi - - echo "VIDEO_CARDS=\"amdgpu radeon radeonsi fbdev intel vesa nvidia-drivers\"" >>$TARGET/etc/portage/make.conf - echo "USE=\"$USE_FLAGS\"" >>$TARGET/etc/portage/make.conf - - echo 'EMERGE_DEFAULT_OPTS="--jobs 10"' >>$TARGET/etc/portage/make.conf - echo 'ACCEPT_KEYWORDS="amd64"' >>$TARGET/etc/portage/make.conf - cp -f /etc/resolv.conf $TARGET/etc/ - mkdir -p $TARGET/var/tmp/portage - cp -f gentoo.sh $TARGET/usr/bin/ - fi - read -p "Press enter key to Continue" - menu - elif [[ $choice = 3 ]]; then - clear - echo "[Install Base System]" - echo - echo - read -p 'Desktop or Server : ' -e -i 'desktop' INSTALL_TYPE - if [[ $INSTALL_TYPE = *desktop* ]]; then - USE_FLAGS=$DESKTOP_USE_FLAGS - PACKAGES=$BASE_PACKAGES$DESKTOP_PACKAGES - INSTALL_TYPE="desktop" - else - USE_FLAGS=$SERVER_USE_FLAGS - PACKAGES=$BASE_PACKAGES - INSTALL_TYPE="server" - fi - set-devices - buildGentoo - read -p "Press enter key to Continue" - menu - elif [[ $choice = 4 ]]; then - set-devices - finishInstall "$HARD_DISK" - read -p "Press enter key to Continue" - menu - elif [[ $choice = 5 ]]; then - set-devices - cp -f gentoo.sh $TARGET/usr/bin/gentoo.sh - if [ ! -f "$TARGET/usr/bin/gentoo.sh" ]; then - echo - echo "Error: $TARGET/usr/bin/gentoo.sh not found!" - echo - exit 1 - fi - echo "bash /usr/bin/gentoo.sh bootloader $1 $ROOT_NAME $BTRFS" >>$TARGET/setup.sh - echo 'bash /usr/bin/gentoo.sh grub-snapshots' >>$TARGET/setup.sh - echo 'bash /usr/bin/gentoo.sh accounts' >>$TARGET/setup.sh - echo 'bash /usr/bin/gentoo.sh desktop' >>$TARGET/setup.sh - echo 'bash /usr/bin/gentoo.sh btrfs-tweaks' >>$TARGET/setup.sh - auto_login - chmod +x $TARGET/usr/bin/gentoo.sh - chmod +x $TARGET/setup.sh - chroot $TARGET /setup.sh - if [[ $INSTALL_TYPE = *server* ]]; then - chroot $TARGET /usr/bin/gentoo.sh nvidia - chroot $TARGET /usr/bin/gentoo.sh cockpit - fi - rm -f $TARGET/setup.sh - read -p "Press enter key to Continue" - menu - elif [[ $choice = 6 ]]; 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 = 7 ]]; 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 = 8 ]]; then - tweaks - elif [[ $choice = 9 ]]; 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 -} - -compile-kernel() { - cd /usr/src/linux - #echo y | make localmodconfig - time make $MAKEOPTS CC="distcc gcc" - time make $MAKEOPTS CC="distcc gcc" modules_install - time make install - dracut --kver "$(eselect kernel list | grep \* | cut -d '-' -f2-3 | sed 's/\*//' | sed 's/ //g')-gentoo-dist" --force - grub-mkconfig -o /boot/grub/grub.cfg -} - -if [ "$1" = "desktop" ]; then - desktop -elif [ "$1" = "tar" ]; then - create-os-snapshots "$3" "$2" +if [ "$1" = "install" ]; then + install "$2" +elif [ "$1" = "pacman-snapshot-hook" ]; then + pacman-snapshot-hook elif [ "$1" = "upgrade-system" ]; then - upgrade-system + upgrade-system +elif [ "$1" = "chroot" ]; then + chroot +elif [ "$1" = "initialize" ]; then + initialize-disk +elif [ "$1" = "aur" ]; then + aur "$2" elif [ "$1" = "wifi" ]; then - wifi -elif [ "$1" = "accounts" ]; then - accounts -elif [ "$1" = "hibernate" ]; then - hibernate-setup + wifi elif [ "$1" = "flatpaks" ]; then - flatpaks + flatpaks elif [ "$1" = "bootloader" ]; then - bootloader "$2" "$3" "$4" + bootloader elif [ "$1" = "snapshot" ]; then - snapshots -elif [ "$1" = "steam" ]; then - installSteam -elif [ "$1" = "grub-snapshots" ]; then - grub-snapshots -elif [ "$1" = "cockpit" ]; then - installCockpit + snapshots +elif [ "$1" = "backup" ]; then + usb-backup "$2" elif [ "$1" = "btrfs-tweaks" ]; then - btrfs-tweaks -elif [ "$1" = "compile-kernel" ]; then - compile-kernel + btrfs-tweaks +elif [ "$1" = "restore" ]; then + usb-restore "$2" elif [ "$1" = "remove-snapshot" ]; then - remove-snapshots + remove-snapshots elif [ "$1" = "help" ]; then - show-help + show-help else - menu -fi + show-help +fi \ No newline at end of file