From cdff390ae0278d176a8afc383c117a2b0f8dd08d Mon Sep 17 00:00:00 2001 From: administrator Date: Mon, 30 Mar 2026 06:40:37 +0100 Subject: [PATCH] chore: auto-commit 2026-03-30 06:40 --- wallarm-ct-reconfigure.sh | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/wallarm-ct-reconfigure.sh b/wallarm-ct-reconfigure.sh index f20a55c..b28fd50 100644 --- a/wallarm-ct-reconfigure.sh +++ b/wallarm-ct-reconfigure.sh @@ -21,10 +21,25 @@ CYAN='\033[0;36m' BOLD='\033[1m' NC='\033[0m' -# Defaults +# ============================================================================== +# CHECK FOR SUDO / ROOT PRIVILEGES +# ============================================================================== +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}${BOLD}ERROR:${NC} This script must be run with sudo or as root." + echo -e "${YELLOW}Please run: sudo $0${NC}" + exit 1 +fi + +# ============================================================================== +# CONFIGURATION +# ============================================================================== INSTANCE_DIR="/opt" INSTANCE_NAME="" +# ============================================================================== +# FUNCTIONS +# ============================================================================== + # Function to find the Wallarm instance directory find_wallarm_instance() { local dirs=() @@ -200,8 +215,8 @@ update_config() { fi # Replace the original config with the new one - sudo mv "$temp_config" "$config_file" - sudo chmod 644 "$config_file" + mv "$temp_config" "$config_file" + chmod 644 "$config_file" echo -e "${GREEN}Configuration updated.${NC}" } @@ -209,15 +224,15 @@ update_config() { restart_container() { local container_name="$1" echo -e "${YELLOW}Restarting container $container_name to apply changes...${NC}" - if sudo docker ps --format "{{.Names}}" | grep -q "^$container_name$"; then - sudo docker restart "$container_name" + if docker ps --format "{{.Names}}" | grep -q "^$container_name$"; then + docker restart "$container_name" echo -e "${GREEN}Container restarted.${NC}" else echo -e "${RED}Container $container_name is not running. Starting it...${NC}" if [ -f "$INSTANCE_DIR/start.sh" ]; then - sudo "$INSTANCE_DIR/start.sh" + "$INSTANCE_DIR/start.sh" else - echo -e "${RED}No start script found. Please start manually: sudo docker start $container_name${NC}" + echo -e "${RED}No start script found. Please start manually: docker start $container_name${NC}" exit 1 fi fi @@ -247,7 +262,7 @@ main() { restart_container "$INSTANCE_NAME" else echo -e "${YELLOW}Changes will take effect after container restart.${NC}" - echo -e "You can restart later with: sudo docker restart $INSTANCE_NAME" + echo -e "You can restart later with: docker restart $INSTANCE_NAME" fi echo -e "\n${GREEN}${BOLD}Reconfiguration completed.${NC}"