opencode / start.sh
kacapower's picture
fix: auto-inject internal Basic Auth to eliminate 401 Basic Realm prompt
7a31669
Raw History Blame Contribute Delete
888 Bytes
#!/bin/bash
set -uo pipefail
cd /home/node || exit 1
export OPENCODE_SERVER_USERNAME="opencode"
export OPENCODE_SERVER_PASSWORD="loopback_internal_pass_777"
echo "[start] hydrating from bucket"
python3 /home/node/sync.py --pull || echo "[start] pull failed - starting with local files"
echo "[start] launching sync daemon"
python3 /home/node/sync.py &
SYNC_PID=$!
cleanup() {
echo "[start] shutting down"
kill -TERM "$SYNC_PID" 2>/dev/null
wait "$SYNC_PID" 2>/dev/null
kill "${OC_PID:-}" "${WEB_PID:-}" 2>/dev/null
exit 0
}
trap cleanup TERM INT
echo "[start] launching opencode (loopback only)"
opencode web --port 4096 --hostname 127.0.0.1 &
OC_PID=$!
echo "[start] launching shell on :7860"
uvicorn app:app --host 0.0.0.0 --port 7860 --proxy-headers --no-server-header &
WEB_PID=$!
wait -n "$OC_PID" "$WEB_PID"
echo "[start] a service exited - shutting down"
cleanup