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