File: snmpd.init

package info (click to toggle)
net-snmp 5.1.2-6.2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,340 kB
  • ctags: 12,062
  • sloc: ansic: 134,798; perl: 10,855; sh: 10,237; makefile: 5,003
file content (66 lines) | stat: -rw-r--r-- 1,905 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /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 \
	    -- $SNMPDOPTS
	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 --exec /usr/sbin/snmpd
    echo -n " snmpd"
    start-stop-daemon --quiet --stop --exec /usr/sbin/snmptrapd
    echo -n " snmptrapd"
    echo "."
    ;;
  restart|reload|force-reload)
    echo -n "Restarting network management services:"
    start-stop-daemon --quiet --stop --exec /usr/sbin/snmpd
    start-stop-daemon --quiet --stop --exec /usr/sbin/snmptrapd
    # 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 -- $SNMPDOPTS
	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 "."
    ;;
  *)
    echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
    exit 1
esac

exit 0