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>
15 export PATH
=/sbin
:/usr
/sbin
:/bin
:/usr
/bin
17 test -x /usr
/sbin
/snmpd ||
exit 0
18 test -x /usr
/sbin
/snmptrapd ||
exit 0
21 export MIBDIRS
=/usr
/share
/snmp
/mibs
23 SNMPDOPTS
='-Lsd -Lf /dev/null -p /var/run/snmpd.pid 127.0.0.1'
25 TRAPDOPTS
='-Lsd -p /var/run/snmptrapd.pid'
27 # Reads config file (will override defaults above)
28 [ -r /etc
/default
/snmpd
] && .
/etc
/default
/snmpd
32 # Cd to / before starting any daemons.
35 # Create compatibility link to old AgentX socket location
36 if [ "$SNMPDCOMPAT" = "yes" ]; then
37 ln -sf /var
/agentx
/master
/var
/run
/agentx
41 if [ "$SNMPDRUN" = "yes" -a -f /etc
/snmp
/snmpd.conf
]; then
42 printf "Starting SNMP daemon: "
43 start-stop-daemon
-q -S -x /usr
/sbin
/snmpd
-- $SNMPDOPTS
44 [ $?
= 0 ] && echo "OK" ||
echo "FAIL"
47 if [ "$TRAPDRUN" = "yes" -a -f /etc
/snmp
/snmptrapd.conf
]; then
48 printf "Starting SNMP trap daemon: "
49 start-stop-daemon
-q -S -x /usr
/sbin
/snmptrapd
-- $TRAPDOPTS
50 [ $?
= 0 ] && echo "OK" ||
echo "FAIL"
55 if [ "$SNMPDRUN" = "yes" -a -f /etc
/snmp
/snmpd.conf
]; then
56 printf "Stopping SNMP daemon: "
57 start-stop-daemon
-q -K $ssd_oknodo -x /usr
/sbin
/snmpd
58 [ $?
= 0 ] && echo "OK" ||
echo "FAIL"
61 if [ "$TRAPDRUN" = "yes" -a -f /etc
/snmp
/snmptrapd.conf
]; then
62 printf "Stopping SNMP trap daemon: "
63 start-stop-daemon
-q -K $ssd_oknodo -x /usr
/sbin
/snmptrapd
64 [ $?
= 0 ] && echo "OK" ||
echo "FAIL"
69 if [ "$SNMPDRUN" = "yes" -a -f /etc
/snmp
/snmpd.conf
]; then
70 printf "Reloading SNMP daemon: "
71 start-stop-daemon
-q -K -s 1 -p /var
/run
/snmpd.pid
-x /usr
/sbin
/snmpd
72 [ $?
= 0 ] && echo "OK" ||
echo "FAIL"
75 if [ "$TRAPDRUN" = "yes" -a -f /etc
/snmp
/snmptrapd.conf
]; then
76 printf "Reloading SNMP trap daemon: "
77 start-stop-daemon
-q -K -s 1 -p /var
/run
/snmptrapd.pid
-x /usr
/sbin
/snmptrapd
78 [ $?
= 0 ] && echo "OK" ||
echo "FAIL"
93 # Allow the daemons time to exit completely.
103 echo "Usage: $0 {start|stop|restart|reload|force-reload}"