This commit is contained in:
2026-05-18 22:48:12 +08:00
parent bd4caa0f09
commit f49c2b135d
11 changed files with 151 additions and 155 deletions

View File

@@ -1,9 +1,7 @@
#!/usr/bin/env sh
set -eu
# 安装证书自动续期定时任务。
# 默认每天 03:00 执行 scripts/renew-certs.sh并把日志写到 logs/cert-renew.log。
# 可以重复执行:安装前会先删除旧的 openresty-gateway cert renew 任务块,再写入新的任务。
# Install an idempotent daily certificate renewal cron block.
MARK_BEGIN="# BEGIN openresty-gateway cert renew"
MARK_END="# END openresty-gateway cert renew"
@@ -13,7 +11,7 @@ LOG_DIR="$ROOT_DIR/logs"
CRON_LINE="$SCHEDULE cd '$ROOT_DIR' && sh scripts/renew-certs.sh >> logs/cert-renew.log 2>&1"
if ! command -v crontab >/dev/null 2>&1; then
echo "错误:缺少 crontab 命令。" >&2
echo "Error: crontab is required." >&2
exit 1
fi
@@ -22,7 +20,7 @@ mkdir -p "$LOG_DIR"
tmp_file="$(mktemp)"
trap 'rm -f "$tmp_file"' EXIT
echo "删除已存在的证书续期 cron 块(如果存在)..."
echo "Replacing existing certificate renewal cron block if present..."
crontab -l 2>/dev/null | sed "/$MARK_BEGIN/,/$MARK_END/d" > "$tmp_file"
{
echo "$MARK_BEGIN"
@@ -32,5 +30,5 @@ crontab -l 2>/dev/null | sed "/$MARK_BEGIN/,/$MARK_END/d" > "$tmp_file"
crontab "$tmp_file"
echo "已安装证书续期 cron"
echo "Installed certificate renewal cron:"
echo "$CRON_LINE"