/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to network-hooks.d/openvpn

  • Committer: Teddy Hogeborn
  • Date: 2011-12-21 17:09:12 UTC
  • mfrom: (526 trunk)
  • mto: This revision was merged to the branch mainline in revision 527.
  • Revision ID: teddy@recompile.se-20111221170912-tr0v60ul607zhd2q
Merge from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
# configuration file(s) should be copied into the
7
7
# /etc/mandos/network-hooks.d directory.
8
8
9
 
# Copyright © 2012 Teddy Hogeborn
10
 
# Copyright © 2012 Björn Påhlsson
11
 
12
9
# Copying and distribution of this file, with or without modification,
13
10
# are permitted in any medium without royalty provided the copyright
14
11
# notice and this notice are preserved.  This file is offered as-is,
19
16
CONFIG="openvpn.conf"
20
17
 
21
18
# Extract the "dev" setting from the config file
22
 
VPNDEVICE=`sed -n -e 's/[[:space:]]#.*//' \
23
 
    -e 's/^[[:space:]]*dev[[:space:]]\+//p' \
24
 
    "$MANDOSNETHOOKDIR/$CONFIG"`
 
19
VPNDEVICE="`sed -n -e 's/#.*//' -e 's/^[[:space:]]*dev[[:space:]]\+//p' \"$MANDOSNETHOOKDIR/$CONFIG\"`"
25
20
 
26
21
PIDFILE=/run/openvpn-mandos.pid
27
22
 
37
32
 
38
33
openvpn=/usr/sbin/openvpn
39
34
 
40
 
do_start(){
41
 
    "$openvpn" --cd "$MANDOSNETHOOKDIR" --daemon 'openvpn(Mandos)' \
42
 
        --writepid "$PIDFILE" --config "$CONFIG"
43
 
     sleep "$DELAY"
44
 
}
45
 
 
46
 
do_stop(){
47
 
    PID="`cat \"$PIDFILE\"`"
48
 
    if [ "$PID" -gt 0 ]; then
49
 
        kill "$PID"
50
 
    fi
51
 
}
52
 
 
53
 
case "${MODE:-$1}" in
54
 
    start|stop)
55
 
        do_"${MODE:-$1}"
 
35
case "$1" in
 
36
    start)
 
37
        "$openvpn" --cd "$MANDOSNETHOOKDIR" --daemon 'openvpn(Mandos)' --writepid "$PIDFILE" --config "$CONFIG"
 
38
        sleep "$DELAY"
 
39
        ;;
 
40
    stop)
 
41
        PID="`cat \"$PIDFILE\"`"
 
42
        if [ "$PID" -gt 0 ]; then
 
43
            kill "$PID"
 
44
        fi
56
45
        ;;
57
46
    files)
58
47
        echo "$openvpn"