aboutsummaryrefslogtreecommitdiffstats
path: root/mandriva/vpn/vpn-start
blob: 49a02cf19802bafeca5cd144381fc0e5d048b2c3 (plain)
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
#!/bin/sh

TYPE=$1
NAME=$2
shift 2
if [ -z "$TYPE" ] || [ -z "$NAME" ]; then
   echo "usage: $0: <VPN type> <VPN name> [parameters]"
fi

DIR=/etc/sysconfig/network-scripts/vpn.d/"$TYPE"
CONFIG="$DIR"/"$NAME".conf
PID=/var/run/"$TYPE"-"$NAME".pid

. /etc/init.d/functions

if pidofproc "$PID" >/dev/null; then
    gprintf "Connection is already started, please stop it first.\n"
    exit 1
fi

case $TYPE in
     pptp)
        gprintf "No implementation for connection type $TYPE yet.\n";
        exit 1
     ;;
     openvpn)
        action "Starting VPN connection: " openvpn --user openvpn --group openvpn --daemon --writepid $PID --config $CONFIG --cd $DIR $*
     ;;
     vpnc)
        action "Starting VPN connection: " /usr/sbin/vpnc $CONFIG --pid-file $PID $*
     ;;
     *)
        gprintf "Connection type $TYPE is not supported.\n";
        exit 1
     ;;
esac