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