3
 
# This is an example of a Mandos client network hook.  This hook
 
4
 
# brings up an OpenVPN interface as specified in a separate
 
5
 
# configuration file.  To be used, this file and any needed
 
6
 
# configuration file(s) should be copied into the
 
7
 
# /etc/mandos/network-hooks.d directory.
 
9
 
# Copyright © 2012 Teddy Hogeborn
 
10
 
# Copyright © 2012 Björn Påhlsson
 
12
 
# Copying and distribution of this file, with or without modification,
 
13
 
# are permitted in any medium without royalty provided the copyright
 
14
 
# notice and this notice are preserved.  This file is offered as-is,
 
15
 
# without any warranty.
 
21
 
# 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"`
 
26
 
PIDFILE=/run/openvpn-mandos.pid
 
28
 
# Exit if no device set in config
 
29
 
if [ -z "$VPNDEVICE" ]; then
 
33
 
# Exit if DEVICE is set and it doesn't match the VPN interface
 
34
 
if [ -n "$DEVICE" ]; then
 
36
 
        *,"$VPNDEVICE"*|"$VPNDEVICE"*) :;;
 
41
 
openvpn=/usr/sbin/openvpn
 
44
 
    "$openvpn" --cd "$MANDOSNETHOOKDIR" --daemon 'openvpn(Mandos)' \
 
45
 
        --writepid "$PIDFILE" --config "$CONFIG"
 
50
 
    PID="`cat \"$PIDFILE\"`"
 
51
 
    if [ "$PID" -gt 0 ]; then