start
[eostre.git] / meatviewer / client.sh
diff --git a/meatviewer/client.sh b/meatviewer/client.sh
new file mode 100644 (file)
index 0000000..4745489
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash -xe
+
+function print_usage {
+       echo \
+"
+       usage: $0 PORT REMOTE_PORT user@proxy
+       script that sets up a reverse ssh tunnel, and optionally starts a VNC server as well if the START_VNC environment variable is not null
+       PORT is the port that your techy needs access to. In general, for graphical issues use 5900 and for command-line issues use 22
+       REMOTE_PORT is the port that you'll get on the proxy server, any number over 1000 works as long as you and your techy plug in the same number
+       user@proxy is just your username at the remote proxy machine
+"
+}
+
+[ -n $@ ] || print_usage
+
+PORT_TO_FORWARD=$1
+REMOTE_PORT=$2
+PROXY=$3
+
+ssh -T -R $REMOTE_PORT:localhost:$PORT_TO_FORWARD $PROXY
+
+# quick code that starts up a VNC server for us, if we like
+# this won't run if START_VNC is set
+[ -n $START_VNC ] || exit
+DISPLAY="${DISPLAY:-:0}"
+# -forever - x11vnc won't exit after the first disconnect
+# -shared - allow multiple clients to share the same screen
+# -localhost - only allow connections that are tunneled through localhost
+x11vnc -forever -shared -localhost