yes, working nicely, plus now we're guarding against running the same tunnel
authorChris Koeritz <fred@gruntose.com>
Sun, 14 Apr 2013 15:26:00 +0000 (11:26 -0400)
committerChris Koeritz <fred@gruntose.com>
Sun, 14 Apr 2013 15:26:00 +0000 (11:26 -0400)
twice based on its screen name.

scripts/security/screened_tunneler.sh

index 8e855bffddcb2725f061b19a39c785f3f6bdbfb4..e8fb61cd20b8d5db4a0a4ae689b9aaa0f07e8180 100755 (executable)
@@ -111,6 +111,13 @@ if [ $LAUNCHING_TUNNEL -eq 1 ]; then
   # loop does not exit on its own.
 else
   # this version re-launches the script but tells it to start the tunnel.
+  existingScreens="$(screen -ls | grep "$TUNNEL_SCREEN_NAME")"
+  if [ ! -z "$existingScreens" ]; then
+    echo "This script is already running a screen for: $TUNNEL_SCREEN_NAME"
+    echo "Connect to that and zap it first before we try to start a new one,"
+    echo "e.g.: screen -r -S \"$TUNNEL_SCREEN_NAME\""
+    exit 1
+  fi
   screen -L -S "$TUNNEL_SCREEN_NAME" -d -m bash $0 "$TUNNEL_USER_PLUS_HOST" "$TUNNEL_LINK" "$TUNNEL_SCREEN_NAME" "$TUNNEL_SECURITY_KEY" go
 fi