Update arch.sh
This commit is contained in:
parent
03238204e8
commit
fb18a65cb7
898
arch.sh
898
arch.sh
@ -1,17 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
clear
|
########################
|
||||||
|
# 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
|
||||||
|
#
|
||||||
########################
|
########################
|
||||||
#Configure this section
|
#Configure this section
|
||||||
########################
|
########################
|
||||||
TARGET='/mnt'
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
TARGET='/install'
|
||||||
|
mkdir $TARGET
|
||||||
######################################
|
######################################
|
||||||
clear
|
|
||||||
echo
|
echo
|
||||||
HARD_DISK=nvme0n1
|
HARD_DISK=$2
|
||||||
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="verita84"
|
||||||
USER_PASSWORD="123456"
|
USER_PASSWORD="123456"
|
||||||
@ -19,457 +35,547 @@ ROOT_PASSWORD="123456"
|
|||||||
WIRELESS_PASSWORD='123456'
|
WIRELESS_PASSWORD='123456'
|
||||||
SSID='123456'
|
SSID='123456'
|
||||||
WIRELESS_INTERFACE='wlan0'
|
WIRELESS_INTERFACE='wlan0'
|
||||||
DISK_PASSWORD='123456'
|
COMPRESSION='compress=zstd:10'
|
||||||
|
FLATPAKS+=(io.exodus.Exodus us.zoom.Zoom app/com.valvesoftware.Steam/x86_64/stable app/net.lutris.Lutris)
|
||||||
|
SERVICES+=(smartd cronie avahi-daemon cups grub-btrfsd sddm NetworkManager dev-zram0.swap)
|
||||||
|
DESKTOP="KDE"
|
||||||
|
BROWSER="brave"
|
||||||
|
MAKEOPTS="-j$(cat /proc/cpuinfo | grep -i processor | grep -vi 'model' | wc -l)"
|
||||||
|
USE_FLAGS="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"
|
||||||
|
TMPFS_SIZE="32G"
|
||||||
|
BASE_PACKAGES=" kde-apps/kcalc www-client/firefox-bin kde-apps/ark kde-apps/dolphin mail-mta/postfix app-admin/sysstat sys-apps/smartmontools plasma-meta sys-process/cronie net-fs/samba net-fs/nfs-utils net-firewall/iptables dev-python/pip sys-fs/inotify-tools kde-apps/kate kde-apps/konsole media-gfx/krita dev-util/sh net-analyzer/nmap x11-apps/xhost app-misc/screen net-im/element-desktop-bin app-portage/gentoolkit sys-fs/dosfstools app-admin/sudo sys-apps/systemd sys-boot/plymouth sys-apps/zram-generator x11-misc/sddm app-eselect/eselect-repository dev-vcs/git sys-boot/refind sys-block/parted sys-boot/grub sys-block/zram-init media-video/vlc app-office/calligra sys-process/btop net-vpn/wireguard-tools sys-apps/flatpak app-editors/vim app-vim/airline app-misc/fastfetch net-misc/yt-dlp net-im/telegram-desktop net-misc/nextcloud-client app-containers/crun app-containers/podman app-office/calligra media-gfx/krita net-fs/samba sys-fs/btrfs-progs kde-apps/kdegraphics-meta app-admin/keepassxc net-print/cups "
|
||||||
|
#VIRTUALIZATION=" virt-manager qemu-system libvirt-daemon-system ovmf cockpit-machines"
|
||||||
|
TAR_EXCLUDES="--exclude=/var/cache/distfiles --exclude=/var/lib/flatpak --exclude=/opt/stable-diffusion-webui --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 --exclude=/opt/chatgpt "
|
||||||
|
|
||||||
#AUR Configuration
|
partitionDetection() {
|
||||||
AUR="/home/$USER/aur"
|
#This is used for the installer to do script-based actions
|
||||||
aur_array+=( trizen )
|
EFI=$(blkid | grep $HARD_DISK | sort | cut -d ":" -f1 | head -1 | tail -1)
|
||||||
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 )
|
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)
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clean-old-usb-snapshots(){
|
partitionDetection
|
||||||
echo;echo "[Cleaning up old USB snapshots.....]";echo
|
|
||||||
btrfs sub delete $TARGET/$ROOT_NAME-$1
|
auto_login() {
|
||||||
btrfs sub delete $TARGET/flatpak
|
mkdir -p $TARGET/etc/sddm.conf.d
|
||||||
echo;echo "[Cleaning up old EFI data.....]";echo
|
echo "[Autologin]" >$TARGET/etc/sddm.conf.d/autologin
|
||||||
rm -rf $TARGET/efi-$1
|
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-snapshots() {
|
create-os-snapshots() {
|
||||||
echo;echo "[Cleaning up old snapshots.....]";echo
|
echo
|
||||||
btrfs sub delete /.snapshots/$ROOT_NAME-$1
|
mkdir $2
|
||||||
btrfs sub delete /.snapshots/flatpak
|
DATE=$(date +%Y-%m-%d-%H)
|
||||||
}
|
echo "[Creating new OS snapshot to $1/gentoo-$DATE).tgz]"
|
||||||
|
echo
|
||||||
create-usb-snapshots(){
|
echo
|
||||||
echo;echo "[Creating new ROOT and Flatpak snapshots.....]";echo
|
NEW_TAR_EXCLUDES="$TAR_EXCLUDES --exclude=/minio --exclude=$TARGET/* --exclude=/var/lib/docker "
|
||||||
btrfs sub snap -r / /.snapshots/$ROOT_NAME-$1
|
echo
|
||||||
btrfs sub snap -r /var/lib/flatpak /.snapshots/flatpak
|
time tar cvpzf $1/gentoo-$DATE.tgz $NEW_TAR_EXCLUDES /
|
||||||
}
|
chown $USER:$USER $1/gentoo-$DATE.tgz
|
||||||
|
|
||||||
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() {
|
homeBackup() {
|
||||||
echo;echo "[Copying USER data....]";echo
|
echo
|
||||||
rsync -av --delete /home/ /mnt/home/
|
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/
|
||||||
}
|
}
|
||||||
|
|
||||||
usb-backup() {
|
os-backup() {
|
||||||
umount $TARGET
|
umount $TARGET
|
||||||
|
|
||||||
echo;echo "[Mounting $USB_BACKUP]";echo
|
echo
|
||||||
mount $USB_BACKUP $TARGET
|
echo "[Mounting.....]"
|
||||||
|
echo
|
||||||
|
mount -o $COMPRESSION $BTRFS $TARGET
|
||||||
|
|
||||||
homeBackup
|
if [ "$1" = "home" ]; then
|
||||||
clean-old-snapshots "$1"
|
homeBackup
|
||||||
clean-old-usb-snapshots "$1"
|
fi
|
||||||
create-usb-snapshots "$1"
|
create-os-snapshots "$2" "$3"
|
||||||
send-snapshots "$1"
|
|
||||||
clean-old-snapshots "$1"
|
ls $TARGET/
|
||||||
copy-efi-to-usb "$1"
|
umount $TARGET
|
||||||
cp -f /usr/bin/arch.sh $TARGET/$1
|
|
||||||
ls $TARGET/
|
|
||||||
umount $TARGET
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usb-restore() {
|
os-restore() {
|
||||||
partitions
|
partitions
|
||||||
rsync -av ../$ROOT_NAME-$1/ $TARGET/ --exclude=/home --delete
|
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
|
||||||
rsync -av ../flatpak/ $TARGET/var/lib/flatpak/ --delete
|
clear
|
||||||
cp -rf ../efi-$1/* $TARGET/boot/
|
echo "[Restoring OS tarfile from $4/$2.tgz]"
|
||||||
fstab
|
echo
|
||||||
cp -f arch.sh $TARGET/
|
tar xfvp $4/$2.tgz -C $TARGET/
|
||||||
arch-chroot $TARGET /arch.sh bootloader
|
|
||||||
arch-chroot $TARGET /arch.sh btrfs-tweaks
|
if [ "$3" = "home" ]; then
|
||||||
#arch-chroot $TARGET /arch.sh aur
|
echo "[Restoring /home]"
|
||||||
rm -f $TARGET/arch.sh
|
echo
|
||||||
unmount
|
rsync -a --delete /home/ $TARGET/home/
|
||||||
|
fi
|
||||||
|
|
||||||
|
fstab
|
||||||
|
cp -f gentoo.sh $TARGET/
|
||||||
|
systemMounts
|
||||||
|
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
|
||||||
|
unmount
|
||||||
}
|
}
|
||||||
|
|
||||||
installSoftware() {
|
systemMounts() {
|
||||||
while true; do
|
mount -o rbind /dev $TARGET/dev
|
||||||
if [ ! -f "$TARGET/usr/bin/zsh" ]; then
|
mount -o rbind /dev/pts $TARGET/dev/pts
|
||||||
echo "Downloading packages......."
|
mount -o rbind /proc $TARGET/proc
|
||||||
printf '\n Y' | /usr/sbin/pacstrap $TARGET $PACKAGES
|
mount -o rbind /sys $TARGET/sys
|
||||||
sleep 10
|
mount -t efivarfs none $TARGET/sys/firmware/efi/efivars
|
||||||
else
|
mount -t tmpfs -o size=$TMPFS_SIZE tmpfs $TARGET/var/tmp/portage
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
partitions
|
partitions
|
||||||
sed -i '/^SigLevel/s/^\(.*\)$/#\1\n/' /etc/pacman.conf
|
if ! [ -f "$TARGET/bin/bash" ]; then
|
||||||
sed -i '/#SigLevel/a SigLevel = Never' /etc/pacman.conf
|
getInstallFiles
|
||||||
pacman -Sy archlinux-keyring --noconfirm
|
fi
|
||||||
installSoftware
|
|
||||||
locale
|
if [ -f "$TARGET/bin/bash" ]; then
|
||||||
accounts
|
systemMounts
|
||||||
auto_login
|
buildGentoo
|
||||||
zram
|
auto_login
|
||||||
custom_service_files
|
setup_script "$1"
|
||||||
services
|
fi
|
||||||
btrfs-tweaks
|
#unmount
|
||||||
cpuPower
|
|
||||||
setup_script
|
|
||||||
unmount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pacman-snapshot-hook(){
|
getInstallFiles() {
|
||||||
echo "[Trigger]" > /usr/share/libalpm/hooks/04-snapshot.hook
|
cd /tmp
|
||||||
echo "Operation = Upgrade" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
STAGE3_URL=$(curl https://www.gentoo.org/downloads/ | grep -i stage3-amd64-systemd | head -1 | cut -d '"' -f2-3 | cut -d '"' -f1)
|
||||||
echo "Operation = Install" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
wget "$STAGE3_URL"
|
||||||
echo "Operation = Remove" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
STAGE3_FILE="/tmp/$(ls /tmp/stage3-* | head -1 | cut -d '/' -f3)"
|
||||||
echo "Type = Package" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
if [ -f "$STAGE3_FILE" ]; then
|
||||||
echo "Target = *" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
echo "Stage3 already here"
|
||||||
echo "[Action]" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
else
|
||||||
echo "Description = Creating Snapshot" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
wget "$STAGE3_URL"
|
||||||
echo "When = PreTransaction" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
STAGE3_FILE="/tmp/$(ls /tmp/stage3-* | head -1 | cut -d '/' -f3)"
|
||||||
echo "Exec = /usr/bin/arch.sh snapshot" >> /usr/share/libalpm/hooks/04-snapshot.hook
|
fi
|
||||||
|
|
||||||
|
tar xfv $STAGE3_FILE -C $TARGET/
|
||||||
|
sed -i 's/-O2/-march=native -O2/i' $TARGET/etc/portage/make.conf
|
||||||
|
echo "USE=\"$USE_FLAGS\"" >>$TARGET/etc/portage/make.conf
|
||||||
|
echo "MAKEOPTS=\"$MAKEOPTS\"" >>$TARGET/etc/portage/make.conf
|
||||||
|
echo 'EMERGE_DEFAULT_OPTS="--jobs 2"' >>$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
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGentoo() {
|
||||||
|
cp -f ./gentoo.sh $TARGET/usr/bin/
|
||||||
|
if [ ! -d "$TARGET/var/db/repos/gentoo/x11-misc" ]; then
|
||||||
|
chroot $TARGET /usr/bin/emerge --sync
|
||||||
|
fi
|
||||||
|
if [ ! -f "$TARGET/usr/bin/gentoo.sh" ]; then
|
||||||
|
echo
|
||||||
|
echo "Error: $TARGET/usr/bin/gentoo.sh not found!"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
chroot $TARGET /usr/bin/eselect $(/usr/bin/eselect profile list | grep -i plasma | grep systemd | head -1 | cut -d '[' -f2 | cut -d ']' -f1)
|
||||||
|
mkdir -p $TARGET/etc/portage/package.license
|
||||||
|
echo "*/* *" >$TARGET/etc/portage/package.license/license
|
||||||
|
rm -rf $TARGET/etc/portage/package.accept_keywords
|
||||||
|
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
|
||||||
|
chroot $TARGET /usr/bin/emerge =sys-kernel/gentoo-sources-$(ls $TARGET/var/db/repos/gentoo/sys-kernel/gentoo-sources/gentoo-sources-6.* | cut -d '-' -f5-6 | grep -vi r | head -1 | sed 's/.ebuild//') sys-kernel/genkernel sys-kernel/linux-firmware
|
||||||
|
chroot $TARGET eselect kernel set 1
|
||||||
|
chroot $TARGET genkernel --cachedir=/var/tmp/portage --tmpdir=/var/tmp/portage --install all
|
||||||
|
chroot $TARGET /usr/bin/emerge $BASE_PACKAGES --autounmask-write
|
||||||
|
chroot $TARGET etc-update -q --automode -5
|
||||||
|
chroot $TARGET /usr/bin/emerge $BASE_PACKAGES
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshots() {
|
snapshots() {
|
||||||
echo
|
echo
|
||||||
echo "Creating Snapshots....."
|
echo "Creating Snapshots....."
|
||||||
echo
|
echo
|
||||||
DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S))
|
DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S))
|
||||||
btrfs sub snapshot / /.snapshots/root-${DATE}
|
btrfs sub snapshot / /.snapshots/root-${DATE}
|
||||||
bootloader_entry "${DATE}" ".snapshots/root-${DATE}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove-snapshots() {
|
remove-snapshots() {
|
||||||
btrfs sub delete /.snapshots/*
|
btrfs sub delete /.snapshots/*
|
||||||
rm -f /boot/loader/entries/root-*
|
rm -f /boot/loader/entries/root-*
|
||||||
}
|
|
||||||
|
|
||||||
chroot() {
|
|
||||||
printf "$DISK_PASSWORD" | cryptsetup open ${BTRFS} root
|
|
||||||
mounts
|
|
||||||
arch-chroot $TARGET /bin/bash
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flatpaks() {
|
flatpaks() {
|
||||||
for i in "${FLATPAKS[@]}"; do
|
echo
|
||||||
flatpak install $i -y
|
echo "Installing Flatpaks......"
|
||||||
done
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
bootloader_entry(){
|
grub-snapshots() {
|
||||||
## $1=Boot Entry Name
|
cd /opt
|
||||||
## $2=Volume Name
|
git clone https://github.com/Antynea/grub-btrfs.git
|
||||||
echo "default arch.conf" >/boot/loader/loader.conf
|
cd /opt/grub-btrfs
|
||||||
echo 'timeout 3 ' >>/boot/loader/loader.conf
|
make
|
||||||
echo "title $1" >/boot/loader/entries/$1.conf
|
make install
|
||||||
echo 'linux /vmlinuz-linux-lts' >>/boot/loader/entries/$1.conf
|
systemctl enable --now grub-btrfsd.service
|
||||||
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() {
|
bootloader() {
|
||||||
echo 'HOOKS=(base udev modconf block encrypt btrfs filesystems keyboard keymap lvm2 fsck)' >/etc/mkinitcpio.conf
|
if [ -z "$1" ]; then
|
||||||
mkinitcpio -P
|
echo
|
||||||
bootctl install
|
echo "Error: No Disk specified!"
|
||||||
bootloader_entry "$ROOT_NAME" "arch"
|
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
|
||||||
|
#genkernel --cachedir=/var/tmp/portage --tmpdir=/var/tmp/portage --install all
|
||||||
|
grub-mkconfig -o /boot/grub/grub.cfg
|
||||||
|
refind-install
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_script() {
|
function setup_script() {
|
||||||
cp -f arch.sh $TARGET/usr/bin/
|
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
|
||||||
|
|
||||||
echo 'bash /usr/bin/arch.sh bootloader' >>$TARGET/setup.sh
|
chmod +x $TARGET/usr/bin/gentoo.sh
|
||||||
#echo 'bash /usr/bin/arch.sh aur' >>$TARGET/setup.sh
|
chmod +x $TARGET/setup.sh
|
||||||
echo 'bash /usr/bin/arch.sh flatpaks' >>$TARGET/setup.sh
|
chroot $TARGET /setup.sh
|
||||||
echo 'bash /usr/bin/arch.sh btrfs-tweaks' >>$TARGET/setup.sh
|
rm -f $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_filesytem() {
|
||||||
btrfs sub create $TARGET/@$ROOT_NAME
|
btrfs sub create $TARGET/@$ROOT_NAME
|
||||||
btrfs sub create $TARGET/@.snapshots
|
btrfs sub create $TARGET/@.snapshots
|
||||||
btrfs sub create $TARGET/@flatpak
|
btrfs sub create $TARGET/@libvirt
|
||||||
btrfs sub create $TARGET/@libvirt
|
btrfs sub create $TARGET/@home
|
||||||
btrfs sub create $TARGET/@home
|
btrfs sub create $TARGET/@root
|
||||||
btrfs sub create $TARGET/@root
|
btrfs sub create $TARGET/@containers
|
||||||
btrfs sub create $TARGET/@postgres
|
btrfs sub create $TARGET/@flatpak
|
||||||
btrfs sub create $TARGET/@containers
|
echo
|
||||||
echo
|
echo "Binding BTRFS Root"
|
||||||
echo "Binding BTRFS Root"
|
echo
|
||||||
echo
|
umount $TARGET
|
||||||
umount /mnt
|
mount -o $COMPRESSION,subvol=@$ROOT_NAME $BTRFS $TARGET
|
||||||
mount -o subvol=@$ROOT_NAME /dev/mapper/root $TARGET
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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 "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=$(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"
|
|
||||||
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" "/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() {
|
services() {
|
||||||
for i in "${SERVICES[@]}"
|
echo '[zram0]' >/etc/systemd/zram-generator.conf
|
||||||
do
|
echo 'zram-size = ram * 2' >>/etc/systemd/zram-generator.conf
|
||||||
echo "systemctl enable $i" >>$TARGET/setup.sh
|
|
||||||
done
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
desktop() {
|
||||||
|
services
|
||||||
|
}
|
||||||
|
|
||||||
|
installBrowser() {
|
||||||
|
if [ "$BROWSER" = "brave" ]; then
|
||||||
|
installBrave
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mounts() {
|
||||||
|
echo
|
||||||
|
echo "Mounting......."
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
unmount() {
|
||||||
|
echo
|
||||||
|
echo "Unmounting....."
|
||||||
|
umount $TARGET/proc
|
||||||
|
umount $TARGET/dev
|
||||||
|
umount $TARGET/sys
|
||||||
|
umount $TARGET/boot
|
||||||
|
umount $TARGET/home
|
||||||
|
umount -lR $TARGET/*
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
partitions() {
|
||||||
|
echo
|
||||||
|
echo "Setting Up Partitions....."
|
||||||
|
|
||||||
|
if [[ -e "$BTRFS" ]]; then
|
||||||
|
mounts
|
||||||
|
fstab
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "Aborting Install, $BTRFS not found!"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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" "/var/lib/containers" "/volumes" "/var/lib/mysql" "/var/lib/libvirt")
|
||||||
|
|
||||||
|
for i in "${DISABLE_COW[@]}"; do
|
||||||
|
chattr -R +C $i
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize-disk() {
|
initialize-disk() {
|
||||||
parted /dev/$HARD_DISK mklabel gpt
|
parted /dev/$HARD_DISK mklabel gpt
|
||||||
parted /dev/$HARD_DISK mkpart primary fat32 1MiB 200MiB
|
parted -a optimal /dev/$HARD_DISK mkpart primary fat32 1MiB 200MiB
|
||||||
parted /dev/$HARD_DISK set 1 esp on
|
parted -a optimal /dev/$HARD_DISK mkpart primary ext3 200MiB 700MiB
|
||||||
parted /dev/$HARD_DISK mkpart P2 ext3 200MiB 100%
|
parted -a optimal /dev/$HARD_DISK set 1 esp on
|
||||||
BTRFS="$(lsblk | grep $HARD_DISK | head -3 | tail -1 | cut -c 7-20 | cut -d ' ' -f1)"
|
parted -a optimal /dev/$HARD_DISK mkpart P2 ext3 700MiB 98%
|
||||||
printf "$DISK_PASSWORD\n$DISK_PASSWORD" | cryptsetup luksFormat /dev/${BTRFS}
|
parted -a optimal /dev/$HARD_DISK mkpart P2 ext3 98% 100%
|
||||||
printf "$DISK_PASSWORD" | cryptsetup open /dev/${BTRFS} root
|
partitionDetection
|
||||||
echo
|
echo
|
||||||
echo "Formatting....."
|
echo "Formatting....."
|
||||||
echo y | mkfs.btrfs -L arch /dev/mapper/root --force
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi() {
|
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() {
|
show-help() {
|
||||||
echo
|
clear
|
||||||
echo "arch.sh arguments:"
|
echo
|
||||||
echo
|
echo "[gentoo.sh arguments]"
|
||||||
echo "./arch.sh install"
|
echo
|
||||||
echo "./arch.sh backup [device name]"
|
echo "./gentoo.sh wifi"
|
||||||
echo "./arch.sh restore [device name"
|
echo "./gentoo.sh bootloader [disk] [ROOT_NAME] [ROOT_MAPPER_NAME]"
|
||||||
echo "./arch.sh chroot"
|
echo "./gentoo.sh initialize"
|
||||||
echo "./arch.sh wifi"
|
echo "./gentoo.sh tar [device name] [location]"
|
||||||
echo "./arch.sh bootloader"
|
echo "./gentoo.sh snapshot"
|
||||||
echo "./arch.sh initialize"
|
echo "./gentoo.sh reomve-snapshot"
|
||||||
echo "./arch.sh snapshot"
|
echo "./gentoo.sh btrfs-tweaks"
|
||||||
echo "./arch.sh reomve-snapshot"
|
echo
|
||||||
echo "./arch.sh btrfs-tweaks"
|
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" = "install" ]; then
|
tweaks() {
|
||||||
install "$2"
|
clear
|
||||||
elif [ "$1" = "pacman-snapshot-hook" ]; then
|
echo
|
||||||
pacman-snapshot-hook
|
echo "Gentoo Installer System Tweaks]"
|
||||||
|
echo
|
||||||
|
echo "[1] Reinstall Bootloader"
|
||||||
|
echo "[2] Chroot into existing OS"
|
||||||
|
echo
|
||||||
|
read -p 'Your Choice: ' choice
|
||||||
|
if [[ $choice = 1 ]]; then
|
||||||
|
set-devices
|
||||||
|
bootloader $HARD_DISK $ROOT_NAME $BTRFS
|
||||||
|
elif [[ $choice = 2 ]]; then
|
||||||
|
set-devices
|
||||||
|
partitions
|
||||||
|
systemMounts
|
||||||
|
/usr/bin/chroot $TARGET /bin/bash
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
menu() {
|
||||||
|
clear
|
||||||
|
echo
|
||||||
|
echo "[Welcome to the Poster.place Gentoo Installer System]"
|
||||||
|
echo
|
||||||
|
echo "[1] Install"
|
||||||
|
echo "[2] Backup"
|
||||||
|
echo "[3] Restore"
|
||||||
|
echo "[4] Tools and Tweaks"
|
||||||
|
echo "[5] Initialize Disk"
|
||||||
|
echo
|
||||||
|
read -p 'Your Choice: ' choice
|
||||||
|
if [[ $choice = 1 ]]; then
|
||||||
|
clear
|
||||||
|
echo "[Install OS]"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
set-devices
|
||||||
|
install "$HARD_DISK"
|
||||||
|
elif [[ $choice = 2 ]]; 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 = 3 ]]; then
|
||||||
|
clear
|
||||||
|
echo "[Restore from Backup]"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
set-devices
|
||||||
|
read -p 'Restore Directory Image Source: ' -e -i "/mnt" restore_directory
|
||||||
|
FILE_SCAN=$(ls $restore_directory/gentoo-* | 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 = 4 ]]; then
|
||||||
|
tweaks
|
||||||
|
elif [[ $choice = 5 ]]; then
|
||||||
|
clear
|
||||||
|
echo "[Initialize Disk]"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
set-devices
|
||||||
|
initialize-disk
|
||||||
|
else
|
||||||
|
menu
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
set-devices() {
|
||||||
|
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 '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
|
||||||
|
partitionDetection
|
||||||
|
ROOT_NAME=$root_name
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = "desktop" ]; then
|
||||||
|
desktop
|
||||||
|
elif [ "$1" = "tar" ]; then
|
||||||
|
create-os-snapshots "null" "$3" "$2"
|
||||||
elif [ "$1" = "upgrade-system" ]; then
|
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
|
elif [ "$1" = "wifi" ]; then
|
||||||
wifi
|
wifi
|
||||||
|
elif [ "$1" = "accounts" ]; then
|
||||||
|
accounts
|
||||||
|
elif [ "$1" = "hibernate" ]; then
|
||||||
|
hibernate-setup
|
||||||
elif [ "$1" = "flatpaks" ]; then
|
elif [ "$1" = "flatpaks" ]; then
|
||||||
flatpaks
|
flatpaks
|
||||||
elif [ "$1" = "bootloader" ]; then
|
elif [ "$1" = "bootloader" ]; then
|
||||||
bootloader
|
bootloader "$2" "$3" "$4"
|
||||||
elif [ "$1" = "snapshot" ]; then
|
elif [ "$1" = "snapshot" ]; then
|
||||||
snapshots
|
snapshots
|
||||||
elif [ "$1" = "backup" ]; then
|
elif [ "$1" = "grub-snapshots" ]; then
|
||||||
usb-backup "$2"
|
grub-snapshots
|
||||||
elif [ "$1" = "btrfs-tweaks" ]; then
|
elif [ "$1" = "btrfs-tweaks" ]; then
|
||||||
btrfs-tweaks
|
btrfs-tweaks
|
||||||
elif [ "$1" = "restore" ]; then
|
|
||||||
usb-restore "$2"
|
|
||||||
elif [ "$1" = "remove-snapshot" ]; then
|
elif [ "$1" = "remove-snapshot" ]; then
|
||||||
remove-snapshots
|
remove-snapshots
|
||||||
elif [ "$1" = "help" ]; then
|
elif [ "$1" = "help" ]; then
|
||||||
show-help
|
show-help
|
||||||
else
|
else
|
||||||
show-help
|
menu
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user