diff --git a/src/core.sh b/src/core.sh index b15c243..780abcf 100644 --- a/src/core.sh +++ b/src/core.sh @@ -850,6 +850,24 @@ uninstall() { else ask string y "是否卸载 ${is_core_name}? [y]:" fi + # Clean up HAProxy and restore Caddy before removing files + if systemctl is-active --quiet haproxy >/dev/null 2>&1; then + systemctl stop haproxy >/dev/null 2>&1 + systemctl disable haproxy >/dev/null 2>&1 + if [[ $(type -P apt-get) ]]; then + apt-get purge -y haproxy >/dev/null 2>&1 + apt-get autoremove -y >/dev/null 2>&1 + elif [[ $(type -P dnf) ]]; then + dnf remove -y haproxy >/dev/null 2>&1 + elif [[ $(type -P yum) ]]; then + yum remove -y haproxy >/dev/null 2>&1 + fi + fi + # If Caddy is NOT being uninstalled (REPLY != '2'), we must restore Caddy back to port 443! + if [[ $REPLY != '2' ]]; then + restore_caddy_default + fi + manage stop &>/dev/null manage disable &>/dev/null rm -rf $is_core_dir $is_log_dir $is_sh_bin ${is_sh_bin/$is_core/sb}