3 # Provides: snmpd snmptrapd
4 # Required-Start: $network $local_fs
5 # Required-Stop: $network $local_fs
6 # Default-Start: 2 3 4 5
8 # Short-Description: SNMP agents
9 # Description: NET SNMP (Simple Network Management Protocol) Agents
12 # Author: Jochen Friedrich <jochen@scram.de>
16 export PATH=/sbin:/usr/sbin:/bin:/usr/bin
18 test -x /usr/sbin/snmpd || exit 0
19 test -x /usr/sbin/snmptrapd || exit 0
22 export MIBDIRS=/usr/share/snmp/mibs
24 SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid 127.0.0.1'
26 TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
28 # Reads config file (will override defaults above)
29 [ -r /etc/default/snmpd ] && . /etc/default/snmpd
33 # Cd to / before starting any daemons.
36 # Create compatibility link to old AgentX socket location
37 if [ "$SNMPDCOMPAT" = "yes" ]; then
38 ln -sf /var/agentx/master /var/run/agentx
43 echo -n "Starting network management services:"
44 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
45 start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
48 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
49 start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
55 echo -n "Stopping network management services:"
56 start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
58 start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
63 echo -n "Restarting network management services:"
64 start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
65 start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
66 # Allow the daemons time to exit completely.
68 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
69 start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
72 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
73 # Allow snmpd time to start up.
75 start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
81 echo -n "Reloading network management services:"
82 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
83 start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
89 echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"