From aeabd0e7f28d99ecc84d3f7b80e4df822dd9bfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= Date: Tue, 2 Jun 2026 15:39:30 +0200 Subject: [PATCH] Load .env in start-macos.sh for APP_PORT and APP_BIND (#1008) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Load .env in start-macos.sh for APP_PORT and APP_BIND Parses .env at startup (consistent with how app.py reads it via python-dotenv) so APP_PORT and APP_BIND are honoured without having to retype them on the command line every run. Resolution order: shell env (ODYSSEUS_PORT / ODYSSEUS_HOST) → .env (APP_PORT / APP_BIND) → built-in defaults. Existing ODYSSEUS_* shell overrides are fully preserved. Co-Authored-By: Claude Sonnet 4.6 * Document .env support for APP_PORT and APP_BIND in macOS section Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- README.md | 6 +++++- start-macos.sh | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e02e26b..fd3673c 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,11 @@ ODYSSEUS_HOST=0.0.0.0 ./start-macos.sh # then open http://:7860 ``` -Keep auth enabled when binding outside loopback, and do not expose this port directly to the public internet. To build a clickable app wrapper: +The script also reads `.env` at startup, so `APP_BIND=0.0.0.0` and `APP_PORT` +set there are picked up automatically without a command-line override each run. + +Keep `AUTH_ENABLED=true` (the default) before binding outside loopback. Do not +expose this port directly to the public internet. To build a clickable app wrapper: ```bash ./build-macos-app.sh diff --git a/start-macos.sh b/start-macos.sh index 966989d..85a1b43 100755 --- a/start-macos.sh +++ b/start-macos.sh @@ -16,8 +16,24 @@ set -e REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$REPO_DIR" -PORT="${ODYSSEUS_PORT:-7860}" # 7860, not 7000 — macOS AirPlay Receiver holds 7000. -HOST="${ODYSSEUS_HOST:-127.0.0.1}" # Set ODYSSEUS_HOST=0.0.0.0 for LAN/Tailscale access. +# Load .env so APP_PORT and APP_BIND are available without re-typing them on +# the command line every run — consistent with how app.py reads them via +# python-dotenv. Variables already set in the shell take priority over .env. +if [ -f .env ]; then + while IFS='=' read -r key value; do + [[ "$key" =~ ^[[:space:]]*# ]] && continue + [[ -z "${key// }" ]] && continue + value="${value%%#*}" + value="${value#"${value%%[![:space:]]*}"}" + value="${value%"${value##*[![:space:]]}"}" + [ -n "$key" ] && [ -z "${!key+x}" ] && export "$key=$value" + done < .env +fi + +# Shell overrides (ODYSSEUS_PORT / ODYSSEUS_HOST) take top priority, then .env +# values (APP_PORT / APP_BIND), then built-in defaults. +PORT="${ODYSSEUS_PORT:-${APP_PORT:-7860}}" # 7860, not 7000 — macOS AirPlay Receiver holds 7000. +HOST="${ODYSSEUS_HOST:-${APP_BIND:-127.0.0.1}}" # Set APP_BIND=0.0.0.0 in .env for LAN/Tailscale access. PROBE_HOST="$HOST" if [ "$PROBE_HOST" = "0.0.0.0" ] || [ "$PROBE_HOST" = "::" ]; then PROBE_HOST="127.0.0.1"