422bb6ec4ed5b55d7bbb6043a7eee76a2b2abaf2
[distro-setup] / prof-remote
1 #!/bin/bash
2
3
4 set -e; . /usr/local/lib/err; set +e
5
6 remote=$1
7 fastcon=0
8 while true; do
9 start=$EPOCHSECONDS
10 # -n or else it competes with the other ssh for reading stdin.
11 ssh -n $remote prof-tail | prof-notify &
12 ssh -t $remote screen -Dr -S profanity ||:
13 builtin kill %% &> /dev/null ||:
14 if (( EPOCHSECONDS > start + 600 )); then
15 fastcon=0
16 fi
17 # we try to reconnect quickly for a while (just once as I write this),
18 # then try to reconnect slowly.
19 if (( fastcon < 1 )); then
20 echo "waiting 10. any key to cancel"
21 read -rsN1 -t 10 ||:
22 fastcon=$((fastcon+1))
23 else
24 echo "waiting 120. any key to cancel"
25 # like sleep but stop on any input
26 read -rsN1 -t 120 ||:
27 fi
28 done