/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

Added sample OpenVPN network hook.

* network-hooks.d/openvpn: New.
* network-hooks.d/openvpn.conf: - '' -

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,
16
13
 
17
14
set -e
18
15
 
19
 
CONFIG="openvpn.conf"
 
16
CONFIG="$MANDOSNETHOOKDIR/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' \"$CONFIG\"`"
25
20
 
26
21
PIDFILE=/run/openvpn-mandos.pid
27
22
 
39
34
 
40
35
case "$1" in
41
36
    start)
42
 
        "$openvpn" --cd "$MANDOSNETHOOKDIR" \
43
 
            --daemon 'openvpn(Mandos)' --writepid "$PIDFILE" \
44
 
            --config "$CONFIG"
 
37
        "$openvpn" --cd "$MANDOSNETHOOKDIR" --daemon 'openvpn(Mandos)' --writepid "$PIDFILE" --config "$CONFIG"
45
38
        sleep "$DELAY"
46
39
        ;;
47
40
    stop)
48
 
        PID="`cat \"$PIDFILE\"`"
 
41
        PID=`cat \"$PIDFILE\"`
49
42
        if [ "$PID" -gt 0 ]; then
50
43
            kill "$PID"
51
44
        fi