chore: auto-commit 2026-03-30 06:40
This commit is contained in:
parent
19866a97a9
commit
cdff390ae0
1 changed files with 23 additions and 8 deletions
|
|
@ -21,10 +21,25 @@ CYAN='\033[0;36m'
|
||||||
BOLD='\033[1m'
|
BOLD='\033[1m'
|
||||||
NC='\033[0m'
|
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_DIR="/opt"
|
||||||
INSTANCE_NAME=""
|
INSTANCE_NAME=""
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# FUNCTIONS
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
# Function to find the Wallarm instance directory
|
# Function to find the Wallarm instance directory
|
||||||
find_wallarm_instance() {
|
find_wallarm_instance() {
|
||||||
local dirs=()
|
local dirs=()
|
||||||
|
|
@ -200,8 +215,8 @@ update_config() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Replace the original config with the new one
|
# Replace the original config with the new one
|
||||||
sudo mv "$temp_config" "$config_file"
|
mv "$temp_config" "$config_file"
|
||||||
sudo chmod 644 "$config_file"
|
chmod 644 "$config_file"
|
||||||
|
|
||||||
echo -e "${GREEN}Configuration updated.${NC}"
|
echo -e "${GREEN}Configuration updated.${NC}"
|
||||||
}
|
}
|
||||||
|
|
@ -209,15 +224,15 @@ update_config() {
|
||||||
restart_container() {
|
restart_container() {
|
||||||
local container_name="$1"
|
local container_name="$1"
|
||||||
echo -e "${YELLOW}Restarting container $container_name to apply changes...${NC}"
|
echo -e "${YELLOW}Restarting container $container_name to apply changes...${NC}"
|
||||||
if sudo docker ps --format "{{.Names}}" | grep -q "^$container_name$"; then
|
if docker ps --format "{{.Names}}" | grep -q "^$container_name$"; then
|
||||||
sudo docker restart "$container_name"
|
docker restart "$container_name"
|
||||||
echo -e "${GREEN}Container restarted.${NC}"
|
echo -e "${GREEN}Container restarted.${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${RED}Container $container_name is not running. Starting it...${NC}"
|
echo -e "${RED}Container $container_name is not running. Starting it...${NC}"
|
||||||
if [ -f "$INSTANCE_DIR/start.sh" ]; then
|
if [ -f "$INSTANCE_DIR/start.sh" ]; then
|
||||||
sudo "$INSTANCE_DIR/start.sh"
|
"$INSTANCE_DIR/start.sh"
|
||||||
else
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
@ -247,7 +262,7 @@ main() {
|
||||||
restart_container "$INSTANCE_NAME"
|
restart_container "$INSTANCE_NAME"
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}Changes will take effect after container restart.${NC}"
|
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
|
fi
|
||||||
|
|
||||||
echo -e "\n${GREEN}${BOLD}Reconfiguration completed.${NC}"
|
echo -e "\n${GREEN}${BOLD}Reconfiguration completed.${NC}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue