fix: check if nginx is already installed before prompting for installation

This commit is contained in:
Konano 2025-08-29 19:27:26 +08:00
parent df95e30c58
commit 96ac630b29
Signed by: Nano
GPG Key ID: 93686B78EE43A65A

View File

@ -315,6 +315,9 @@ configure_nginx() {
echo "deb-src [signed-by=/usr/share/keyrings/nginx.gpg] https://nginx.org/packages/ubuntu/ $(lsb_release -cs) nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list >/dev/null
fi
if confirm_action "要安装 nginx 吗?" "Y"; then
if command_exists nginx && ! confirm_action "检测到旧版 nginx 的存在 ($(nginx -v 2>&1)),是否继续安装?" "N"; then
return
fi
sudo apt-get update
sudo apt-get install nginx -y
echo "nginx 版本: $(nginx -v 2>&1)"