-
-
Save asasuou/1b50bb4b2e75dba5d3ca to your computer and use it in GitHub Desktop.
ocserv 启动脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: ocserv | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
### END INIT INFO | |
# Copyright Rene Mayrhofer, Gibraltar, 1999 | |
# This script is distibuted under the GPL | |
PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
DAEMON=/usr/sbin/ocserv | |
PIDFILE=/var/run/ocserv.pid | |
DAEMON_ARGS="-c /etc/ocserv/ocserv.conf" | |
case "$1" in | |
start) | |
if [ ! -r $PIDFILE ]; then | |
echo -n "Starting OpenConnect VPN Server Daemon: " | |
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ | |
$DAEMON_ARGS > /dev/null | |
echo "ocserv." | |
else | |
echo -n "OpenConnect VPN Server is already running.\n\r" | |
exit 0 | |
fi | |
;; | |
stop) | |
echo -n "Stopping OpenConnect VPN Server Daemon: " | |
start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON | |
echo "ocserv." | |
rm -f $PIDFILE | |
;; | |
force-reload|restart) | |
echo "Restarting OpenConnect VPN Server: " | |
$0 stop | |
sleep 1 | |
$0 start | |
;; | |
status) | |
if [ ! -r $PIDFILE ]; then | |
# no pid file, process doesn't seem to be running correctly | |
exit 3 | |
fi | |
PID=`cat $PIDFILE | sed 's/ //g'` | |
EXE=/proc/$PID/exe | |
if [ -x "$EXE" ] && | |
[ "`ls -l \"$EXE\" | cut -d'>' -f2,2 | cut -d' ' -f2,2`" = \ | |
"$DAEMON" ]; then | |
# ok, process seems to be running | |
exit 0 | |
elif [ -r $PIDFILE ]; then | |
# process not running, but pidfile exists | |
exit 1 | |
else | |
# no lock file to check for, so simply return the stopped status | |
exit 3 | |
fi | |
;; | |
*) | |
echo "Usage: /etc/init.d/ocserv {start|stop|restart|force-reload|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment