summaryrefslogtreecommitdiff
path: root/rapid-tunneling-status
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-06-15 16:11:40 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-06-15 16:11:40 +0000
commit60a54d6482d6b641e92a12749a8161f2b6311f9a (patch)
treebf4419449db6e17eab0aacc54835883a00f7892c /rapid-tunneling-status
parent01815348667fc8a7f74ca25c986f47d7bea6f88f (diff)
rapid-tunneling: delete old authorized_keys entries
* rapid-tunneling-status -s (Stop) will also delete entries from authorized keys. * rapid-tunneling-status -r (Remove) will do that - if not connected. * Note the authorized_keys file in the man page. * Better initialize variables. * More documentation updates. git-svn-id: svn+ssh://xorcom/home/svn/debs/components/rapid-tunneling@9429 283159da-0705-0410-b60c-f2062b4bb6ad
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