]> git.pld-linux.org Git - packages/net-snmp.git/blobdiff - net-snmpd.init
- up to 5.6.1.1
[packages/net-snmp.git] / net-snmpd.init
index 7bdf32043e2a851faa54893d8f2dd5c4a83505d7..28777c800f0b17c9ee0f797b1a804a815e3aa8f5 100644 (file)
 #!/bin/sh
 #
-# snmpd                Simple Network Management Protocol (SNMP) Daemon
+# snmpd                        Simple Network Management Protocol (SNMP) Daemon
 #
-# chkconfig:   345 50 50
+# chkconfig:           345 50 50
 #
-# description: Simple Network Management Protocol (SNMP) Daemon
-# description(es): Servidor SNMP (Simple Network Management Protocol)
-# description(pt_BR): Servidor SNMP (Simple Network Management Protocol)
-# description(ru): äĹÍĎΠSNMP (Simple Network Management Protocol)
-# description(uk): äĹÍĎΠSNMP (Simple Network Management Protocol)
+# description:         Simple Network Management Protocol (SNMP) Daemon
+# description(es.UTF-8):       Servidor SNMP (Simple Network Management Protocol)
+# description(pt_BR.UTF-8):    Servidor SNMP (Simple Network Management Protocol)
+# description(ru.UTF-8):       Демон SNMP (Simple Network Management Protocol)
+# description(uk.UTF-8):       Демон SNMP (Simple Network Management Protocol)
 #
-# processname: snmpd
-# config:      /etc/snmp/snmpd.local.conf
-# config:      /etc/snmp/snmpd.conf
-
+# processname:         snmpd
+# config:              /etc/snmp/snmpd.local.conf
+# config:              /etc/snmp/snmpd.conf
 
 # Source function library
 . /etc/rc.d/init.d/functions
 
+upstart_controlled
+
 # Get network config
 . /etc/sysconfig/network
 
-CONF_FILE=/etc/snmp/snmpd.conf
-LOG_WARNINGS_MESSAGES_TO_SYSLOG=yes
+CONF_FILE=""
+LOG_WARNINGS_MESSAGES_TO_SYSLOG="yes"
+SNMPD_LISTEN_ADDRS=""
 
 # Get service config
 [ -f /etc/sysconfig/snmpd ] && . /etc/sysconfig/snmpd
 
 # Check that networking is up.
-if is_no "${NETWORKING}"; then
-       msg_network_down "snmpd"
-       exit 1
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "snmpd"
+               exit 1
+       fi
+else
+       exit 0
 fi
 
-# See how we were called.
-case "$1" in
-  start)
+start() {
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/snmpd ]; then
-               msg_starting "snmpd"
-               daemon /usr/bin/setsid /usr/sbin/snmpd \
-                       $([ -n "$CONF_FILE" ] && echo "-C -c $CONF_FILE") \
-                       $( is_yes "$LOG_WARNINGS_MESSAGES_TO_SYSLOG" && \
-                               echo "-s" ) </dev/null
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
-       else
+       if [ -f /var/lock/subsys/snmpd ]; then
                msg_already_running "snmpd"
-               RETVAL=1
+               return
        fi
+
+       msg_starting "snmpd"
+       daemon /usr/bin/setsid /usr/sbin/snmpd \
+               $([ -n "$CONF_FILE" ] && echo "-C -c $CONF_FILE") \
+               $([ -n "$SNMPD_INITLIST" ] && echo "-I \"$SNMPD_INITLIST\"") \
+               $(is_yes "$LOG_WARNINGS_MESSAGES_TO_SYSLOG" && echo "-LSid" ) \
+               -p /var/run/snmpd.pid $SNMPD_LISTEN_ADDRS </dev/null
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/snmpd ]; then
+               msg_not_running "snmpd"
+               return
+       fi
+
+       msg_stopping "snmpd"
+       killproc snmpd
+       rm -f /var/lock/subsys/snmpd >/dev/null 2>&1
+}
+
+condrestart() {
+       if [ ! -f /var/lock/subsys/snmpd ]; then
+               msg_not_running "snmpd"
+               RETVAL=$1
+               return
+       fi
+
+       stop
+       start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
   stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  reload|force-reload)
        if [ -f /var/lock/subsys/snmpd ]; then
-               msg_stopping "snmpd"
-               killproc snmpd
-               rm -f /var/lock/subsys/snmpd >/dev/null 2>&1
+               msg_reloading "snmpd"
+               killproc snmpd -HUP
        else
                msg_not_running "snmpd"
-               RETVAL=1
-       fi      
-       ;;
-  restart|reload)
-       $0 stop
-       $0 start
+       fi
        ;;
   status)
        status snmpd
        exit $?
        ;;
   *)
-       msg_usage "$0 {start|stop|status|restart|reload}"
-       RETVAL=1
+       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
+       exit 3
 esac
 
 exit $RETVAL
This page took 0.049337 seconds and 4 git commands to generate.