#!/bin/bash if [[ $EUID -ne 0 ]]; then echo "This script must be run as root!" >&2 exit 1 fi echo "Taking fresh install snapshot..." btrfs subvolume snapshot -r / /.snapshots/@clean-install-snapshot echo "Setting up grup-btrfs..." systemctl enable --now grub-btrfsd.service grub-mkconfig -o /boot/grub/grub.cfg echo "Setting up pacman hooks..." if [[ ! -d "/etc/pacman.d/hooks/" ]]; then mkdir -p "/etc/pacman.d/hooks/" fi cat <<'EOF' > /etc/pacman.d/hooks/90-btrfs-snapshot.hook [Trigger] Type = Package Operation = Install Operation = Upgrade Operation = Remove Target = linux Target = linux-lts Target = intel-ucode Target = grub [Action] Description = Creating BTRFS snapshot before system upgrade When = PreTransaction Exec = /usr/bin/bash -c '/usr/bin/btrfs subvolume snapshot / /.snapshots/@root-snapshot-$(date +%Y-%m-%d-%H-%M)' AbortOnFail EOF cat <<'EOF' > /etc/pacman.d/hooks/91-grub-mkconfig.hook [Trigger] Type = Package Operation = Install Operation = Upgrade Operation = Remove Target = linux Target = linux-lts Target = intel-ucode Target = grub [Action] Description = Update grub cfg so it can boot from new snapshots When = PostTransaction Exec = /usr/bin/bash -c '/usr/bin/grub-mkconfig -o /boot/grub/grub.cfg' EOF echo "Cloning repos..." git clone https://git.tovijaeschke.xyz/tovi/dmenu.git /usr/local/src/dmenu git clone https://git.tovijaeschke.xyz/tovi/dwm.git /usr/local/src/dwm git clone https://git.tovijaeschke.xyz/tovi/dwmblocks.git /usr/local/src/dwmblocks git clone https://git.tovijaeschke.xyz/tovi/st.git /usr/local/src/st git clone https://github.com/neovim/neovim /usr/local/src/neovim echo "Building dmenu..." cd /usr/local/src/dmenu/ make make install make clean echo "Building dwm..." cd /usr/local/src/dwm/ make make install make clean echo "Building dwmblocks..." cd /usr/local/src/dwmblocks/ make make install make clean echo "Building st..." cd /usr/local/src/st/ make make install make clean echo "Building neovim..." cd /usr/local/src/st/ make CMAKE_BUILD_TYPE=RelWithDebInfo make install echo "Building yay..." git clone https://aur.archlinux.org/yay.git /opt/yay/ cd /opt/yay makepkg -si echo "Cloning dotfiles..." echo "Enabling networkmanager service..." systemctl enable NetworkManager echo "Taking post install script snapshot..." btrfs subvolume snapshot -r / /.snapshots/@post-install-snapshot