Files
gitea-review-bot/docker-entrypoint.sh

34 lines
1.0 KiB
Bash

#!/bin/sh
# gitea-review-bot container entrypoint — the container's "environment seam".
#
# Generates ~/.ssh/config for the Mac alias from config.toml's [mac] section, then execs the bot.
# SSH-client wiring lives here, not in bot.py (same split matrix-bridge uses). On the Spark host the
# bot would use modelo's existing ~/.ssh/config; in the container we recreate just the one alias.
set -e
SSH_DIR="$HOME/.ssh"
mkdir -p "$SSH_DIR"
chmod 700 "$SSH_DIR"
GRB_SSH_KEY="${GRB_SSH_KEY:-$SSH_DIR/id_ed25519}" \
SSH_CONFIG="$SSH_DIR/config" \
KNOWN_HOSTS="$SSH_DIR/known_hosts" \
python - <<'PY'
import os, tomllib
with open("/app/config.toml", "rb") as f:
mac = tomllib.load(f)["mac"]
config = f"""Host {mac.get('ssh_alias', 'mac-bridge')}
HostName {mac['hostname']}
User {mac['user']}
IdentityFile {os.environ['GRB_SSH_KEY']}
IdentitiesOnly yes
StrictHostKeyChecking accept-new
UserKnownHostsFile {os.environ['KNOWN_HOSTS']}
"""
with open(os.environ['SSH_CONFIG'], "w") as f:
f.write(config)
PY
chmod 600 "$SSH_DIR/config"
exec "$@"