| #!/bin/bash |
|
|
| while true; do |
| echo "[tmate-log] Launching new tmate session..." | tee /home/draco/tmate.txt |
|
|
| |
| 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 |
|
|
| |
| 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 |