Add reload option to install script

This commit is contained in:
2025-03-27 12:14:11 +00:00
parent 83827798f7
commit e43e9726ea

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# -r : Only reload configurations
# Colors # Colors
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
@@ -37,6 +39,15 @@ install_gnome_extension() {
fi fi
} }
# Flags
reload=false
for arg in "$@"; do
if [ "$arg" = "-r" ]; then
reload=true
break
fi
done
# Clone Dotfiles if not already present # Clone Dotfiles if not already present
cd "$HOME/dotfiles" cd "$HOME/dotfiles"
if [ "$(pwd)" != "$HOME/dotfiles" ]; then if [ "$(pwd)" != "$HOME/dotfiles" ]; then
@@ -83,7 +94,7 @@ printf "${CYAN}Desktop: ${PURPLE}%s${NC}\n" "$XDG_CURRENT_DESKTOP"
printf "\n" printf "\n"
# Install Programs # Install Programs
if [ -z "$nixos" ]; then if [ "$reload" = false ] && [ -z "$nixos" ]; then
programs=(neovim curl git tmux htop fzf gcc make tldr pass lynis bat) programs=(neovim curl git tmux htop fzf gcc make tldr pass lynis bat)
if [[ "$OSTYPE" != "darwin"* ]]; then if [[ "$OSTYPE" != "darwin"* ]]; then
@@ -133,7 +144,7 @@ else
fi fi
# UFW Firewall # UFW Firewall
if [ -z "$nixos" ] && [[ "$OSTYPE" != "darwin"* ]]; then if [ "$reload" = false ] && [ -z "$nixos" ] && [[ "$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 deny incoming
sudo ufw default allow outgoing sudo ufw default allow outgoing
@@ -149,7 +160,7 @@ if [ -z "$nixos" ] && [[ "$OSTYPE" != "darwin"* ]]; then
else else
printf "${GREEN}UFW setup successfully.${NC}\n" printf "${GREEN}UFW setup successfully.${NC}\n"
fi fi
elif [[ "$OSTYPE" == "darwin"* ]]; then elif [[ "$OSTYPE" == "darwin"* && "$reload" = false ]]; then
printf "${YELLOW}Enabling macOS Firewall...${NC}\n" printf "${YELLOW}Enabling macOS Firewall...${NC}\n"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@@ -192,7 +203,7 @@ if [ "$USER" = "trude" ]; then
fi fi
# Security Scan # Security Scan
if [ ! -f "$HOME/dotfiles/logs/lynis_scan.log" ]; then if [ "$reload" = false ] && [ ! -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" sudo lynis audit system | tee "$HOME/dotfiles/logs/lynis_scan.log"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then