refactor: lego outputs to /opt/backup/certs/, one backup directory

This commit is contained in:
Claus Lohmar 2026-07-07 15:27:30 +01:00
parent c7d25c0107
commit 6d87718b43
2 changed files with 2 additions and 10 deletions

View file

@ -113,19 +113,11 @@ if [ "$GREENFIELD" = true ]; then
echo "[INFO] .env deployed from backup"
fi
# Copy certificates from backup vault or lego cache to Zoraxy cert dir
# Copy certificates from backup vault to Zoraxy cert dir
for DOMAIN_SUB in app dns www; do
FQDN="${DOMAIN_SUB}.${DOMAIN}"
CERT_SRC="$BACKUP_DIR/certs/${FQDN}/fullchain.pem"
KEY_SRC="$BACKUP_DIR/certs/${FQDN}/privkey.pem"
# Fallback to lego's SAN cert (named after first domain)
if [ ! -f "$CERT_SRC" ] && [ -d "$BACKUP_DIR/lego/certificates" ]; then
LECHO=$(ls "$BACKUP_DIR/lego/certificates/"*.crt 2>/dev/null | grep -v issuer | head -1)
if [ -n "$LECHO" ]; then
CERT_SRC="$LECHO"
KEY_SRC="${LECHO%.crt}.key"
fi
fi
if [ -f "$CERT_SRC" ] && [ -f "$KEY_SRC" ]; then
cp "$CERT_SRC" "$TARGET_DIR/config/zoraxy/conf/certs/${FQDN}.crt"
cp "$KEY_SRC" "$TARGET_DIR/config/zoraxy/conf/certs/${FQDN}.key"

View file

@ -97,7 +97,7 @@ func runCert(args []string) {
domainsStr := fs.String("domains", "", "Comma-separated domain list")
email := fs.String("email", "", "ACME email")
backupDir := fs.String("backup-dir", "/opt/backup/certs", "Backup directory for certs")
legoDir := fs.String("lego-dir", "/opt/backup/lego", "Lego working directory")
legoDir := fs.String("lego-dir", "/opt/backup/certs", "Lego working directory")
fs.Parse(args)
if *domainsStr == "" || *email == "" {