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