Small tweaks and auto-update

This commit is contained in:
2025-03-14 08:59:03 +00:00
parent 0e67c91eb4
commit 3eab62885f
2 changed files with 48 additions and 35 deletions

View File

@@ -12,18 +12,24 @@ NC='\033[0m' # No Color
mkdir -p "$HOME/dotfiles/logs"
# Clone Dotfiles if not already present
cd "$HOME/dotfiles" || exit
cd "$HOME/dotfiles"
if [ "$(pwd)" != "$HOME/dotfiles" ]; then
printf "${YELLOW}[+] Cloning dotfiles repository...${NC}\n"
printf "${YELLOW}Cloning dotfiles repository...${NC}\n"
git clone https://github.com/TrudeEH/dotfiles --depth 1
if [ $? -ne 0 ]; then
printf "${RED}[E] Error cloning dotfiles repository. Exiting...${NC}\n"
printf "${RED}Error cloning dotfiles repository. Exiting...${NC}\n"
exit 2
fi
cd dotfiles || exit
printf "${GREEN}[I] dotfiles repository cloned successfully.${NC}\n"
printf "${GREEN}dotfiles repository cloned successfully.${NC}\n"
else
printf "${GREEN}[I] dotfiles repository already present.${NC}\n"
printf "${YELLOW}Updating dotfiles repository...${NC}\n"
pull_output=$(git pull)
printf "%s\n" "$pull_output"
if ! echo "$pull_output" | grep -q "Already up to date."; then
printf "${YELLOW}Changes detected. Re-running script...${NC}\n"
exec "$0" "$@"
fi
fi
source ./scripts/p.sh
@@ -46,105 +52,105 @@ fi
p i "${programs[@]}"
# Copy files
printf "${YELLOW}[+] Installing Dotfiles...${NC}\n"
printf "${YELLOW}Installing Dotfiles...${NC}\n"
cp -r "$HOME/dotfiles/home/." "$HOME"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error copying Dotfiles.${NC}\n"
printf "${RED}Error copying Dotfiles.${NC}\n"
else
printf "${GREEN}[I] Dotfiles installed successfully.${NC}\n"
printf "${GREEN}Dotfiles installed successfully.${NC}\n"
fi
# Copy scripts
printf "${YELLOW}[+] Installing Scripts...${NC}\n"
printf "${YELLOW}Installing Scripts...${NC}\n"
mkdir -p "$HOME/.local/bin"
cp -r "$HOME/dotfiles/scripts/." "$HOME/.local/bin/"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error copying Scripts.${NC}\n"
printf "${RED}Error copying Scripts.${NC}\n"
else
printf "${GREEN}[I] Scripts installed successfully.${NC}\n"
printf "${GREEN}Scripts installed successfully.${NC}\n"
fi
# Install fonts
printf "${YELLOW}[+] Installing fonts...${NC}\n"
printf "${YELLOW}Installing fonts...${NC}\n"
if [[ "$OSTYPE" == "darwin"* ]]; then
cp -rf "$HOME/dotfiles/fonts/"* "$HOME/Library/Fonts/"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error installing fonts.${NC}\n"
printf "${RED}Error installing fonts.${NC}\n"
else
printf "${GREEN}[I] Fonts installed successfully.${NC}\n"
printf "${GREEN}Fonts installed successfully.${NC}\n"
fi
else
mkdir -p "$HOME/.local/share/fonts"
cp -rf "$HOME/dotfiles/fonts/"* "$HOME/.local/share/fonts/"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error installing fonts.${NC}\n"
printf "${RED}Error installing fonts.${NC}\n"
else
fc-cache -fv "$HOME/.local/share/fonts" >"$HOME/dotfiles/logs/font_install.log"
printf "${GREEN}[I] Fonts installed successfully.${NC}\n"
printf "${GREEN}Fonts installed successfully.${NC}\n"
fi
fi
# Load Dconf (GNOME settings)
if [[ "$OSTYPE" != "darwin"* ]]; then
printf "${YELLOW}[+] Loading Dconf settings...${NC}\n"
printf "${YELLOW}Loading Dconf settings...${NC}\n"
dconf load / <"$HOME/dotfiles/dconf-settings.ini"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error loading Dconf settings.${NC}\n"
printf "${RED}Error loading Dconf settings.${NC}\n"
else
printf "${GREEN}[I] Dconf settings loaded successfully.${NC}\n"
printf "${GREEN}Dconf settings loaded successfully.${NC}\n"
fi
fi
# UFW Firewall
if [[ "$OSTYPE" != "darwin"* ]]; then
printf "${YELLOW}[+] Setting up UFW...${NC}\n"
printf "${YELLOW}Setting up UFW...${NC}\n"
sudo ufw default deny incoming
sudo ufw default allow outgoing
if systemctl is-active --quiet sshd; then
printf "${YELLOW}[+] SSH Server detected; Enabling SSH rule...${NC}\n"
printf "${YELLOW}SSH Server detected; Enabling SSH rule...${NC}\n"
sudo ufw limit 22/tcp
fi
sudo ufw enable
sudo ufw status numbered | tee "$HOME/dotfiles/logs/ufw_status.log"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error setting up UFW.${NC}\n"
printf "${RED}Error setting up UFW.${NC}\n"
else
printf "${GREEN}[I] UFW setup successfully.${NC}\n"
printf "${GREEN}UFW setup successfully.${NC}\n"
fi
else
printf "${YELLOW}[+] Enabling macOS Firewall...${NC}\n"
printf "${YELLOW}Enabling macOS Firewall...${NC}\n"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
if [ $? -ne 0 ]; then
printf "${RED}[E] Error enabling Firewall.${NC}\n"
printf "${RED}Error enabling Firewall.${NC}\n"
else
printf "${GREEN}[I] Firewall enabled successfully.${NC}\n"
printf "${GREEN}Firewall enabled successfully.${NC}\n"
fi
fi
# Clone password-store
if [ "$(whoami)" = "trude" ]; then
if [ ! -d "$HOME/.password-store" ]; then
printf "${YELLOW}[+] Cloning password-store...${NC}\n"
printf "${YELLOW}Cloning password-store...${NC}\n"
git clone https://github.com/TrudeEH/password-store "$HOME/.password-store"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error cloning password-store.${NC}\n"
printf "${RED}Error cloning password-store.${NC}\n"
else
printf "${GREEN}[I] Password-store cloned successfully.${NC}\n"
printf "${GREEN}Password-store cloned successfully.${NC}\n"
fi
else
printf "${CYAN}[I] Password-store already present.${NC}\n"
printf "${CYAN}Password-store already present.${NC}\n"
fi
fi
# Security Scan
if [ ! -f "$HOME/dotfiles/logs/lynis_scan.log" ]; then
printf "${YELLOW}[+] Running Lynis Security Scan...${NC}\n"
printf "${YELLOW}Running Lynis Security Scan...${NC}\n"
sudo lynis audit system | tee "$HOME/dotfiles/logs/lynis_scan.log"
if [ $? -ne 0 ]; then
printf "${RED}[E] Error running Lynis.${NC}\n"
printf "${RED}Error running Lynis.${NC}\n"
else
printf "${GREEN}[I] Lynis scan completed.${NC}\n"
printf "${GREEN}Lynis scan completed.${NC}\n"
fi
else
printf "${CYAN}[I] Previous Lynis scan detected, read the log @ $HOME/dotfiles/logs/lynis_scan.log.${NC}\n"
printf "${CYAN}Previous Lynis scan detected, read the log @ $HOME/dotfiles/logs/lynis_scan.log.${NC}\n"
fi