File: ssh-tunnel.sh

package info (click to toggle)
bacula 5.0.2-2.2%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 22,692 kB
  • ctags: 15,071
  • sloc: ansic: 109,509; cpp: 24,105; sh: 21,958; makefile: 4,012; perl: 3,083; sql: 1,366; lisp: 479; python: 166; xml: 64; sed: 32; awk: 8
file content (41 lines) | stat: -rwxr-xr-x 1,169 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
# script for creating / stopping a ssh-tunnel to a backupclient
# Stephan Holl<sholl@gmx.net>
# Modified by Joshua Kugler <joshua.kugler@uaf.edu>
#
#

# variables
USER=bacula
CLIENT=$2
LOCAL=your.backup.server.host.name
SSH=/usr/bin/ssh

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 $?
        ;;

 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
        ;;
esac