feat: LE_DRY_RUN=true skips LE, generates self-signed
This commit is contained in:
parent
c426b711df
commit
efaa917013
2 changed files with 9 additions and 1 deletions
|
|
@ -104,10 +104,12 @@ if [ "$GREENFIELD" = true ]; then
|
||||||
echo "[4/6] Checking certificates..."
|
echo "[4/6] Checking certificates..."
|
||||||
mkdir -p "$BACKUP_DIR/certificates"
|
mkdir -p "$BACKUP_DIR/certificates"
|
||||||
if [ -f "$TOOL_BIN" ]; then
|
if [ -f "$TOOL_BIN" ]; then
|
||||||
|
DRY=""
|
||||||
|
[ "${LE_DRY_RUN:-false}" = "true" ] && DRY="--dry-run"
|
||||||
"$TOOL_BIN" cert \
|
"$TOOL_BIN" cert \
|
||||||
--domains "${APP_SUB}.${DOMAIN},${DNS_SUB}.${DOMAIN},${WWW_SUB}.${DOMAIN}" \
|
--domains "${APP_SUB}.${DOMAIN},${DNS_SUB}.${DOMAIN},${WWW_SUB}.${DOMAIN}" \
|
||||||
--email "${TLS_EMAIL:-admin@${DOMAIN}}" \
|
--email "${TLS_EMAIL:-admin@${DOMAIN}}" \
|
||||||
--backup-dir "$BACKUP_DIR/certificates" 2>&1 || true
|
--backup-dir "$BACKUP_DIR/certificates" $DRY 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 5: Build production directory structure
|
# Step 5: Build production directory structure
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ func runCert(args []string) {
|
||||||
email := fs.String("email", "", "ACME email")
|
email := fs.String("email", "", "ACME email")
|
||||||
backupDir := fs.String("backup-dir", "/opt/backup/certificates", "Backup directory for certs")
|
backupDir := fs.String("backup-dir", "/opt/backup/certificates", "Backup directory for certs")
|
||||||
legoDir := fs.String("lego-dir", "/opt/backup", "Lego working directory")
|
legoDir := fs.String("lego-dir", "/opt/backup", "Lego working directory")
|
||||||
|
dryRun := fs.Bool("dry-run", false, "Skip LE, generate self-signed if no backup")
|
||||||
fs.Parse(args)
|
fs.Parse(args)
|
||||||
|
|
||||||
if *domainsStr == "" || *email == "" {
|
if *domainsStr == "" || *email == "" {
|
||||||
|
|
@ -135,6 +136,11 @@ func runCert(args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if needIssue {
|
if needIssue {
|
||||||
|
if *dryRun {
|
||||||
|
log.Printf("[INFO] Dry-run mode — generating self-signed fallback certs")
|
||||||
|
generateSelfSigned(domains, *backupDir)
|
||||||
|
return
|
||||||
|
}
|
||||||
// Try lego first
|
// Try lego first
|
||||||
legoPath, legoErr := exec.LookPath("lego")
|
legoPath, legoErr := exec.LookPath("lego")
|
||||||
if legoErr == nil {
|
if legoErr == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue