}
start() {
- # Check if the service is already running?
- if tunlsup; then
- msg_already_running "OpenVPN"
- return
- fi
-
msg_starting "OpenVPN"; started
for tun in $TUNNELS; do
config="/etc/openvpn/$tun.conf"
fail
RET=1
else
- show "Starting OpenVPN tunnel %s" "$tun"
- if tunlup $tun; then
- started
- continue
- fi
-
+ tunlup $tun && continue
+ show "Starting OpenVPN tunnel %s" "$tun"; busy
daemon --pidfile /var/run/openvpn/$tun.pid /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/$tun.pid \
--config $config --cd /etc/openvpn ${OPENVPN_OPT}
RET=$?
}
stop() {
- if ! tunlsup; then
- msg_not_running "OpenVPN"
- return
- fi
-
- # Stop daemons.
msg_stopping "OpenVPN"; started
for tun in $TUNNELS; do
pidfile=/var/run/openvpn/$tun.pid
pid=`cat "$pidfile"`
show "Stopping OpenVPN tunnel %s" "$tun"; busy
killproc --pidfile openvpn/$tun.pid || err=1
+ rm -f $pidfile
done
rm -f /var/lock/subsys/openvpn >/dev/null 2>&1
}