aboutsummaryrefslogtreecommitdiffstats
path: root/mageia/usr/sbin/vpn-start
blob: 18cef8d2144df0b2b0b926171218ae401d97de81 (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=/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