Appearance
hook init —— 生成 hook 骨架
生成 hook 脚本骨架。hook init 支持以下三种 hook 类型,分别对应证书生命周期的不同阶段:
| 类型 | 触发时机 | 默认输出文件 | 主要环境变量 |
|---|---|---|---|
present | DCV 域名验证阶段,为每个域名布置验证材料 | ./present.sh(Windows ./present.bat) | CERTIMAN_DCV_HOST / FQDN / TYPE / VALUE |
cleanup | DCV 完成后清理已布置的验证材料(适用于 dns / cname / file / email;dns-persist / dns-proxy 持久记录不建议配置 cleanup,否则验证记录将在每次验证后被删除) | ./cleanup.sh(Windows ./cleanup.bat) | 同 present,额外收到 CERTIMAN_DCV_RESULT(success / failure) |
deploy | 证书签发或续期后部署到目标服务并执行 reload | ./deploy.sh(Windows ./deploy.bat) | CERTIMAN_CERT_PATH / KEY_PATH / RENEWED |
三种类型的用法相同,只需在命令中指定对应的类型名。生成的骨架均包含:
- 按类型精简的
CERTIMAN_*环境变量注释表 - 解释器声明:macOS / Linux 生成以
#!/bin/sh开头的.sh脚本,Windows 生成以@echo off开头的.bat脚本 - 空的业务逻辑主体(待填入具体调用)
- 退出码约定注释
生成的脚本权限为 0700。三种类型的完整环境变量清单见 Hook 环境变量。
用法
bash
certiman hook init <type> [flags]参数
| 位置参数 / flag | 类型 | 允许值 | 默认 | 说明 |
|---|---|---|---|---|
<type> | string | present / cleanup / deploy | Hook 类型,必填 | |
--out | string | 任意路径 | 按 <type> 派生(见上表) | 输出路径 |
示例
bash
# 生成 present hook 骨架到当前目录
certiman hook init present
# 生成 cleanup hook,指定输出路径
certiman hook init cleanup --out ~/.certiman/hooks/dns-cleanup.sh
# 生成 deploy hook
certiman hook init deploy --out ~/.certiman/hooks/nginx-deploy.sh