package/rpi-userland: don't install file in random location
[buildroot-gz.git] / package / netsnmp / S59snmpd
blob4ff844ee3ae196f5a92f69bd8ba2ef1f2fd0c10a
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: snmpd snmptrapd
4 # Required-Start: $network $local_fs
5 # Required-Stop: $network $local_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 6
8 # Short-Description: SNMP agents
9 # Description: NET SNMP (Simple Network Management Protocol) Agents
10 ### END INIT INFO
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
20 # Defaults
21 export MIBDIRS=/usr/share/snmp/mibs
22 SNMPDRUN=yes
23 SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid 127.0.0.1'
24 TRAPDRUN=no
25 TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
27 # Reads config file (will override defaults above)
28 [ -r /etc/default/snmpd ] && . /etc/default/snmpd
30 ssd_oknodo="-o"
32 # Cd to / before starting any daemons.
33 cd /
35 # Create compatibility link to old AgentX socket location
36 if [ "$SNMPDCOMPAT" = "yes" ]; then
37 ln -sf /var/agentx/master /var/run/agentx
40 start() {
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"
54 stop() {
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"
68 reload() {
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"
82 case "$1" in
83 start)
84 start
87 stop)
88 stop
91 restart)
92 stop
93 # Allow the daemons time to exit completely.
94 sleep 2
95 start
98 reload|force-reload)
99 reload
103 echo "Usage: $0 {start|stop|restart|reload|force-reload}"
104 exit 1
105 esac
107 exit 0