diff options
Diffstat (limited to 'network/ocserv/rc.ocserv')
-rw-r--r-- | network/ocserv/rc.ocserv | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/network/ocserv/rc.ocserv b/network/ocserv/rc.ocserv new file mode 100644 index 0000000000000..83fa395888f9a --- /dev/null +++ b/network/ocserv/rc.ocserv @@ -0,0 +1,55 @@ +#!/bin/bash +# Start/stop/restart the ocserv vpn server +# This script uses the occtl tool + +start_ocserv() { + if [ -S /var/run/occtl.socket ]; then + echo "ocserv is already running" + exit 0 + fi + echo "Starting ocserv" + /usr/sbin/ocserv 2>/dev/null +} + +stop_ocserv() { + /usr/bin/occtl stop now +} + +restart_ocserv() { + stop_ocserv + sleep 1 + start_ocserv +} + +reload_ocserv() { + /usr/bin/occtl reload +} + +status_ocserv() { + if [ -S /var/run/occtl.socket ]; then + /usr/bin/occtl show status + else + echo "ocserv is stopped" + exit 1 + fi +} + +case "$1" in +'start') + start_ocserv + ;; +'stop') + stop_ocserv + ;; +'restart') + restart_ocserv + ;; +'reload') + reload_ocserv + ;; +'status') + status_ocserv + ;; +*) + echo "usage $0 start|stop|restart|reload|status" +esac |