From c512f9eb344575ac6bce0b13729c05e1760cd094 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 19 Aug 2012 00:04:07 +0000 Subject: Sun Aug 19 00:04:07 UTC 2012 --- testing/openvpn/openvpn.rc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 testing/openvpn/openvpn.rc (limited to 'testing/openvpn/openvpn.rc') diff --git a/testing/openvpn/openvpn.rc b/testing/openvpn/openvpn.rc new file mode 100755 index 000000000..96c28b641 --- /dev/null +++ b/testing/openvpn/openvpn.rc @@ -0,0 +1,43 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +CFGDIR="/etc/openvpn" +STATEDIR="/var/run/openvpn" + +case "$1" in + start) + stat_busy "Starting OpenVPN ... " + success=0 + mkdir -p "${STATEDIR}" + for cfg in "${CFGDIR}"/*.conf; do + stat_append "$(basename "${cfg}" .conf) " + /usr/sbin/openvpn --daemon --writepid "${STATEDIR}"/"$(basename "${cfg}" .conf)".pid --cd "${CFGDIR}" --config "${cfg}" || success=$? + done + if [ $success -eq 0 ]; then + add_daemon openvpn + stat_done + else + stat_fail + fi + ;; + stop) + stat_busy "Stopping OpenVPN ..." + for pidfile in "${STATEDIR}"/*.pid; do + stat_append "$(basename "${pidfile}" .pid) " + kill $(cat "${pidfile}" 2>/dev/null) 2>/dev/null + rm -f "${pidfile}" + done + rm_daemon openvpn + stat_done + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 -- cgit v1.2.3-54-g00ecf