summaryrefslogtreecommitdiff
path: root/rapid-tunneling-status
diff options
context:
space:
mode:
Diffstat (limited to 'rapid-tunneling-status')
-rwxr-xr-xrapid-tunneling-status21
1 files changed, 19 insertions, 2 deletions
diff --git a/rapid-tunneling-status b/rapid-tunneling-status
index 8040616..1b9753b 100755
--- a/rapid-tunneling-status
+++ b/rapid-tunneling-status
@@ -3,18 +3,25 @@
base_dir="$HOME/.rapid-tunneling"
if [ "$1" = "--help" ]; then
- echo "Usage: $0 [-p] [<pid-file>]" 1>&2
+ echo "Usage: $0 [-p] [-r] [-s] [<pid-file>]" 1>&2
echo " -p: Print only pid of SSH process (if connecting or connected)." 1>&2
echo " Otherwise, print status" 1>&2
echo " Exit code: 0 if connected, 1 if connecting, 2 if not connected." 1>&2
- echo " $0 -s [<pid-file>]" 1>&2
echo " -s: Stop the tunnel" 1>&2
+ echo " -r: Remove the SSH keys (if not connected)" 1>&2
exit 255
fi
+remove=0
+showpid=0
+stop=0
+
if [ "$1" = "-p" ]; then
showpid=1
shift
+elif [ "$1" = "-r" ]; then
+ remove=1
+ shift
elif [ "$1" = "-s" ]; then
stop=1
shift
@@ -37,15 +44,25 @@ connecting()
not_connected()
{
[ "$showpid" = 1 ] || echo "Not connected"
+ if [ "$remove" = 1 ]; then
+ remove_ssh_keys
+ exit 0
+ fi
exit 2
}
stop_it()
{
kill $pid 2>/dev/null
+ remove_ssh_keys
exit 0
}
+remove_ssh_keys()
+{
+ sed -i '/ rapid-tunneling$/d' "$HOME/.ssh/authorized_keys"
+}
+
pid=`cat "$pidfile" 2>/dev/null`
[ "$pid" ] || not_connected
kill -s 0 $pid 2>/dev/null || not_connected