larpaso-website/claude-remote/claude/rc-loop.sh
Pascal Scholz b42f0049d2 Keep remote-control loop alive when Ctrl+C is pressed in tmux
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 19:45:51 +01:00

31 lines
1,005 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Hält einen Remote-Control-Server für ein Projekt am Laufen.
# Aufruf: rc-loop <projektordner> <git-url>
dir="$1"
url="$2"
# Strg+C beendet nur den laufenden Server, nicht diese Schleife.
trap 'echo " (Strg+C – Neustart folgt; zum Verlassen von tmux: Strg+b, dann d)"' INT
while true; do
if [ ! -d "$dir/.git" ]; then
echo "[$(date '+%F %T')] Klone $url nach $dir ..."
if ! git clone "$url" "$dir"; then
echo "Klonen fehlgeschlagen (SSH-Key in Forgejo hinterlegt? Repo vorhanden?). Neuer Versuch in 60 s."
sleep 60
continue
fi
fi
if [ ! -s "$HOME/.claude/.credentials.json" ]; then
echo "Noch nicht eingeloggt. Einmalig im Container 'claude' starten und /login ausführen. Neuer Versuch in 60 s."
sleep 60
continue
fi
cd "$dir" || exit 1
echo "[$(date '+%F %T')] Starte Remote-Control-Server in $dir"
claude remote-control --spawn worktree
echo "[$(date '+%F %T')] Server beendet (Exit $?). Neustart in 30 s."
sleep 30
done