#!/bin/bash
#
# /etc/openvpn/opvpn
#
# ::copy::
# ::maintainer::
#
CMD=$(basename $0)
CMDVER="1.5"
CMDSTR="$CMD v$CMDVER (2026-07-27)"

OPENVPN=/usr/sbin/openvpn
PARMS="
	--user openvpn --group openvpn
	--cd /etc/openvpn
	--verb 5
"

tmp=`mktemp /tmp/opvpn-XXXXXXXXX` || exit $?

trap "rm -f $tmp; exit 255" 1 2 3 15

for conf
do
	conf=`echo $conf | sed -e 's/\.conf$//'`
	grep -v '^log' /etc/openvpn/$conf.conf >$tmp

	$OPENVPN $PARMS \
		--writepid /var/run/openvpn.$conf.pid \
		--config $tmp
done

rm -f $tmp
exit 0
