27 lines
708 B
Bash
27 lines
708 B
Bash
#!/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 "完成。"
|