#! /bin/sh RED="\e[31m" GREEN="\e[32m" YELLOW="\e[33m" MAGENTA="\e[35m" CYAN="\e[36m" BOLD="\e[1m" NC="\e[0m" trap 'printf "${RED}install.sh interrupted.${NC}"; exit 1' INT TERM testing_branch="trixie" window_height='15' window_width='60' W_MAIN=$( whiptail --notags --title "Trude's Dotfiles" \ --cancel-button "Exit" \ --menu "Main Menu" $window_height $window_width 3 \ "install" "Install Dotfiles" \ "reload" "Reload Configuration" \ "update" "Update Debian" \ 3>&1 1>&2 2>&3 ) if [ -z $W_MAIN ]; then exit 1 fi if [ $W_MAIN = "update" ]; then ./scripts/update exit 0 fi if [ $W_MAIN = "install" ]; then W_DEB_SOURCES=$(whiptail --notags --title "Debian Sources" \ --cancel-button "Skip" \ --menu "Choose your Debian source:" $window_height $window_width 2 \ "stable" "Stable" \ "testing" "Testing ($testing_branch)" \ 3>&1 1>&2 2>&3) fi install_gnome_extension() { uuid="$1" if [ -z "$uuid" ]; then echo "${RED}Usage: install_gnome_extension ${NC}" return 1 fi if ! gnome-extensions list | grep -qw "$uuid"; then echo "${GREEN}Sent install request for $uuid.${NC}" gdbus call --session --dest org.gnome.Shell.Extensions \ --object-path /org/gnome/Shell/Extensions \ --method org.gnome.Shell.Extensions.InstallRemoteExtension \ "$uuid" >/dev/null 2>&1 return 0 elif gnome-extensions list --updates | grep -qw "$uuid"; then echo "${GREEN}Sent update request for $uuid.${NC}" gdbus call --session --dest org.gnome.Shell.Extensions \ --object-path /org/gnome/Shell/Extensions \ --method org.gnome.Shell.Extensions.InstallRemoteExtension \ "$uuid" >/dev/null 2>&1 return 0 else echo "${GREEN}GNOME Extension $uuid is already installed.${NC}" return 0 fi } # Clone Dotfiles if not already present if [ $W_MAIN = "install" ]; then cd "$HOME/dotfiles" if [ "$(pwd)" != "$HOME/dotfiles" ]; then echo "${YELLOW}Cloning dotfiles repository...${NC}" sudo apt update sudo apt install -y git if ! git clone https://github.com/TrudeEH/dotfiles --depth 1; then echo "${RED}Error cloning dotfiles repository. Exiting...${NC}" exit 2 fi cd dotfiles || exit echo "${GREEN}dotfiles repository cloned successfully.${NC}" else echo "${YELLOW}Updating dotfiles repository...${NC}" pull_output=$(git pull) echo "$pull_output" if ! echo "$pull_output" | grep -q "Already up to date."; then echo "${YELLOW}Changes detected. Re-running script...${NC}" exec "$0" "$@" fi fi else cd "$HOME/dotfiles" || exit fi mkdir -p "$HOME/dotfiles/logs" if [ $W_MAIN = "install" ]; then echo "${YELLOW}Setting Debian Sources...${NC}" case $W_DEB_SOURCES in "stable") echo "${CYAN}Using Stable sources.${NC}" sudo cp /etc/apt/sources.list /etc/apt/sources.list.bckp sudo sh -c 'cat > /etc/apt/sources.list < /etc/apt/sources.list <"$HOME/dotfiles/logs/font_install.log" fi # UFW Firewall if [ "$reload" = false ]; then echo "${YELLOW}Setting up UFW...${NC}" sudo ufw default deny incoming sudo ufw default allow outgoing if systemctl is-active --quiet sshd; then echo "${YELLOW}SSH Server detected; Enabling SSH rule...${NC}" sudo ufw limit 22/tcp fi sudo ufw enable sudo ss -tupln | tee "$HOME/dotfiles/logs/open_ports.log" sudo ufw status numbered | tee "$HOME/dotfiles/logs/ufw_status.log" fi # Trude-only settings if [ "$USER" = "trude" ]; then # Git config git config --global commit.gpgsign true git config --global tag.gpgSign true git config --global gpg.format ssh git config --global user.signingkey ~/.ssh/id_ed25519.pub git config --global user.name "TrudeEH" git config --global user.email "ehtrude@gmail.com" # Clone password-store if [ ! -f "$HOME/.ssh/id_ed25519" ] || [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then echo "${RED}ED25519 key not found in ${CYAN}$HOME/.ssh/id_ed25519. ${RED}Please add your ED25519 key pair for password-store.${NC}" elif ! gpg --list-keys "ehtrude@gmail.com" >/dev/null 2>&1; then echo "${RED}GPG key for ehtrude@gmail.com not found. Please import the key for password-store.${NC}" else if [ ! -d "$HOME/.password-store" ]; then echo "${YELLOW}Cloning password-store...${NC}" chmod 700 ~/.ssh chmod 600 ~/.ssh/* if ! git clone git@github.com:TrudeEH/password-store.git "$HOME/.password-store"; then echo "${RED}Error cloning password-store.${NC}" else echo "${GREEN}Password-store cloned successfully.${NC}" fi else echo "${CYAN}Password-store already present.${NC}" fi fi fi # Set up GNOME Desktop case "$XDG_CURRENT_DESKTOP" in *GNOME*) echo "${YELLOW}Installing GNOME Extensions...${NC}" install_gnome_extension "caffeine@patapon.info" install_gnome_extension "Vitals@CoreCoding.com" install_gnome_extension "appindicatorsupport@rgcjonas.gmail.com" echo "${YELLOW}Loading Dconf settings...${NC}" if ! dconf load / <"$HOME/dotfiles/dconf-settings.ini"; then echo "${RED}Error loading Dconf settings.${NC}" fi ;; esac