diff options
author | root <root@rshg047.dnsready.net> | 2011-05-15 22:39:31 +0000 |
---|---|---|
committer | root <root@rshg047.dnsready.net> | 2011-05-15 22:39:31 +0000 |
commit | a45aa8f19ea32f45610dafabfc06c8b7d1ed5cfe (patch) | |
tree | 3855efd25da6fab2bbaf889a2090a44a9faab93f /testing/openvpn/openvpn.rc | |
parent | e69c538fc7af5a9861c7688dd15913082d978180 (diff) |
Sun May 15 22:39:30 UTC 2011
Diffstat (limited to 'testing/openvpn/openvpn.rc')
-rwxr-xr-x | testing/openvpn/openvpn.rc | 43 |
1 files changed, 43 insertions, 0 deletions
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 |