This commit is contained in:
Jeffrey Townsend
2016-03-02 02:00:05 +00:00
parent 891eff09de
commit b14ce8a648

View File

@@ -0,0 +1,67 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: onlpd
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start ONLP Platform Agent
# Description: ONLP PLATFORM AGENTX
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
DAEMON=/bin/onlpd
PIDFILE=/var/run/onlpd.pid
ONLP_SNMPD_OPTS="-M $PIDFILE"
QUIET=
test -x $DAEMON || exit 5
RUNASUSER=root
UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
case $1 in
start)
log_daemon_msg "Starting ONLP Platform Agent" "onlpd"
if [ -z "$UGID" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
fi
start-stop-daemon --start $QUIET --oknodo --pidfile $PIDFILE --startas $DAEMON -- $ONLP_SNMPD_OPTS $ONLP_SNMPD_EXTRA_OPTS
status=$?
log_end_msg $status
;;
stop)
log_daemon_msg "Stopping ONLP Platform Agent" "onlpd"
start-stop-daemon --stop $QUIET --oknodo --pidfile $PIDFILE
log_end_msg $?
rm -f $PIDFILE
;;
restart|force-reload)
$0 stop && sleep 2 && $0 start
;;
try-restart)
if $0 status >/dev/null; then
$0 restart
else
exit 0
fi
;;
reload)
log_daemon_msg "Reloading ONLP Platform Agent" "onlpd"
start-stop-daemon --stop $QUIET --oknodo --pidfile $PIDFILE --signal 1
status=$?
log_end_msg $status
;;
status)
status_of_proc $DAEMON "ONLP Platform Agent"
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|reload|status}"
exit 2
;;
esac