]> git.sur5r.net Git - bacula/bacula/blob - bacula/examples/ssh-tunnel.sh
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / bacula / examples / ssh-tunnel.sh
1 #!/bin/sh
2 # script for creating / stopping a ssh-tunnel to a backupclient
3 # Stephan Holl<sholl@gmx.net>
4 # Modified by Joshua Kugler <joshua.kugler@uaf.edu>
5 #
6 #
7
8 # variables
9 USER=bacula
10 CLIENT=$2
11 LOCAL=your.backup.server.host.name
12 SSH=/usr/bin/ssh
13
14 case "$1" in
15  start)
16     # create ssh-tunnel 
17         echo "Starting SSH-tunnel to $CLIENT..."
18         $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
19         exit $?
20         ;;
21
22  stop)
23         # remove tunnel 
24         echo "Stopping SSH-tunnel to $CLIENT..."
25         # find PID killem
26         PID=`ps ax | grep "ssh -fnCN2 -o PreferredAuthentications=publickey -i /usr/local/bacula/ssh/id_dsa" | grep "$CLIENT" | awk '{ print $1 }'`
27         kill $PID
28         exit $?
29         ;;
30  *)
31         #  usage:
32         echo "             "
33         echo "      Start SSH-tunnel to client-host"
34         echo "      to bacula-director and storage-daemon"
35         echo "            "
36         echo "      USAGE:"
37         echo "      ssh-tunnel.sh {start|stop} client.fqdn"
38         echo ""
39         exit 1
40         ;;
41 esac