fix: only app+dns active, www+auth empty, dynamic domain lists
This commit is contained in:
parent
b948399d1d
commit
09a74425b3
1 changed files with 30 additions and 17 deletions
47
deploy.sh
47
deploy.sh
|
|
@ -26,10 +26,10 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Subdomain prefixes (hardcoded — change here if needed)
|
# Subdomain prefixes (hardcoded — change here if needed)
|
||||||
APP_SUB="hub"
|
APP_SUB="app"
|
||||||
DNS_SUB="noc"
|
DNS_SUB="dns"
|
||||||
WWW_SUB="www"
|
WWW_SUB=""
|
||||||
AUTH_SUB="auth"
|
AUTH_SUB=""
|
||||||
|
|
||||||
# --- Mode detection ---
|
# --- Mode detection ---
|
||||||
GREENFIELD=false
|
GREENFIELD=false
|
||||||
|
|
@ -103,11 +103,16 @@ if [ "$GREENFIELD" = true ]; then
|
||||||
# Step 4: Run helper tool — port 80 is free, can obtain LE certs via HTTP-01
|
# Step 4: Run helper tool — port 80 is free, can obtain LE certs via HTTP-01
|
||||||
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
|
# Build list of active subdomains (skip empty ones)
|
||||||
|
ALL_SUBS=""
|
||||||
|
for S in $APP_SUB $DNS_SUB $WWW_SUB; do
|
||||||
|
[ -n "$S" ] && ALL_SUBS="${ALL_SUBS:+$ALL_SUBS,}${S}.${DOMAIN}"
|
||||||
|
done
|
||||||
|
if [ -f "$TOOL_BIN" ] && [ -n "$ALL_SUBS" ]; then
|
||||||
DRY=""
|
DRY=""
|
||||||
[ "${LE_DRY_RUN:-false}" = "true" ] && DRY="--dry-run"
|
[ "${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 "$ALL_SUBS" \
|
||||||
--email "${TLS_EMAIL:-admin@${DOMAIN}}" \
|
--email "${TLS_EMAIL:-admin@${DOMAIN}}" \
|
||||||
--backup-dir "$BACKUP_DIR/certificates" $DRY 2>&1 || true
|
--backup-dir "$BACKUP_DIR/certificates" $DRY 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
|
@ -130,8 +135,9 @@ if [ "$GREENFIELD" = true ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy certificates from backup vault to Zoraxy cert dir
|
# Copy certificates from backup vault to Zoraxy cert dir
|
||||||
for DOMAIN_SUB in $APP_SUB $DNS_SUB $WWW_SUB; do
|
for S in $APP_SUB $DNS_SUB $WWW_SUB; do
|
||||||
FQDN="${DOMAIN_SUB}.${DOMAIN}"
|
[ -z "$S" ] && continue
|
||||||
|
FQDN="${S}.${DOMAIN}"
|
||||||
CERT_SRC="$BACKUP_DIR/certificates/${FQDN}/fullchain.pem"
|
CERT_SRC="$BACKUP_DIR/certificates/${FQDN}/fullchain.pem"
|
||||||
KEY_SRC="$BACKUP_DIR/certificates/${FQDN}/privkey.pem"
|
KEY_SRC="$BACKUP_DIR/certificates/${FQDN}/privkey.pem"
|
||||||
if [ -f "$CERT_SRC" ] && [ -f "$KEY_SRC" ]; then
|
if [ -f "$CERT_SRC" ] && [ -f "$KEY_SRC" ]; then
|
||||||
|
|
@ -186,15 +192,18 @@ EOF
|
||||||
# Register certificates using Go tool (handles CSRF/session properly)
|
# Register certificates using Go tool (handles CSRF/session properly)
|
||||||
echo "[*] Registering certificates via Go tool..."
|
echo "[*] Registering certificates via Go tool..."
|
||||||
REG_TOOL="$REPO_DIR/tools/register-certs/register-certs"
|
REG_TOOL="$REPO_DIR/tools/register-certs/register-certs"
|
||||||
if [ -f "$REG_TOOL" ]; then
|
# Build list of domains
|
||||||
cd "$REPO_DIR/tools/register-certs" && go build -o register-certs . 2>/dev/null && cd "$REPO_DIR"
|
DOMAIN_LIST=""
|
||||||
"$REG_TOOL" "${ADMIN_USERNAME:-master}" "${ADMIN_PASSWORD:-9Aku7MfklZU9ldnZ}" \
|
for S in $APP_SUB $DNS_SUB $WWW_SUB; do
|
||||||
${APP_SUB}.${DOMAIN} ${DNS_SUB}.${DOMAIN} ${WWW_SUB}.${DOMAIN} 2>&1 || true
|
[ -n "$S" ] && DOMAIN_LIST="$DOMAIN_LIST ${S}.${DOMAIN}"
|
||||||
else
|
done
|
||||||
echo " [WARN] Register tool not found, building..."
|
if [ -n "$DOMAIN_LIST" ]; then
|
||||||
cd "$REPO_DIR/tools/register-certs"
|
if [ ! -f "$REG_TOOL" ]; then
|
||||||
go build -o register-certs . 2>&1 || true
|
cd "$REPO_DIR/tools/register-certs" && go build -o register-certs . 2>/dev/null && cd "$REPO_DIR"
|
||||||
cd "$REPO_DIR"
|
fi
|
||||||
|
if [ -f "$REG_TOOL" ]; then
|
||||||
|
"$REG_TOOL" "${ADMIN_USERNAME:-master}" "${ADMIN_PASSWORD:-9Aku7MfklZU9ldnZ}" $DOMAIN_LIST 2>&1 || true
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop Zoraxy to write proxy configs
|
# Stop Zoraxy to write proxy configs
|
||||||
|
|
@ -217,6 +226,7 @@ ZORAXY_APP
|
||||||
}
|
}
|
||||||
ZORAXY_DNS
|
ZORAXY_DNS
|
||||||
|
|
||||||
|
if [ -n "$WWW_SUB" ]; then
|
||||||
cat > "$TARGET_DIR/config/zoraxy/conf/proxy/${WWW_SUB}.$DOMAIN.config" <<ZORAXY_WWW
|
cat > "$TARGET_DIR/config/zoraxy/conf/proxy/${WWW_SUB}.$DOMAIN.config" <<ZORAXY_WWW
|
||||||
{
|
{
|
||||||
"ProxyType": 1,
|
"ProxyType": 1,
|
||||||
|
|
@ -225,7 +235,9 @@ ZORAXY_DNS
|
||||||
"Disabled": false, "AuthenticationProvider": {"AuthMethod": 0}
|
"Disabled": false, "AuthenticationProvider": {"AuthMethod": 0}
|
||||||
}
|
}
|
||||||
ZORAXY_WWW
|
ZORAXY_WWW
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$AUTH_SUB" ]; then
|
||||||
cat > "$TARGET_DIR/config/zoraxy/conf/proxy/${AUTH_SUB}.$DOMAIN.config" <<ZORAXY_AUTH
|
cat > "$TARGET_DIR/config/zoraxy/conf/proxy/${AUTH_SUB}.$DOMAIN.config" <<ZORAXY_AUTH
|
||||||
{
|
{
|
||||||
"ProxyType": 1,
|
"ProxyType": 1,
|
||||||
|
|
@ -234,6 +246,7 @@ ZORAXY_WWW
|
||||||
"Disabled": false, "AuthenticationProvider": {"AuthMethod": 0}
|
"Disabled": false, "AuthenticationProvider": {"AuthMethod": 0}
|
||||||
}
|
}
|
||||||
ZORAXY_AUTH
|
ZORAXY_AUTH
|
||||||
|
fi
|
||||||
|
|
||||||
chattr -R +i "$TARGET_DIR/config/zoraxy/conf/proxy/" 2>/dev/null || true
|
chattr -R +i "$TARGET_DIR/config/zoraxy/conf/proxy/" 2>/dev/null || true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue