This commit is contained in:
2026-05-18 22:32:08 +08:00
parent 6ab44ea187
commit bd4caa0f09
22 changed files with 1178 additions and 297 deletions

26
scripts/renew-certs.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env sh
set -eu
# 日常续期用:
# certbot renew 会自己判断证书是否快过期;没到续期时间不会真正重签。
# renew 成功或无须续期后,重载 OpenResty让已经更新的证书生效。
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
cd "$ROOT_DIR"
. "$ROOT_DIR/scripts/lib-compose.sh"
echo "按需续期证书..."
compose run --rm --entrypoint certbot certbot \
renew --webroot -w /var/www
echo "重载 OpenResty 以使用续期后的证书..."
if compose exec -T openresty openresty -s reload; then
echo "OpenResty 已重载。"
else
echo "重载失败,改为重启 OpenResty..."
compose restart openresty
fi
echo "完成。"