From b70981b68efcce5256eb11c6cd26ae123b10b6ea Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 24 Jul 2009 08:01:31 +0000 Subject: moved extra/* to main/ and fixed misc build issues --- main/openvpn/openvpn.initd | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 main/openvpn/openvpn.initd (limited to 'main/openvpn/openvpn.initd') diff --git a/main/openvpn/openvpn.initd b/main/openvpn/openvpn.initd new file mode 100644 index 000000000..a6e4529e1 --- /dev/null +++ b/main/openvpn/openvpn.initd @@ -0,0 +1,63 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +VPNDIR="/etc/openvpn" +VPN="${SVCNAME#*.}" +if [ -n "${VPN}" ] && [ "${SVCNAME}" != "openvpn" ]; then + VPNPID="/var/run/openvpn.${VPN}.pid" +else + VPNPID="/var/run/openvpn.pid" +fi +VPNCONF="${VPNDIR}/${VPN}.conf" + +depend() { + need localmount net + before netmount + after bootmisc +} + +checktundevice() { + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi +} + +start() { + ebegin "Starting ${SVCNAME}" + + checktundevice || return 1 + + if [ ! -e "${VPNCONF}" ]; then + eend 1 "${VPNCONF} does not exist" + return 1 + fi + + local args="" + # If the config file does not specify the cd option, we do + # But if we specify it, we override the config option which we do not want + if ! grep -q "^[ \t]*cd[ \t].*" "${VPNCONF}" ; then + args="${args} --cd ${VPNDIR}" + fi + + start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \ + -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon ${args} + eend $? "Check your logs to see why startup failed" +} + +stop() { + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${VPNPID}" + eend $? +} + +# vim: ts=4 -- cgit v1.2.3