Hi,
I have a patch attached for the ssh-tunnel.sh script included in the
examples directory that makes the tunnel script less Linux-centric by
default, specifically when the script is called to stop the ssh tunnel
to a remote client. In the few Linux distributions I've looked at, the
PID column is first in ps(1) output, however on FreeBSD, AIX, and
Solaris (last I checked on the latter two), the PID column is second.
This patch might allow users to implement ssh-tunneled backups over
insecure lines with hopefully fewer changes over the original versions
of the script.
There should be no regressions from the original version by Stephan Holl
which was later modified by Joshua Kugler, though one notable change I
made was disabling ssh compression, as it tends to slow down data
transfers on fast links.
Comments are welcome.
Regards,
Glen
--
Glen Barber
--- ssh-tunnel.sh.orig 2010-08-05 10:29:51.000000000 -0400
+++ ssh-tunnel.sh 2011-08-13 17:02:53.245625118 -0400
@@ -2,40 +2,61 @@
# script for creating / stopping a ssh-tunnel to a backupclient
# Stephan Holl<sh...@gmx.net>
# Modified by Joshua Kugler <joshua.kug...@uaf.edu>
-#
+# Modified by Glen Barber <glen.j.bar...@gmail.com>
#
# variables
USER=bacula
CLIENT=$2
-LOCAL=your.backup.server.host.name
+LOCAL=`hostname`
SSH=/usr/bin/ssh
+HOME="/usr/local/bacula"
+OS=`uname -s`
case "$1" in
- start)
- # create ssh-tunnel
- echo "Starting SSH-tunnel to $CLIENT..."
- $SSH -fnCN2 -o PreferredAuthentications=publickey -i
/usr/local/bacula/ssh/id_dsa -l $USER -R 9101:$LOCAL:9101 -R 9103:$LOCAL:9103
$CLIENT > /dev/null 2> /dev/null
- exit $?
- ;;
+ start)
+ # create ssh-tunnel
+ echo "Starting SSH-tunnel to $CLIENT..."
+ $SSH -nfN2 -l $USER -i "$HOME/.ssh/id_rsa" -R 9101:$LOCAL:9101
-R 9103:$LOCAL:9103 $CLIENT > /dev/null 2>&1
+ exit $?
+ ;;
+
+ stop)
+ # remove tunnel
+ echo "Stopping SSH-tunnel to $CLIENT..."
+ case ${OS} in
+ AIX)
+ PID=`ps auxww | grep "ssh -nfN2 -l $USER -i
$HOME/.ssh/id_rsa" | grep -v grep | awk '{print $2}'`
+ ;;
+ FreeBSD)
+ PID=`ps auxww | grep "ssh -nfN2 -l $USER -i
$HOME/.ssh/id_rsa" | grep -v grep | awk '{print $2}'`
+ ;;
+ Linux)
+ PID=`ps auxww | grep "ssh -nfN2 -l $USER -i
$HOME/.ssh/id_rsa" | grep -v grep | awk '{print $1}'`
+ ;;
+ *)
+ echo "Cannot identify correct ps(1) column."
+ ;;
+ esac
- stop)
- # remove tunnel
- echo "Stopping SSH-tunnel to $CLIENT..."
- # find PID killem
- PID=`ps ax | grep "ssh -fnCN2 -o PreferredAuthentications=publickey -i
/usr/local/bacula/ssh/id_dsa" | grep "$CLIENT" | awk '{ print $1 }'`
- kill $PID
- exit $?
- ;;
- *)
- # usage:
- echo " "
- echo " Start SSH-tunnel to client-host"
- echo " to bacula-director and storage-daemon"
- echo " "
- echo " USAGE:"
- echo " ssh-tunnel.sh {start|stop} client.fqdn"
- echo ""
- exit 1
- ;;
+ if [ ! $PID ]; then
+ echo "Please check 'ps' output - the tunnel may not
have been killable."
+ exit 0
+ fi
+ echo "Killing $PID ($LOCAL $OS)"
+ kill -9 $PID
+ exit $?
+ ;;
+ *)
+ # usage:
+ echo ""
+ echo " Start SSH-tunnel to client-host"
+ echo " to bacula-director and storage-daemon"
+ echo ""
+ echo " USAGE:"
+ echo " ssh-tunnel.sh {start|stop} client.fqdn"
+ echo ""
+ exit 1
+ ;;
esac
+
------------------------------------------------------------------------------
FREE DOWNLOAD - uberSVN with Social Coding for Subversion.
Subversion made easy with a complete admin console. Easy
to use, easy to manage, easy to install, easy to extend.
Get a Free download of the new open ALM Subversion platform now.
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel