diff --git a/gentoo.sh b/gentoo.sh index 3b060da..1fa17ee 100644 --- a/gentoo.sh +++ b/gentoo.sh @@ -44,19 +44,19 @@ AUTO_DECRYPT='False' DISK_PASSWORD='123456' ############################## FLATPAKS+=() -SERVICES+=(cronie libvirtd smartd cronie cups NetworkManager dev-zram0.swap) +SERVICES+=(cronie libvirtd smartd cronie cups NetworkManager zram_swap.service) MAKEOPTS="-j$(cat /proc/cpuinfo | grep -i processor | grep -vi 'model' | wc -l)" ROOT_PARTITION_SIZE="30GB" FEATURES="-pid-sandbox getbinpkg -binpkg-request-signature" -EMERGE_DEFAULT_OPTS="--getbinpkg " +EMERGE_DEFAULT_OPTS=" --getbinpkg " #USEFLAG CONFIGURATION -USE_FLAGS=" systemd-boot -webengine jumbo-build hwaccel -telemetry dist-kernel postscript webchannel qml -gpm plasma luks cryptsetup kernel-install boot proprietary-codecs kernel-install gles2 pulseaudio keeshare 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 wayland alsa X sound-server screencast systemd firmware btrfs policykit networkmanager zlib pipewire minizip network browser " +USE_FLAGS=" systemd-boot -webengine jumbo-build hwaccel -telemetry dist-kernel postscript webchannel qml -gpm plasma luks cryptsetup kernel-install boot proprietary-codecs kernel-install gles2 pulseaudio 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 wayland alsa X sound-server screencast systemd firmware btrfs policykit networkmanager zlib pipewire minizip network " VIDEO_CARDS="amdgpu radeon radeonsi" # #PACKAGE CONFIGURATION -BASE_PACKAGES=" sys-power/acpid app-arch/zip dev-python/virtualenv sys-apps/flatpak net-misc/nyx app-emulation/virt-manager sys-power/powertop net-vpn/tor app-shells/bash-completion sys-apps/fwupd sys-power/cpupower net-misc/nextcloud-client media-libs/gexiv2 app-vim/airline mail-mta/postfix app-admin/sysstat sys-apps/smartmontools sys-process/cronie net-fs/nfs-utils net-firewall/nftables 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/fastfetch net-misc/yt-dlp sys-fs/btrfs-progs net-print/cups " +BASE_PACKAGES=" sys-power/acpid app-arch/zip dev-python/virtualenv sys-apps/flatpak net-misc/nyx app-emulation/virt-manager sys-power/powertop net-vpn/tor app-shells/bash-completion sys-power/cpupower net-misc/nextcloud-client media-libs/gexiv2 app-vim/airline mail-mta/postfix app-admin/sysstat sys-apps/smartmontools sys-process/cronie net-fs/nfs-utils net-firewall/nftables 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-block/zram-init app-eselect/eselect-repository dev-vcs/git sys-block/parted sys-process/btop net-vpn/wireguard-tools app-editors/vim app-misc/fastfetch net-misc/yt-dlp sys-fs/btrfs-progs net-print/cups " #FIX=" dev-libs/libappindicator" -DESKTOP_APPS=" kde-apps/kcalc kde-apps/ark kde-frameworks/karchive net-im/signal-desktop-bin kde-apps/okular kde-apps/spectacle kde-apps/dolphin konsole kde-plasma/plasma-meta firefox-bin app-office/libreoffice-bin gui-libs/xdg-desktop-portal-wlr sys-apps/xdg-desktop-portal dev-util/android-tools media-video/obs-studio media-video/handbrake xfce-base/thunar app-editors/vscodium media-video/vlc app-admin/keepassxc media-fonts/fontawesome media-gfx/krita " +DESKTOP_APPS=" firefox-bin kde-apps/kcalc kde-apps/ark kde-frameworks/karchive net-im/signal-desktop-bin kde-apps/okular kde-apps/spectacle kde-apps/dolphin konsole kde-plasma/plasma-meta app-office/libreoffice-bin gui-libs/xdg-desktop-portal-wlr sys-apps/xdg-desktop-portal dev-util/android-tools media-video/obs-studio media-video/handbrake xfce-base/thunar kde-apps/kate media-video/vlc media-fonts/fontawesome media-gfx/krita " # PACKAGES="$BASE_PACKAGES $DESKTOP_APPS" TMPFS_SIZE="32G" @@ -361,7 +361,7 @@ liveOSrestore() { mount $LIVE_OS_DM /tmp/live cd /tmp/live/$LIVE_OS_SUBVOL - rsync -a --delete . --exclude=/var/lib/docker --exclude=/var/db/repos/* --exclude=/var/lib/systemd/coredump/* --exclude=/var/cache/* --exclude=home/* --exclude=.snapshots/* --exclude=sys/* --exclude=dev/* --exclude=proc/* --exclude=run/* $TARGET/ + rsync -a --delete . --exclude=/var/cache --exclude=/var/notmpfs --exclude=/var/lib/docker --exclude=/var/db/repos/* --exclude=/var/lib/systemd/coredump/* --exclude=/var/cache/* --exclude=home/* --exclude=.snapshots/* --exclude=sys/* --exclude=dev/* --exclude=proc/* --exclude=run/* $TARGET/ fstab cp -f $SCRIPT/gentoo.sh $TARGET/usr/bin/ echo "[Copying Boot Files ]" @@ -374,7 +374,7 @@ liveOSrestore() { echo 'bash /usr/bin/gentoo.sh accounts' >>$TARGET/setup.sh echo 'bash /usr/bin/gentoo.sh btrfs-tweaks' >>$TARGET/setup.sh echo 'bash /usr/bin/gentoo.sh hibernate' >>$TARGET/setup.sh - + echo "chown -R $USER:$USER $TARGET/home/$USER" >>$TARGET/setup.sh chmod +x $TARGET/usr/bin/gentoo.sh chmod +x $TARGET/setup.sh chroot $TARGET bash /setup.sh @@ -390,7 +390,7 @@ liveOSrestore() { echo echo "Skipping User Tweaks" fi - chown -R $USER:$USER $TARGET/home/$USER + cd umount /tmp/live #unmount @@ -424,20 +424,19 @@ btrfs_filesytem() { } userTweaks() { - mkdir $TARGET/home/$USER/.mozilla mkdir -p $TARGET/home/$USER/Documents/keys/keepass mkdir -p $TARGET/home/$USER/dotfiles mkdir -p $TARGET/home/$USER/server mkdir -p $TARGET/home/$USER/.config/Exodus + mkdir -p $TARGET/home/$USER/.mozilla mkdir -p $TARGET/home/$USER/.local/share/fonts - $TARGET/home/$USER/.local/share/fonts/ - + cp -f /home/$USER/.bash* $TARGET/home/$USER/ + rsync -av --delete /home/$USER/.mozilla/ $TARGET/home/$USER/.mozilla/ rsync -av --delete /home/$USER/server/ $TARGET/home/$USER/server/ rsync -av --delete /home/$USER/.local/share/fonts/ $TARGET/home/$USER/.local/share/fonts/ rsync -av --delete /home/$USER/.config/Exodus/ $TARGET/home/$USER/.config/Exodus/ - rsync -av --delete /home/$USER/.mozilla/ $TARGET/home/$USER/.mozilla/ rsync -av --delete /home/$USER/.config/autostart/ $TARGET/home/$USER/.config/autostart/ rsync -av --delete /home/$USER/Documents/keys/keepass/ $TARGET/home/$USER/Documents/keys/keepass/ rsync -av --delete /home/$USER/dotfiles/ $TARGET/home/$USER/dotfiles/ @@ -447,8 +446,17 @@ userTweaks() { } services() { - echo '[zram0]' >/etc/systemd/zram-generator.conf - echo 'zram-size = ram * 2' >>/etc/systemd/zram-generator.conf + echo '[Unit]' > /usr/lib/systemd/system/zram_swap.service + echo 'Description=swap with zram' >> /usr/lib/systemd/system/zram_swap.service + echo 'DefaultDependencies=no' >> /usr/lib/systemd/system/zram_swap.service + echo 'Before=swap.target' >> /usr/lib/systemd/system/zram_swap.service + echo '[Service]' >> /usr/lib/systemd/system/zram_swap.service + echo 'Type=oneshot' >> /usr/lib/systemd/system/zram_swap.service + echo 'RemainAfterExit=true' >> /usr/lib/systemd/system/zram_swap.service + echo 'ExecStart=/bin/sh -c "exec /sbin/zram-init -p 32767 -s2 -azstd -Lzram_swap 32000 "' >> /usr/lib/systemd/system/zram_swap.service + echo 'ExecStop=/sbin/zram-init 0' >> /usr/lib/systemd/system/zram_swap.service + echo '[Install]' >> /usr/lib/systemd/system/zram_swap.service + echo 'WantedBy=swap.target' >> /usr/lib/systemd/system/zram_swap.service for i in "${SERVICES[@]}"; do systemctl enable --now $i @@ -487,8 +495,9 @@ fstab() { echo "UUID=$(/sbin/blkid -s UUID -o value $ROOT_MAPPER_NAME) /var/lib/libvirt btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@libvirt 0 1" >>$TARGET/etc/fstab echo "UUID=$(/sbin/blkid -s UUID -o value $ROOT_MAPPER_NAME) /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 0 0" >>$TARGET/etc/fstab + echo "tmpfs /tmp tmpfs defaults,size=32G 0 0" >>$TARGET/etc/fstab + echo "tmpfs /var/tmp/portage tmpfs defaults,size=32G 0 0" >>$TARGET/etc/fstab + echo "tmpfs /var/lib/systemd/coredump tmpfs defaults,size=5G 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 "UUID=$(/sbin/blkid -s UUID -o value $ROOT_MAPPER_NAME) /home btrfs noatime,nodiratime,autodefrag,$COMPRESSION,subvol=@home 0 1" >>$TARGET/etc/fstab @@ -639,6 +648,11 @@ download-setup() { echo setDevices STAGE3_URL=$(curl https://www.gentoo.org/downloads/ | grep -i stage3-amd64-systemd | head -1 | cut -d '"' -f2-3 | cut -d '"' -f1) + + if [ -f "./repos.conf" ]; then + STAGE3_URL="http://192.168.0.55/releases/amd64/autobuilds/current-stage3-amd64-desktop-systemd/$(curl -s 'http://192.168.0.55/releases/amd64/autobuilds/current-stage3-amd64-desktop-systemd/' | grep .tar.xz | grep -Evi '.asc|.gz|DIGESTS|sha256' | cut -d \" -f2)" + fi + STAGE3_FILE="/tmp/stage3.tar.xz" if [ -f "$STAGE3_FILE" ]; then echo @@ -807,8 +821,8 @@ bootloader() { #find /boot/* -type d -exec rm -rf {} \; bootctl install MACHINE_ID=$(cat /etc/machine-id) - KERNEL="kernel-$(ls /boot/$MACHINE_ID | grep gentoo)" - KERNEL_VERSION=$(echo $KERNEL | cut -d '-' -f2-4) + KERNEL="kernel-$(ls /boot/$MACHINE_ID | grep gentoo | tail -1)" + KERNEL_VERSION=$(echo $KERNEL | cut -d '-' -f2-5) LOADER_FILE="/boot/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" PREVIOUS_LOADER_FILE="/boot/loader/entries/previous.conf" clear @@ -835,33 +849,37 @@ bootloader() { fi mkdir -p /boot/$MACHINE_ID/$KERNEL_VERSION - plymouth-set-default-theme solar - dracut --regenerate-all -f + #plymouth-set-default-theme solar echo "MachineID=$MACHINE_ID" - echo "KERNEL IS $KERNEL" - echo "Root_Name=$ROOT_NAME" - echo "BTRFS=$BTRFS" + echo "KERNEL: $KERNEL" + echo "KERNEL_VERSION: $KERNEL_VERSION" + echo "Root_Name: $ROOT_NAME" + echo "BTRFS: $BTRFS" echo "UEFI Kernel: $KERNEL_VERSION" - echo "default $MACHINE_ID" >/boot/loader/loader.conf echo "timeout 1" >>/boot/loader/loader.conf - #Generate Main Boot Entry - echo "title Current" >$LOADER_FILE - echo "version $KERNEL_VERSION" >>$LOADER_FILE - echo "options $KERNEL_COMMAND_LINE " >>$LOADER_FILE - echo "machine-id $MACHINE_ID" >>$LOADER_FILE - echo "linux /kernel-$KERNEL_VERSION" >>$LOADER_FILE - echo "initrd /initramfs-$KERNEL_VERSION.img" >>$LOADER_FILE + echo + echo + echo + read -p 'Is the kernel compiled from source?: ' -e -i 'n' kernel_source - #Generate Previous Boot Entry - #cp -f $LOADER_FILE $PREVIOUS_LOADER_FILE - #sed -i "s/@${ROOT_NAME}/@.snapshots/previous/" $PREVIOUS_LOADER_FILE - #sed -i "s/Current/Previous/" $PREVIOUS_LOADER_FILE - #bootctl set-default $MACHINE_ID-$KERNEL_VERSION.conf + if [[ $kernel_source = *y* ]]; then + cd /usr/src/linux + make install + rm -f /boot/loader/entries/$MACHINE_ID-$KERNEL_VERSION-gentoo.conf + else + dracut --regenerate-all -f + fi - #bootctl list + #Generate Main Boot Entry + echo "title Current" >$LOADER_FILE + echo "version $KERNEL_VERSION" >>$LOADER_FILE + echo "options $KERNEL_COMMAND_LINE " >>$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 } compile-kernel() {