126 lines
2.4 KiB
Bash
Executable File
126 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright 2015 Mirantis, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
# ucd-snmp init file for snmptrapd
|
|
#
|
|
# chkconfig: - 50 50
|
|
# description: Simple Network Management Protocol (SNMP) Trap Daemon
|
|
#
|
|
# processname: /usr/sbin/snmptrapd
|
|
# config: /etc/snmp/snmptrapd.conf
|
|
# config: /usr/share/snmp/snmptrapd.conf
|
|
# pidfile: /var/run/snmptrapd.pid
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: snmptrapd
|
|
# Required-Start: $local_fs $network
|
|
# Required-Stop: $local_fs $network
|
|
# Should-Start:
|
|
# Should-Stop:
|
|
# Default-Start:
|
|
# Default-Stop:
|
|
# Short-Description: start and stop Net-SNMP trap daemon
|
|
# Description: Simple Network Management Protocol (SNMP) trap daemon
|
|
### END INIT INFO
|
|
|
|
# source function library
|
|
. /etc/init.d/functions
|
|
|
|
#run service in the following network namespace:
|
|
NS="zabbix"
|
|
OPTIONS="-Lsd -p /var/run/snmptrapd.pid"
|
|
if [ -e /etc/sysconfig/snmptrapd ]; then
|
|
. /etc/sysconfig/snmptrapd
|
|
fi
|
|
|
|
RETVAL=0
|
|
prog="snmptrapd"
|
|
binary=/usr/sbin/snmptrapd
|
|
pidfile=/var/run/snmptrapd.pid
|
|
|
|
if [ "x$NS" != "x" ]; then
|
|
cmd="/sbin/ip netns exec $NS $binary"
|
|
else
|
|
cmd=$binary
|
|
fi
|
|
|
|
start() {
|
|
[ -x $binary ] || exit 5
|
|
echo -n $"Starting $prog: "
|
|
daemon --pidfile=$pidfile $cmd $OPTIONS
|
|
RETVAL=$?
|
|
echo
|
|
touch /var/lock/subsys/snmptrapd
|
|
return $RETVAL
|
|
}
|
|
|
|
stop() {
|
|
echo -n $"Stopping $prog: "
|
|
killproc -p $pidfile $binary
|
|
RETVAL=$?
|
|
echo
|
|
rm -f /var/lock/subsys/snmptrapd
|
|
return $RETVAL
|
|
}
|
|
|
|
reload(){
|
|
stop
|
|
start
|
|
}
|
|
|
|
restart(){
|
|
stop
|
|
start
|
|
}
|
|
|
|
condrestart(){
|
|
[ -e /var/lock/subsys/snmptrapd ] && restart
|
|
return 0
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
RETVAL=$?
|
|
;;
|
|
stop)
|
|
stop
|
|
RETVAL=$?
|
|
;;
|
|
restart)
|
|
restart
|
|
RETVAL=$?
|
|
;;
|
|
reload|force-reload)
|
|
reload
|
|
RETVAL=$?
|
|
;;
|
|
condrestart|try-restart)
|
|
condrestart
|
|
RETVAL=$?
|
|
;;
|
|
status)
|
|
status $prog
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
|
|
RETVAL=2
|
|
esac
|
|
|
|
exit $RETVAL
|