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
# Copying and distribution of this file, with or without modification,
10
# are permitted in any medium without royalty provided the copyright
11
# notice and this notice are preserved. This file is offered as-is,
12
# without any warranty.
16
CONFIG="$MANDOSNETHOOKDIR/openvpn.conf"
18
# Extract the "dev" setting from the config file
19
VPNDEVICE="`sed -n -e 's/#.*//' -e 's/^[[:space:]]*dev[[:space:]]\+//p' \"$CONFIG\"`"
21
PIDFILE=/run/openvpn-mandos.pid
23
# Exit if no device set in config
24
if [ -z "$VPNDEVICE" ]; then
28
# Exit if DEVICE is set and it doesn't match the VPN interface
29
if [ -n "$DEVICE" -a "$DEVICE" = "${DEVICE#$VPNDEVICE}" ]; then
33
openvpn=/usr/sbin/openvpn
37
"$openvpn" --cd "$MANDOSNETHOOKDIR" --daemon 'openvpn(Mandos)' --writepid "$PIDFILE" --config "$CONFIG"
41
PID=`cat \"$PIDFILE\"`
42
if [ "$PID" -gt 0 ]; then