Skip to content

Commit f6cae4a

Browse files
andyclaude
andcommitted
Gateway scripts: find ecce-session-lib.sh beside a symlink's target too
b3ca4e4 dropped readlink -f (missing on macOS 10.15), so a gateway script run through a symlink whose directory has no ecce-session-lib.sh (the test isolates link bin/ scripts one by one) fell back to $ECCE_HOME/bin and failed there: tests/teaching on main stopped at 'services did not start'. Follow one level of plain readlink before the $ECCE_HOME fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PFPK14wBcLD1s4dYUowpP4
1 parent 7a0fb7b commit f6cae4a

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎packaging/gateway/ecce-gateway-reap‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ ECCE_HOME="${ECCE_HOME:-/opt/ecce}"
3737
ECCE_REALUSERHOME="${ECCE_REALUSERHOME:-$HOME}"
3838
STATEDIR="$ECCE_REALUSERHOME/.ECCE"
3939
UID_="$(id -u)"
40+
# Beside the script, else beside its symlink target (plain readlink: no -f
41+
# on macOS 10.15), else in $ECCE_HOME/bin.
4042
_lib="$(dirname "$0")/ecce-session-lib.sh"
43+
if [ ! -r "$_lib" ] && _t=$(readlink "$0" 2>/dev/null); then
44+
case $_t in /*) ;; *) _t="$(dirname "$0")/$_t" ;; esac
45+
_lib="$(dirname "$_t")/ecce-session-lib.sh"
46+
fi
4147
[ -r "$_lib" ] || _lib="$ECCE_HOME/bin/ecce-session-lib.sh"
4248
. "$_lib" || { echo "ecce-gateway-reap: cannot read $_lib" >&2; exit 1; }
4349

‎packaging/gateway/ecce-gateway-start‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ export ECCE_REALUSERHOME="${ECCE_REALUSERHOME:-$HOME}"
2020
export ECCE_REALUSER="${ECCE_REALUSER:-$(id -un)}"
2121
export HOST="${HOST:-$(hostname)}"
2222

23+
# Beside the script, else beside its symlink target (plain readlink: no -f
24+
# on macOS 10.15), else in $ECCE_HOME/bin.
2325
_lib="$(dirname "$0")/ecce-session-lib.sh"
26+
if [ ! -r "$_lib" ] && _t=$(readlink "$0" 2>/dev/null); then
27+
case $_t in /*) ;; *) _t="$(dirname "$0")/$_t" ;; esac
28+
_lib="$(dirname "$_t")/ecce-session-lib.sh"
29+
fi
2430
[ -r "$_lib" ] || _lib="$ECCE_HOME/bin/ecce-session-lib.sh"
2531
. "$_lib" || { echo "ecce-gateway-start: cannot read $_lib" >&2; exit 1; }
2632
ecce_session_ensure

‎packaging/gateway/ecce-gateway-status‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ shared=""
1414

1515
# The broker file is what the processes actually use: this session's, or
1616
# failing that any one of this account's.
17+
# Beside the script, else beside its symlink target (plain readlink: no -f
18+
# on macOS 10.15), else in $ECCE_HOME/bin.
1719
_lib="$(dirname "$0")/ecce-session-lib.sh"
20+
if [ ! -r "$_lib" ] && _t=$(readlink "$0" 2>/dev/null); then
21+
case $_t in /*) ;; *) _t="$(dirname "$0")/$_t" ;; esac
22+
_lib="$(dirname "$_t")/ecce-session-lib.sh"
23+
fi
1824
[ -r "$_lib" ] || _lib="$ECCE_HOME/bin/ecce-session-lib.sh"
1925
. "$_lib" || { echo "ecce-gateway-status: cannot read $_lib" >&2; exit 1; }
2026
bfile="$(ecce_broker_file)" || bfile=""

‎packaging/gateway/ecce-gateway-stop‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ set -u
77
ECCE_REALUSERHOME="${ECCE_REALUSERHOME:-$HOME}"
88
STATEDIR="$ECCE_REALUSERHOME/.ECCE"
99
ECCE_HOME="${ECCE_HOME:-/opt/ecce}"
10+
# Beside the script, else beside its symlink target (plain readlink: no -f
11+
# on macOS 10.15), else in $ECCE_HOME/bin.
1012
_lib="$(dirname "$0")/ecce-session-lib.sh"
13+
if [ ! -r "$_lib" ] && _t=$(readlink "$0" 2>/dev/null); then
14+
case $_t in /*) ;; *) _t="$(dirname "$0")/$_t" ;; esac
15+
_lib="$(dirname "$_t")/ecce-session-lib.sh"
16+
fi
1117
[ -r "$_lib" ] || _lib="$ECCE_HOME/bin/ecce-session-lib.sh"
1218
. "$_lib" || { echo "ecce-gateway-stop: cannot read $_lib" >&2; exit 1; }
1319
# The data server credential this session's processes share through

0 commit comments

Comments
 (0)