Find the vhost by what it proxies to when .deploy-env is absent
The one-time WebSocket check was skipped on exactly the deployments it was added for: install.sh writes .deploy-env, so every host installed before this release has none, and the check gave up rather than looking. The port is in lembas.env, and the vhost is whichever conf.d file proxies to it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+20
-6
@@ -84,19 +84,33 @@ fi
|
|||||||
VHOST_STAMP="$PREFIX/.vhost-applied"
|
VHOST_STAMP="$PREFIX/.vhost-applied"
|
||||||
vhost_now=$(sha256sum "$APP/deploy/nginx-vhost.conf" | cut -d' ' -f1)
|
vhost_now=$(sha256sum "$APP/deploy/nginx-vhost.conf" | cut -d' ' -f1)
|
||||||
|
|
||||||
site_host=""; app_port="8080"
|
site_host=""; app_port=""
|
||||||
# Written by install.sh. Absent on a deployment that predates it, in which case
|
# Written by install.sh, and absent on every deployment that predates it --
|
||||||
# the commands below are a template rather than a copy-paste.
|
# which is the case that most needs the one-time check below, so the port is
|
||||||
|
# recovered from the environment file and the vhost found by what it proxies to.
|
||||||
|
# Guessing "your-host" instead would have skipped the check on exactly the hosts
|
||||||
|
# it was added for.
|
||||||
if [[ -f "$PREFIX/.deploy-env" ]]; then
|
if [[ -f "$PREFIX/.deploy-env" ]]; then
|
||||||
. "$PREFIX/.deploy-env"
|
. "$PREFIX/.deploy-env"
|
||||||
site_host="$SITE_HOST"; app_port="$APP_PORT"
|
site_host="$SITE_HOST"; app_port="$APP_PORT"
|
||||||
fi
|
fi
|
||||||
installed_vhost="/etc/nginx/conf.d/${site_host:-your-host}.conf"
|
if [[ -z "$app_port" && -f "$PREFIX/lembas.env" ]]; then
|
||||||
|
app_port=$(sed -n 's/^LEMBAS_PORT=//p' "$PREFIX/lembas.env" | tail -1)
|
||||||
|
fi
|
||||||
|
app_port="${app_port:-8080}"
|
||||||
|
|
||||||
|
installed_vhost=""
|
||||||
|
if [[ -n "$site_host" && -f "/etc/nginx/conf.d/$site_host.conf" ]]; then
|
||||||
|
installed_vhost="/etc/nginx/conf.d/$site_host.conf"
|
||||||
|
else
|
||||||
|
installed_vhost=$(grep -ls "proxy_pass http://127.0.0.1:$app_port" \
|
||||||
|
/etc/nginx/conf.d/*.conf 2>/dev/null | head -1)
|
||||||
|
fi
|
||||||
|
|
||||||
vhost_stale=""
|
vhost_stale=""
|
||||||
if [[ -f "$VHOST_STAMP" ]]; then
|
if [[ -f "$VHOST_STAMP" ]]; then
|
||||||
[[ "$(cat "$VHOST_STAMP")" != "$vhost_now" ]] && vhost_stale="the template has changed"
|
[[ "$(cat "$VHOST_STAMP")" != "$vhost_now" ]] && vhost_stale="the template has changed"
|
||||||
elif [[ -n "$site_host" && -f "$installed_vhost" ]]; then
|
elif [[ -n "$installed_vhost" ]]; then
|
||||||
# First run with this check, so there is no stamp to compare against. Rather
|
# First run with this check, so there is no stamp to compare against. Rather
|
||||||
# than assume what is installed is current -- which is what the unit check
|
# than assume what is installed is current -- which is what the unit check
|
||||||
# does, and would hide exactly the change this was added for -- look for the
|
# does, and would hide exactly the change this was added for -- look for the
|
||||||
@@ -109,7 +123,7 @@ if [[ -n "$vhost_stale" ]]; then
|
|||||||
echo "== nginx vhost ==" >&2
|
echo "== nginx vhost ==" >&2
|
||||||
echo " $vhost_stale." >&2
|
echo " $vhost_stale." >&2
|
||||||
echo " Review and reinstall it:" >&2
|
echo " Review and reinstall it:" >&2
|
||||||
echo " diff $installed_vhost <(sed \\" >&2
|
echo " diff ${installed_vhost:-/etc/nginx/conf.d/your-host.conf} <(sed \\" >&2
|
||||||
echo " -e 's|__SITE_HOST__|${site_host:-your-host}|g' -e 's|__APP_PORT__|$app_port|g' \\" >&2
|
echo " -e 's|__SITE_HOST__|${site_host:-your-host}|g' -e 's|__APP_PORT__|$app_port|g' \\" >&2
|
||||||
echo " $APP/deploy/nginx-vhost.conf)" >&2
|
echo " $APP/deploy/nginx-vhost.conf)" >&2
|
||||||
echo " Then: sudo nginx -t && sudo systemctl reload nginx" >&2
|
echo " Then: sudo nginx -t && sudo systemctl reload nginx" >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user