From e0ed1550974900e1c567f346eb3e07890accab0a Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 24 Nov 2025 20:04:26 +0000 Subject: [PATCH] fix(upgrade): Improve Caddy installation process and handle existing service --- core/scripts/webpanel/webpanel_shell.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/core/scripts/webpanel/webpanel_shell.sh b/core/scripts/webpanel/webpanel_shell.sh index 2061821..4a38e91 100644 --- a/core/scripts/webpanel/webpanel_shell.sh +++ b/core/scripts/webpanel/webpanel_shell.sh @@ -6,10 +6,21 @@ CADDY_CONFIG_FILE="/etc/hysteria/core/scripts/webpanel/Caddyfile" WEBPANEL_ENV_FILE="/etc/hysteria/core/scripts/webpanel/.env" install_dependencies() { - sudo apt update -y > /dev/null 2>&1 + if command -v caddy &> /dev/null; then + echo -e "${green}Caddy is already installed.${NC}" + if systemctl list-units --full -all | grep -q 'caddy.service'; then + if systemctl is-active --quiet caddy.service; then + echo -e "${yellow}Stopping and disabling default caddy.service...${NC}" + systemctl stop caddy > /dev/null 2>&1 + systemctl disable caddy > /dev/null 2>&1 + fi + fi + return 0 + fi - sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl > /dev/null 2>&1 - apt install libnss3-tools -y > /dev/null 2>&1 + echo -e "${yellow}Installing Caddy...${NC}" + sudo apt update -y > /dev/null 2>&1 + sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl libnss3-tools > /dev/null 2>&1 curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg > /dev/null 2>&1 curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list > /dev/null 2>&1 @@ -22,10 +33,8 @@ install_dependencies() { echo -e "${red}Error: Failed to install Caddy. ${NC}" exit 1 fi - systemctl stop caddy > /dev/null 2>&1 systemctl disable caddy > /dev/null 2>&1 - echo -e "${green}Caddy installed successfully. ${NC}" }