Spaces:
Paused
Paused
| while true; do | |
| echo "[tmate-log] Launching new tmate session..." | tee /home/draco/tmate.txt | |
| # Start tmate session | |
| tmate -S /tmp/tmate.sock new-session -d | |
| tmate -S /tmp/tmate.sock wait tmate-ready | |
| echo "[tmate-log] SSH: $(tmate -S /tmp/tmate.sock display -p "#{tmate_ssh}")" | tee -a /home/draco/tmate.txt | |
| echo "[tmate-log] Web: $(tmate -S /tmp/tmate.sock display -p "#{tmate_web}")" | tee -a /home/draco/tmate.txt | |
| echo "[tmate-log] Monitoring connection (will restart in 3 hours)..." | tee -a /home/draco/tmate.txt | |
| # Monitor for 3 hours or until tmate process exits | |
| start_time=$(date +%s) | |
| while pgrep -f "tmate -S /tmp/tmate.sock" > /dev/null; do | |
| current_time=$(date +%s) | |
| elapsed=$((current_time - start_time)) | |
| if [ $elapsed -ge 10800 ]; then | |
| echo "[tmate-log] ⏰ 3 hours passed. Restarting session..." | tee -a /home/draco/tmate.txt | |
| pkill -f "tmate -S /tmp/tmate.sock" | |
| break | |
| fi | |
| sleep 5 | |
| done | |
| echo "[tmate-log] ⚠️ Connection lost or timeout. Reconnecting in 5 seconds..." | tee -a /home/draco/tmate.txt | |
| sleep 5 | |
| done |