#!/bin/bash . /etc/rc.conf . /etc/rc.d/functions PID=`pidof -o %PPID /usr/sbin/openvpn` case "$1" in start) stat_busy "Starting OpenVPN" [ -z "$PID" ] && /etc/openvpn/openvpn-startup.sh if [ $? -gt 0 ]; then stat_fail else PID=`pidof -o %PPID /usr/sbin/openvpn` echo $PID >/var/run/openvpn.pid add_daemon openvpn stat_done fi ;; stop) stat_busy "Stopping OpenVPN" # [ -n "$PID" ] && /etc/openvpn/openvpn-shutdown.sh > /dev/null 2>&1 [ -n "$PID" ] && kill -15 $PID >/dev/null if [ $? -gt 0 ]; then stat_fail else rm -f /var/run/openvpn.pid rm_daemon openvpn stat_done fi ;; restart) $0 stop sleep 1 $0 start ;; *) echo "usage: $0 {start|stop|restart}" esac exit 0