diff options
author | An-Cheng Huang <ancheng@sydney.vyatta.com> | 2007-10-22 10:34:06 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@sydney.vyatta.com> | 2007-10-22 10:34:06 -0700 |
commit | d34592273240b6ea91b82c479362bd88352b7f65 (patch) | |
tree | 2a1c759216e4abd921e1ecd87746925976e42927 /scripts/snmpd.init | |
parent | d4e70f30421c5c48b256e0e272c91c7b6db2aa86 (diff) | |
parent | 92ee6e6c49cacad059478ad1a50ffa7a50ecd90e (diff) | |
download | vyatta-cfg-quagga-d34592273240b6ea91b82c479362bd88352b7f65.tar.gz vyatta-cfg-quagga-d34592273240b6ea91b82c479362bd88352b7f65.zip |
Merge branch 'master' of phuket.vyatta.com:/usr/local/git/vyatta-cfg-system
Diffstat (limited to 'scripts/snmpd.init')
-rw-r--r-- | scripts/snmpd.init | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/scripts/snmpd.init b/scripts/snmpd.init new file mode 100644 index 00000000..3e4ef17b --- /dev/null +++ b/scripts/snmpd.init @@ -0,0 +1,75 @@ +#! /bin/sh +# /etc/init.d/snmpd: start snmp daemon. + +test -x /usr/sbin/snmpd || exit 0 +test -x /usr/sbin/snmptrapd || exit 0 + +# Defaults +export MIBDIRS=/usr/share/snmp/mibs +SNMPDRUN=yes +SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid' +TRAPDRUN=no +TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' + +# Reads config file (will override defaults above) +[ -r /etc/default/snmpd ] && . /etc/default/snmpd + +# Cd to / before starting any daemons. +cd / + +case "$1" in + start) + echo -n "Starting network management services:" + if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then + start-stop-daemon --quiet --start --exec /usr/sbin/snmpd \ + -- -p /var/run/snmpd.pid + echo -n " snmpd" + fi + if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then + start-stop-daemon --quiet --start --exec /usr/sbin/snmptrapd \ + -- $TRAPDOPTS + echo -n " snmptrapd" + fi + echo "." + ;; + stop) + echo -n "Stopping network management services:" + start-stop-daemon --quiet --stop --pidfile /var/run/snmpd.pid + echo -n " snmpd" + start-stop-daemon --quiet --stop --pidfile /var/run/snmptrapd.pid + echo -n " snmptrapd" + echo "." + ;; + restart) + echo -n "Restarting network management services:" + start-stop-daemon --quiet --stop --pidfile /var/run/snmpd.pid + start-stop-daemon --quiet --stop --pidfile /var/run/snmptrapd.pid + # Allow the daemons time to exit completely. + sleep 2 + if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then + start-stop-daemon --quiet --start --exec /usr/sbin/snmpd -- -p /var/run/snmpd.pid + echo -n " snmpd" + fi + if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then + # Allow snmpd time to start up. + sleep 1 + start-stop-daemon --quiet --start --exec /usr/sbin/snmptrapd -- $TRAPDOPTS + echo -n " snmptrapd" + fi + echo "." + ;; + reload|force-reload) + echo -n "Reloading network management services:" + if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then + start-stop-daemon --quiet --stop --signal 1 \ + --pidfile /var/run/snmpd.pid --exec /usr/sbin/snmpd + echo -n " snmpd" + fi + echo "." + ;; + *) + echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}" + exit 1 +esac + +exit 0 |