]> code.delx.au - monosys/blob - ssh-screen-wrapper
multiboot hide umount errors
[monosys] / ssh-screen-wrapper
1 #!/bin/bash -e
2
3 hostname="$(basename "$0")"
4 local_hostname="${hostname}.localnet"
5 public_hostname="p${hostname}"
6
7 if grep -q "^Host ${hostname}$" ~/.ssh/config; then
8 true
9 elif ping -c1 -t1 "$local_hostname" &> /dev/null; then
10 hostname="$local_hostname"
11 else
12 hostname="$public_hostname"
13 fi
14
15 while true; do
16 clear
17 echo "Connecting to ${hostname}..."
18 ssh \
19 -o ServerAliveInterval=1 \
20 -o ServerAliveCountMax=5 \
21 -t \
22 "$hostname" \
23 "bash --login -c 'screen -dR'" \
24 && exit 0
25 echo "Disconnected, waiting..."
26 echo -ne "\033]0;${hostname}: disconnected!\007"
27 sleep 1
28 done
29