v2
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 备份并覆盖配置文件
|
||||
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
|
||||
cp nginx.conf /etc/nginx/
|
||||
# 备份并覆盖所有.conf配置文件
|
||||
for conf in *.conf; do
|
||||
cp "/etc/nginx/$conf" "/etc/nginx/${conf}.bak" 2>/dev/null || true
|
||||
cp "$conf" /etc/nginx/
|
||||
done
|
||||
|
||||
# 测试并重载配置
|
||||
if nginx -t; then
|
||||
systemctl reload nginx
|
||||
echo "配置已生效,HTTPS已启用"
|
||||
else
|
||||
echo "配置测试失败,已恢复备份"
|
||||
cp /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
|
||||
fi
|
||||
echo "配置测试失败,正在恢复所有备份"
|
||||
for conf in *.conf; do
|
||||
mv -f "/etc/nginx/${conf}.bak" "/etc/nginx/$conf" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user