mostly profanity and fixes
[distro-setup] / prof-remote
diff --git a/prof-remote b/prof-remote
new file mode 100755 (executable)
index 0000000..d848894
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+
+set -e; . /usr/local/lib/err; set +e
+
+remote=$1
+fastcon=0
+while true; do
+  start=$EPOCHSECONDS
+  ssh -t $remote screen -Dr -S profanity
+  if (( EPOCHSECONDS > start + 600 )); then
+    fastcon=0
+  fi
+  # we try to reconnect quickly for a while (just once as I write this),
+  # then try to reconnect slowly.
+  if (( fastcon < 1 )); then
+    echo "waiting 10. any key to cancel"
+    read -rsN1 -t 10 ||:
+    fastcon=$((fastcon+1))
+  else
+    echo "waiting 120. any key to cancel"
+    # like sleep but stop on any input
+    read -rsN1 -t 120 ||:
+  fi
+done