updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / openvpn-dev / openvpn.rc
blob8d95e4c8a33344a55bc0699deb67134a4405db28
1 #!/bin/bash
3 daemon_name=openvpn
5 . /etc/rc.conf
6 . /etc/rc.d/functions
7 . /etc/conf.d/$daemon_name
9 STATEDIR="/var/run/openvpn"
11 case "$1" in
12 start)
13 stat_busy "Starting OpenVPN ... "
14 success=0
15 mkdir -p "${STATEDIR}"
16 for cfg in ${openvpn_confs}; do
17 stat_append "$(basename "${cfg}" .conf) "
18 /usr/sbin/openvpn --daemon --writepid "${STATEDIR}"/"$(basename "${cfg}" .conf)".pid --cd "$(dirname "${cfg}")" --config "${cfg}" || success=$?
19 done
20 if [ $success -eq 0 ]; then
21 add_daemon openvpn
22 stat_done
23 else
24 stat_fail
27 stop)
28 stat_busy "Stopping OpenVPN ..."
29 for pidfile in "${STATEDIR}"/*.pid; do
30 stat_append "$(basename "${pidfile}" .pid) "
31 kill $(cat "${pidfile}" 2>/dev/null) 2>/dev/null
32 rm -f "${pidfile}"
33 done
34 rm_daemon openvpn
35 stat_done
37 restart)
38 $0 stop
39 sleep 1
40 $0 start
43 echo "usage: $0 {start|stop|restart}"
44 esac
45 exit 0