]> code.delx.au - monosys/commitdiff
ssh-screen-wrapper
authorJames Bunton <jamesbunton@delx.net.au>
Fri, 1 Nov 2013 12:04:16 +0000 (23:04 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Fri, 1 Nov 2013 12:04:16 +0000 (23:04 +1100)
bin/ssh-screen-wrapper [new file with mode: 0755]

diff --git a/bin/ssh-screen-wrapper b/bin/ssh-screen-wrapper
new file mode 100755 (executable)
index 0000000..99b2f2f
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash -e
+
+hostname="$(basename "$0")"
+local_hostname="${hostname}.localnet"
+public_hostname="p${hostname}"
+
+if grep -q "^Host ${hostname}$" ~/.ssh/config; then
+       true
+elif ping -c1 -t1 "$local_hostname" &> /dev/null; then
+       hostname="$local_hostname"
+else
+       hostname="$public_hostname"
+fi
+
+exec ssh "$hostname" "$@" -t screen -dR
+