mirror of
https://github.com/curly60e/pyblock.git
synced 2026-08-17 13:07:17 +02:00
Umbrel forces `user: "1000:1000"` in docker-compose, but the previous Dockerfile let useradd assign the next-free UID. Since ubuntu:24.04 ships a pre-existing `ubuntu` user at 1000, `pyblock` ended up as 1001, causing permission errors on the bind-mounted config dir reported in getumbrel/umbrel-apps#5258. - dockerfile: remove the default `ubuntu` user and pin pyblock to UID/GID 1000 so file ownership matches the user Umbrel runs as. - entrypoint.sh: fail fast with a clear, actionable message when the config dir is not writable (covers future UID-mismatch regressions). - umbrel/: bump image tag and app version to v4.0.1 with release notes. Verified with `docker run --user 1000:1000` and an empty bind-mount: all 5 config files generated successfully, ttyd serves on :6969. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
101 lines
3.2 KiB
Bash
Executable file
101 lines
3.2 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
CONFIG_DIR="/app/pyblock/pybitblock/config"
|
|
mkdir -p "$CONFIG_DIR"
|
|
|
|
# Fail fast with a clear message if the config dir is not writable. This is
|
|
# almost always a UID mismatch between the host bind-mount owner and the
|
|
# container user (Umbrel forces `user: "1000:1000"`).
|
|
if ! touch "$CONFIG_DIR/.writetest" 2>/dev/null; then
|
|
echo "[PyBLOCK] FATAL: cannot write to $CONFIG_DIR" >&2
|
|
echo "[PyBLOCK] The bind-mounted host directory must be writable by UID $(id -u):$(id -g)." >&2
|
|
echo "[PyBLOCK] On Umbrel, ensure \${APP_DATA_DIR}/data/config is owned by 1000:1000." >&2
|
|
ls -ld "$CONFIG_DIR" >&2 || true
|
|
exit 1
|
|
fi
|
|
rm -f "$CONFIG_DIR/.writetest"
|
|
|
|
# Auto-generate Bitcoin config from env vars if set
|
|
if [ -n "$BITCOIN_RPC_HOST" ] && [ -n "$BITCOIN_RPC_USER" ]; then
|
|
BITCOIN_RPC_PORT="${BITCOIN_RPC_PORT:-8332}"
|
|
cat > "$CONFIG_DIR/bclock.conf" <<BTCEOF
|
|
{
|
|
"ip_port": "http://${BITCOIN_RPC_HOST}:${BITCOIN_RPC_PORT}",
|
|
"rpcuser": "${BITCOIN_RPC_USER}",
|
|
"rpcpass": "${BITCOIN_RPC_PASS}",
|
|
"bitcoincli": "${BITCOIN_CLI_PATH:-}"
|
|
}
|
|
BTCEOF
|
|
echo "[PyBLOCK] Bitcoin RPC configured: ${BITCOIN_RPC_HOST}:${BITCOIN_RPC_PORT}"
|
|
fi
|
|
|
|
# Auto-generate LND config from env vars if set
|
|
if [ -n "$LND_HOST" ] || [ -n "$LND_TLS_CERT_PATH" ]; then
|
|
LND_GRPC_PORT="${LND_GRPC_PORT:-10009}"
|
|
# Only build ip_port if LND_HOST is set (matches Python _env_lnd_config)
|
|
if [ -n "$LND_HOST" ]; then
|
|
LND_IP_PORT="${LND_HOST}:${LND_GRPC_PORT}"
|
|
else
|
|
LND_IP_PORT=""
|
|
fi
|
|
cat > "$CONFIG_DIR/blndconnect.conf" <<LNDEOF
|
|
{
|
|
"ip_port": "${LND_IP_PORT}",
|
|
"tls": "${LND_TLS_CERT_PATH:-}",
|
|
"macaroon": "${LND_MACAROON_PATH:-}",
|
|
"ln": "${LND_CLI_PATH:-}"
|
|
}
|
|
LNDEOF
|
|
echo "[PyBLOCK] LND configured: ${LND_IP_PORT:-local paths only}"
|
|
fi
|
|
|
|
# Auto-set mode if specified (PYBLOCK_MODE always overwrites)
|
|
PYBLOCK_MODE="${PYBLOCK_MODE:-}"
|
|
if [ -n "$PYBLOCK_MODE" ]; then
|
|
echo "\"${PYBLOCK_MODE}\"" > "$CONFIG_DIR/intro.conf"
|
|
echo "[PyBLOCK] Mode set to: ${PYBLOCK_MODE}"
|
|
elif [ -n "$BITCOIN_RPC_HOST" ] && [ ! -f "$CONFIG_DIR/intro.conf" ]; then
|
|
# Auto-detect mode from available env vars
|
|
if [ -n "$LND_HOST" ] || [ -n "$LND_TLS_CERT_PATH" ]; then
|
|
echo '"A"' > "$CONFIG_DIR/intro.conf"
|
|
echo "[PyBLOCK] Auto-detected mode: A (Bitcoin + Lightning)"
|
|
else
|
|
echo '"B"' > "$CONFIG_DIR/intro.conf"
|
|
echo "[PyBLOCK] Auto-detected mode: B (Bitcoin Only)"
|
|
fi
|
|
fi
|
|
|
|
# Generate default settings if missing
|
|
if [ ! -f "$CONFIG_DIR/pyblocksettings.conf" ]; then
|
|
cat > "$CONFIG_DIR/pyblocksettings.conf" <<SEOF
|
|
{
|
|
"gradient": "",
|
|
"design": "block",
|
|
"colorA": "green",
|
|
"colorB": "yellow"
|
|
}
|
|
SEOF
|
|
fi
|
|
|
|
if [ ! -f "$CONFIG_DIR/pyblocksettingsClock.conf" ]; then
|
|
cat > "$CONFIG_DIR/pyblocksettingsClock.conf" <<SCEOF
|
|
{
|
|
"gradient": "",
|
|
"colorA": "green",
|
|
"colorB": "yellow"
|
|
}
|
|
SCEOF
|
|
fi
|
|
|
|
echo "[PyBLOCK] Starting..."
|
|
|
|
# Ensure UTF-8 for all terminal output (ttyd, AI responses, etc.)
|
|
export LANG="${LANG:-C.UTF-8}"
|
|
export LC_ALL="${LC_ALL:-C.UTF-8}"
|
|
export PYTHONIOENCODING=utf-8
|
|
|
|
# Launch PyBLOCK via ttyd
|
|
exec ttyd -W -p "${PYBLOCK_PORT:-6969}" \
|
|
${PYBLOCK_TTYD_AUTH:+-c "$PYBLOCK_TTYD_AUTH"} \
|
|
python3 /app/pyblock/pybitblock/PyBlock.py "$@"
|