From 0cc87645ddbfe89be002da7bc7dd6dcc2ff9337d Mon Sep 17 00:00:00 2001 From: Thomas Penteker Date: Thu, 12 Apr 2012 20:13:05 +0200 Subject: [PATCH] openvpn: added rc script, thanks jaeger --- openvpn/.footprint | 3 +++ openvpn/.md5sum | 1 + openvpn/Pkgfile | 4 ++- openvpn/openvpn | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 openvpn/openvpn diff --git a/openvpn/.footprint b/openvpn/.footprint index b2d1329f4..9f21d1022 100644 --- a/openvpn/.footprint +++ b/openvpn/.footprint @@ -1,3 +1,6 @@ +drwxr-xr-x root/root etc/ +drwxr-xr-x root/root etc/rc.d/ +-rwxr-xr-x root/root etc/rc.d/openvpn drwxr-xr-x root/root usr/ drwxr-xr-x root/root usr/man/ drwxr-xr-x root/root usr/man/man8/ diff --git a/openvpn/.md5sum b/openvpn/.md5sum index 0b3116e21..1592cbf0d 100644 --- a/openvpn/.md5sum +++ b/openvpn/.md5sum @@ -1 +1,2 @@ +f8152ae5357778e949c32950874c03ac openvpn c5181e27b7945fa6276d21873329c5c7 openvpn-2.2.2.tar.gz diff --git a/openvpn/Pkgfile b/openvpn/Pkgfile index c423ce4ef..e6fdd1373 100644 --- a/openvpn/Pkgfile +++ b/openvpn/Pkgfile @@ -6,9 +6,11 @@ name=openvpn version=2.2.2 release=1 -source=(http://swupdate.openvpn.net/community/releases/$name-$version.tar.gz) +source=(http://swupdate.openvpn.net/community/releases/$name-$version.tar.gz \ + openvpn) build() { + install -D -m 755 openvpn $PKG/etc/rc.d/openvpn cd $name-$version ./configure --prefix=/usr \ diff --git a/openvpn/openvpn b/openvpn/openvpn new file mode 100644 index 000000000..62ce72f0f --- /dev/null +++ b/openvpn/openvpn @@ -0,0 +1,65 @@ +#!/bin/sh +# +# /etc/rc.d/openvpn: start/stop openvpn daemon +# + +CONFDIR=/etc/openvpn +RUNDIR=/var/run + +# optional arguments to openvpn +OPTARGS="--fast-io" + +usage() { + echo "Usage: $0 [start|stop|restart] " + exit 0 +} + +# require a config name to be specified +if [ -z "$2" ] +then + usage +fi + +CONF=${CONFDIR}/${2}.conf +PID=${RUNDIR}/openvpn.${2}.pid + +# check for the existence of the specified config +if [ ! -f ${CONF} ] +then + echo "Can't find config file ${CONF}! Exiting." + exit 1 +fi + +case $1 in + start) + # check for an existing PID; this tunnel may already be running + if [ -f ${PID} ] + then + echo "VPN '${2}' appears to be running already. If not, remove the stale PID file '${PID}'. Exiting." + exit 2 + fi + # start the specified VPN config + echo "Starting VPN '${2}'..." + /usr/sbin/openvpn --config ${CONF} --writepid ${PID} --daemon ovpn-${2} ${OPTARGS} + ;; + stop) + # check for an existing PID; this tunnel should already be running + if [ ! -f ${PID} ] + then + echo "VPN '${2}' doesn't appear to be running. Exiting." + exit 3 + fi + # stop the specified VPN config + echo "Stopping VPN '${2}'..." + kill `cat ${PID}` + rm -f ${PID} + ;; + restart) + ${0} stop ${2}; sleep 3; ${0} start ${2} + ;; + *) + usage + ;; +esac + +# End of file