Files
openresty-gateway/scripts/uninstall-renew-cron.sh
2026-05-18 22:32:08 +08:00

22 lines
574 B
Bash

#!/usr/bin/env sh
set -eu
# 卸载 scripts/install-renew-cron.sh 安装的证书自动续期定时任务。
# 只删除固定标记之间的内容,不影响其它 crontab 任务。
MARK_BEGIN="# BEGIN openresty-gateway cert renew"
MARK_END="# END openresty-gateway cert renew"
if ! command -v crontab >/dev/null 2>&1; then
echo "错误:缺少 crontab 命令。" >&2
exit 1
fi
tmp_file="$(mktemp)"
trap 'rm -f "$tmp_file"' EXIT
crontab -l 2>/dev/null | sed "/$MARK_BEGIN/,/$MARK_END/d" > "$tmp_file"
crontab "$tmp_file"
echo "已卸载证书续期 cron。"