summaryrefslogtreecommitdiffstats
path: root/source/n/net-snmp/rc.snmpd
blob: cd52366c6ba7c4527a1bcaddcc2cc18427c52829 (about) (plain) (blame)
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
#!/bin/sh
#
# rc.snmpd	This shell script takes care of starting and stopping
#		the net-snmp SNMP daemon

OPTIONS="-A -p /var/run/snmpd -a"

start() {
	if [ -x /usr/sbin/snmpd -a -f /etc/snmp/snmpd.conf ]; then
		echo -n "Starting snmpd: "
		/usr/sbin/snmpd $OPTIONS -c /etc/snmp/snmpd.conf
		echo " /usr/sbin/snmpd $OPTIONS -c /etc/snmp/snmpd.conf"
	fi
}

stop() {
        # Stop daemons.
	COUNT=0
        echo -n "Shutting down snmpd: "
	while `killall snmpd 2>/dev/null`; do
		echo -n "."
		sleep 1
		COUNT=$((COUNT+1))
		if [ $COUNT -ge 30 ]; then
			killall -9 snmpd
			sleep 1
			break
		fi
	done
	echo " DONE"
}

# See how we were called.
case "$1" in
  start)
	start
        ;;
  stop)
	stop
        ;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/run/snmpd ]; then
	    stop
	    start
	fi
	;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart}"
	;;
esac