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.
18
# Extract the "dev" setting from the config file
19
VPNDEVICE=`sed -n -e 's/[[:space:]]#.*//' \
20
-e 's/^[[:space:]]*dev[[:space:]]\+//p' \
21
"$MANDOSNETHOOKDIR/$CONFIG"`
23
PIDFILE=/run/openvpn-mandos.pid
25
# Exit if no device set in config
26
if [ -z "$VPNDEVICE" ]; then
30
# Exit if DEVICE is set and it doesn't match the VPN interface
31
if [ -n "$DEVICE" -a "$DEVICE" = "${DEVICE#$VPNDEVICE}" ]; then
35
openvpn=/usr/sbin/openvpn
39
"$openvpn" --cd "$MANDOSNETHOOKDIR" \
40
--daemon 'openvpn(Mandos)' --writepid "$PIDFILE" \
45
PID="`cat \"$PIDFILE\"`"
46
if [ "$PID" -gt 0 ]; then