]> git.pld-linux.org Git - packages/net-snmp.git/blame - net-snmpd.init
Bug 1314610 - snmpd complaining twice "Cannot statfs net:[********]#***: No such...
[packages/net-snmp.git] / net-snmpd.init
CommitLineData
43f17c64
AF
1#!/bin/sh
2#
bde59677 3# snmpd Simple Network Management Protocol (SNMP) Daemon
43f17c64 4#
bde59677 5# chkconfig: 345 50 50
43f17c64 6#
bde59677 7# description: Simple Network Management Protocol (SNMP) Daemon
383a15b5
ER
8# description(es.UTF-8): Servidor SNMP (Simple Network Management Protocol)
9# description(pt_BR.UTF-8): Servidor SNMP (Simple Network Management Protocol)
10# description(ru.UTF-8): Демон SNMP (Simple Network Management Protocol)
11# description(uk.UTF-8): Демон SNMP (Simple Network Management Protocol)
43f17c64 12#
bde59677 13# processname: snmpd
14# config: /etc/snmp/snmpd.local.conf
15# config: /etc/snmp/snmpd.conf
43f17c64 16
43f17c64
AF
17# Source function library
18. /etc/rc.d/init.d/functions
19
4ea247ad
ER
20upstart_controlled
21
43f17c64
AF
22# Get network config
23. /etc/sysconfig/network
24
eccc84ec
ER
25CONF_FILE=""
26LOG_WARNINGS_MESSAGES_TO_SYSLOG="yes"
dc29eb97 27SNMPD_LISTEN_ADDRS=""
43f17c64
AF
28
29# Get service config
30[ -f /etc/sysconfig/snmpd ] && . /etc/sysconfig/snmpd
31
32# Check that networking is up.
bde59677 33if is_yes "${NETWORKING}"; then
8d056991 34 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
bde59677 35 msg_network_down "snmpd"
36 exit 1
37 fi
38else
39 exit 0
43f17c64
AF
40fi
41
10206900 42start() {
43f17c64 43 # Check if the service is already running?
383a15b5 44 if [ -f /var/lock/subsys/snmpd ]; then
43f17c64 45 msg_already_running "snmpd"
383a15b5 46 return
43f17c64 47 fi
383a15b5
ER
48
49 msg_starting "snmpd"
50 daemon /usr/bin/setsid /usr/sbin/snmpd \
51 $([ -n "$CONF_FILE" ] && echo "-C -c $CONF_FILE") \
f26abd0c 52 $([ -n "$SNMPD_INITLIST" ] && echo "-I \"$SNMPD_INITLIST\"") \
7692f595 53 $(is_yes "$LOG_WARNINGS_MESSAGES_TO_SYSLOG" && echo "-LS0-4d" ) \
383a15b5
ER
54 -p /var/run/snmpd.pid $SNMPD_LISTEN_ADDRS </dev/null
55 RETVAL=$?
56 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
10206900
ER
57}
58
59stop() {
383a15b5 60 if [ ! -f /var/lock/subsys/snmpd ]; then
43f17c64 61 msg_not_running "snmpd"
383a15b5 62 return
442e422e 63 fi
383a15b5
ER
64
65 msg_stopping "snmpd"
66 killproc snmpd
67 rm -f /var/lock/subsys/snmpd >/dev/null 2>&1
10206900
ER
68}
69
f4a613ee 70condrestart() {
383a15b5 71 if [ ! -f /var/lock/subsys/snmpd ]; then
f4a613ee
JB
72 msg_not_running "snmpd"
73 RETVAL=$1
383a15b5 74 return
f4a613ee 75 fi
383a15b5
ER
76
77 stop
78 start
f4a613ee
JB
79}
80
10206900
ER
81RETVAL=0
82# See how we were called.
83case "$1" in
84 start)
85 start
86 ;;
87 stop)
88 stop
43f17c64 89 ;;
f4a613ee
JB
90 restart)
91 stop
92 start
93 ;;
94 try-restart)
95 condrestart 0
96 ;;
97 reload|force-reload)
e11a5f10
ER
98 if [ -f /var/lock/subsys/snmpd ]; then
99 msg_reloading "snmpd"
277d9d4e 100 killproc snmpd -HUP
e11a5f10
ER
101 else
102 msg_not_running "snmpd"
442e422e 103 fi
e11a5f10 104 ;;
43f17c64
AF
105 status)
106 status snmpd
107 exit $?
108 ;;
109 *)
f4a613ee 110 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
04a4ae24 111 exit 3
43f17c64
AF
112esac
113
114exit $RETVAL
This page took 0.700899 seconds and 4 git commands to generate.