#!/usr/bin/env bash # The most awesome sync script! :) # This shouldn't be used anywhere else than on my PCs! printf "\033[0;31m" if [ -z "$HOME" ] || ! [ -x "$(command -v pacman)" ]; then echo "Something went wrong!" printf "\033[0m" exit 1 fi echo "WARNING: This will replace all your existing configs!" read -p "Are you sure you want to do this? [yn] " -n 1 -r if [[ ! $REPLY =~ ^[Yy]$ ]]; then printf "\033[0m" echo exit 1 fi echo printf "\033[0;32m" echo "Okay, syncing..." printf "\033[0;34m" echo "Pulling newest configs" git pull --quiet || exit 1 printf "\033[0;34m" echo "Syncing packages" sudo pacman -Syq &>/dev/null printf "\033[0;34m" echo "Comparing installed packages" comm -23 <(sort packages.txt) <(pacman -Qqe | sort) | yay -Sq --needed - printf "\033[0;34m" echo "Compiling local repos" for d in ./.repos/*/; do (cd "$d" && sudo make clean install &>/dev/null); done || exit 1 printf "\033[0;34m" echo "Copying configs" printf "\033[0;37m" cp -rv .config/ .lein/ .scripts/ .bash_profile .bashrc .xinitrc .Xresources "$HOME"/ sudo cp -rv .etc/* /etc/ printf "\033[0;34m" echo "Syncing crypto files from server" ping -q -w1 -c1 10.0.0.33 &>/dev/null && scp -rq root@10.0.0.33:/mnt/ssd/.crypto "$HOME"/ || echo "Server connection failed" echo "Finished!" printf "\033[0m"