1
This commit is contained in:
26
scripts/renew-certs.sh
Normal file
26
scripts/renew-certs.sh
Normal 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 "完成。"
|
||||
Reference in New Issue
Block a user