Containers for Pascal and Lara run claude remote-control per project (larpaso, youtube) on the VPS, isolated from the web stack, and exchange messages through a small MCP mailbox server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.5 KiB
Bash
57 lines
2.5 KiB
Bash
#!/bin/bash
|
||
# Einstiegspunkt des Claude-Containers. Richtet bei jedem Start die
|
||
# verwaltete Konfiguration ein und startet je Projekt einen
|
||
# Remote-Control-Server in einer tmux-Sitzung.
|
||
set -u
|
||
|
||
: "${MAILBOX_USER:?MAILBOX_USER fehlt}"
|
||
FORGEJO="ssh://git@git.larpaso.de:2222"
|
||
|
||
mkdir -p "$HOME/.claude" "$HOME/.ssh" "$HOME/projekte"
|
||
chmod 700 "$HOME/.ssh"
|
||
|
||
# Git-Identität (E-Mail nur setzen, wenn vorgegeben)
|
||
git config --global user.name "${GIT_NAME:-$MAILBOX_USER}"
|
||
[ -n "${GIT_EMAIL:-}" ] && git config --global user.email "$GIT_EMAIL"
|
||
git config --global init.defaultBranch main
|
||
git config --global pull.rebase true
|
||
|
||
# Eigener SSH-Key für Forgejo – der Public Key muss im Forgejo-Profil
|
||
# der jeweiligen Person hinterlegt werden.
|
||
if [ ! -f "$HOME/.ssh/id_ed25519" ]; then
|
||
ssh-keygen -t ed25519 -N "" -C "claude-${MAILBOX_USER}@vps" -f "$HOME/.ssh/id_ed25519" >/dev/null
|
||
fi
|
||
echo "=== Forgejo-SSH-Key für ${MAILBOX_USER} (in Forgejo → Einstellungen → SSH-Schlüssel eintragen) ==="
|
||
cat "$HOME/.ssh/id_ed25519.pub"
|
||
if ! grep -q "git.larpaso.de" "$HOME/.ssh/known_hosts" 2>/dev/null; then
|
||
ssh-keyscan -p 2222 git.larpaso.de >> "$HOME/.ssh/known_hosts" 2>/dev/null
|
||
fi
|
||
|
||
# Globale Anweisungen für alle Sitzungen
|
||
cp /opt/claude/CLAUDE.global.md "$HOME/.claude/CLAUDE.md"
|
||
|
||
# Postfach-Hinweis als Hook in die Benutzer-Settings mergen
|
||
settings="$HOME/.claude/settings.json"
|
||
[ -s "$settings" ] || echo '{}' > "$settings"
|
||
hook='[{"hooks":[{"type":"command","command":"postfach-hinweis"}]}]'
|
||
tmp=$(mktemp)
|
||
jq --argjson h "$hook" '.hooks.SessionStart = $h | .hooks.UserPromptSubmit = $h' "$settings" > "$tmp" && mv "$tmp" "$settings"
|
||
|
||
# MCP-Postfach (Benutzer-Scope) – immer neu setzen, damit der Header stimmt
|
||
claude mcp remove postfach -s user >/dev/null 2>&1 || true
|
||
claude mcp add --transport http -s user postfach http://postfach:8080/mcp \
|
||
--header "x-mailbox-user: ${MAILBOX_USER}" >/dev/null 2>&1 \
|
||
|| echo "Hinweis: MCP-Postfach konnte nicht registriert werden."
|
||
|
||
# Je Projekt ein Remote-Control-Server
|
||
tmux kill-server 2>/dev/null || true
|
||
tmux new-session -d -s larpaso -n larpaso \
|
||
"rc-loop $HOME/projekte/larpaso $FORGEJO/pascal/larpaso-website.git"
|
||
tmux new-session -d -s youtube -n youtube \
|
||
"rc-loop $HOME/projekte/youtube $FORGEJO/pascal/youtube.git"
|
||
|
||
echo "Remote-Control-Server laufen in tmux (Sitzungen: larpaso, youtube)."
|
||
echo "Ansehen: docker exec -it claude-${MAILBOX_USER} tmux attach -t larpaso (lösen mit Strg+b, dann d)"
|
||
|
||
# Container am Leben halten, solange tmux läuft
|
||
while tmux has-session 2>/dev/null; do sleep 60; done
|