From b53c36f33de73bd9f40bea41ddcbe232e7fd3575 Mon Sep 17 00:00:00 2001 From: casjay Date: Mon, 3 Aug 2026 11:37:00 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20opengist=20external-url=20?= =?UTF-8?q?never=20being=20substituted=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found while build-testing the freshly regenerated image in a temp data/config dir: opengist served REPLACE_HOSTNAME literally in every generated URL, and http.git-enabled routes redirected to bogus paths, because __update_conf_files() was patching a config file ($ETC_DIR/opengist.yaml) that doesn't exist -- the shipped config is named config.yaml. Also normalized the substituted value: opengist's external-url must be a full URL (scheme+host), not a bare hostname, or it breaks absolute-URL/redirect generation; ssh.external-domain must stay a bare domain, so it now gets its own REPLACE_SSH_HOSTNAME token instead of reusing the schemed value. Verified via: docker build, then a container run against a scratch temp dir with data/config volumes -- health check reports healthy, config.yaml shows the correct external-url/ssh.external-domain, and /-/all, /-/login, /-/register all return 200 with real opengist HTML. - rootfs/usr/local/etc/docker/init.d/00-opengist.sh: __update_conf_files now targets $ETC_DIR/config.yaml (was opengist.yaml, a nonexistent file), prefixes sysname with http:// when no scheme is present for external-url, and replaces ssh.external-domain via a separate REPLACE_SSH_HOSTNAME token using the unschemed hostname - rootfs/tmp/etc/opengist/config.yaml: ssh.external-domain placeholder changed from REPLACE_HOSTNAME to REPLACE_SSH_HOSTNAME --- rootfs/tmp/etc/opengist/config.yaml | 2 +- rootfs/usr/local/etc/docker/init.d/00-opengist.sh | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rootfs/tmp/etc/opengist/config.yaml b/rootfs/tmp/etc/opengist/config.yaml index c30c09b..78b0364 100644 --- a/rootfs/tmp/etc/opengist/config.yaml +++ b/rootfs/tmp/etc/opengist/config.yaml @@ -47,7 +47,7 @@ ssh.host: 0.0.0.0 ssh.port: 7823 # Public domain for the Git SSH connection, if it has to be different from the HTTP one. -ssh.external-domain: REPLACE_HOSTNAME +ssh.external-domain: REPLACE_SSH_HOSTNAME # Path or alias to ssh-keygen executable. Default: ssh-keygen ssh.keygen-executable: ssh-keygen diff --git a/rootfs/usr/local/etc/docker/init.d/00-opengist.sh b/rootfs/usr/local/etc/docker/init.d/00-opengist.sh index b7b2629..d892d29 100755 --- a/rootfs/usr/local/etc/docker/init.d/00-opengist.sh +++ b/rootfs/usr/local/etc/docker/init.d/00-opengist.sh @@ -316,6 +316,14 @@ __update_conf_files() { local exitCode=0 # set hostname local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" + # opengist's external-url must be a full URL (scheme + host); a bare hostname breaks + # absolute-URL generation (e.g. redirect Location headers). ssh.external-domain must + # stay a bare domain, so it gets its own token instead of reusing the schemed value. + local ssh_sysname="$sysname" + case "$sysname" in + *://*) ;; + *) sysname="http://$sysname" ;; + esac # - - - - - - - - - - - - - - - - - - - - - - - - - # delete files #__rm "" @@ -325,9 +333,10 @@ __update_conf_files() { # - - - - - - - - - - - - - - - - - - - - - - - - - # replace variables - __replace "REPLACE_HOSTNAME" "$sysname" "$ETC_DIR/opengist.yaml" - __replace "REPLACE_DATA_DIR" "$DATA_DIR" "$ETC_DIR/opengist.yaml" - __replace "REPLACE_SERVER_PORT" "$SERVICE_PORT" "$ETC_DIR/opengist.yaml" + __replace "REPLACE_HOSTNAME" "$sysname" "$ETC_DIR/config.yaml" + __replace "REPLACE_SSH_HOSTNAME" "$ssh_sysname" "$ETC_DIR/config.yaml" + __replace "REPLACE_DATA_DIR" "$DATA_DIR" "$ETC_DIR/config.yaml" + __replace "REPLACE_SERVER_PORT" "$SERVICE_PORT" "$ETC_DIR/config.yaml" # replace variables recursively # __find_replace "" "" "$CONF_DIR"