merge new gateway configs from dev build

This commit is contained in:
techartdev
2026-02-02 02:02:16 +02:00
parent 9aab638714
commit cb68662eb6
8 changed files with 385 additions and 2 deletions
+35
View File
@@ -27,6 +27,10 @@ ROUTER_KEY=$(jq -r '.router_ssh_key_path // "/data/keys/router_ssh"' "$OPTIONS_F
CLEAN_LOCKS_ON_START=$(jq -r '.clean_session_locks_on_start // true' "$OPTIONS_FILE")
CLEAN_LOCKS_ON_EXIT=$(jq -r '.clean_session_locks_on_exit // true' "$OPTIONS_FILE")
# Gateway bind mode (loopback or lan)
GATEWAY_BIND_MODE=$(jq -r '.gateway_bind_mode // "loopback"' "$OPTIONS_FILE")
GATEWAY_PORT=$(jq -r '.gateway_port // 18789' "$OPTIONS_FILE")
export TZ="$TZNAME"
# Reduce risk of secrets ending up in logs
@@ -170,6 +174,8 @@ cfg_path.parent.mkdir(parents=True, exist_ok=True)
cfg = {
"gateway": {
"mode": "local",
"port": 18789,
"bind": "loopback",
"auth": {
"mode": "token",
"token": secrets.token_urlsafe(24)
@@ -182,6 +188,35 @@ print("INFO: Wrote minimal OpenClaw config (gateway.mode=local, auth.token gener
PY
fi
# ------------------------------------------------------------------------------
# Apply gateway LAN mode settings safely using helper script
# This updates gateway.bind and gateway.port without touching other settings
# ------------------------------------------------------------------------------
export OPENCLAW_CONFIG_PATH="/config/.openclaw/openclaw.json"
# Find the helper script (copied to root in Dockerfile, or fallback to add-on dir)
HELPER_PATH="/oc_config_helper.py"
if [ ! -f "$HELPER_PATH" ] && [ -f "$(dirname "$0")/oc_config_helper.py" ]; then
HELPER_PATH="$(dirname "$0")/oc_config_helper.py"
fi
if [ -f "$OPENCLAW_CONFIG_PATH" ]; then
if [ -f "$HELPER_PATH" ]; then
if ! python3 "$HELPER_PATH" apply-bind-mode "$GATEWAY_BIND_MODE" "$GATEWAY_PORT"; then
rc=$?
echo "ERROR: Failed to apply gateway bind mode via oc_config_helper.py (exit code ${rc})."
echo "ERROR: Gateway bind configuration may be incorrect; aborting startup."
exit "${rc}"
fi
else
echo "WARN: oc_config_helper.py not found, cannot apply gateway settings"
echo "INFO: Ensure the add-on image includes oc_config_helper.py and restart"
fi
else
echo "WARN: OpenClaw config not found at $OPENCLAW_CONFIG_PATH, cannot apply gateway settings"
echo "INFO: Run 'openclaw onboard' first, then restart the add-on"
fi
echo "Starting OpenClaw Assistant gateway (openclaw)..."
openclaw gateway run &
GW_PID=$!