Blame view

buildroot/buildroot-2016.08.1/package/netsnmp/S59snmpd 2.73 KB
6b13f685e   김민수   BSP 최초 추가
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  #! /bin/sh
  ### BEGIN INIT INFO
  # Provides:           snmpd snmptrapd
  # Required-Start:     $network $local_fs
  # Required-Stop:      $network $local_fs
  # Default-Start:      2 3 4 5
  # Default-Stop:       0 6
  # Short-Description:  SNMP agents
  # Description:        NET SNMP (Simple Network Management Protocol) Agents
  ### END INIT INFO
  #
  # Author:    Jochen Friedrich <jochen@scram.de>
  #
  
  export PATH=/sbin:/usr/sbin:/bin:/usr/bin
  
  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 127.0.0.1'
  TRAPDRUN=no
  TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
  
  # Reads config file (will override defaults above)
  [ -r /etc/default/snmpd ] && . /etc/default/snmpd
  
  ssd_oknodo="-o"
  
  # Cd to / before starting any daemons.
  cd /
  
  # Create compatibility link to old AgentX socket location
  if [ "$SNMPDCOMPAT" = "yes" ]; then
    ln -sf /var/agentx/master /var/run/agentx
  fi
  
  start() {
      if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
          printf "Starting SNMP daemon: "
          start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
          [ $? = 0 ] && echo "OK" || echo "FAIL"
      fi
  
      if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
          printf "Starting SNMP trap daemon: "
          start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
          [ $? = 0 ] && echo "OK" || echo "FAIL"
      fi
  }
  
  stop() {
      if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
          printf "Stopping SNMP daemon: "
          start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
          [ $? = 0 ] && echo "OK" || echo "FAIL"
      fi
  
      if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
          printf "Stopping SNMP trap daemon: "
          start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
          [ $? = 0 ] && echo "OK" || echo "FAIL"
      fi
  }
  
  reload() {
      if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
          printf "Reloading SNMP daemon: "
          start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
          [ $? = 0 ] && echo "OK" || echo "FAIL"
      fi
  
      if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
          printf "Reloading SNMP trap daemon: "
          start-stop-daemon -q -K -s 1 -p /var/run/snmptrapd.pid -x /usr/sbin/snmptrapd
          [ $? = 0 ] && echo "OK" || echo "FAIL"
      fi
  }
  
  case "$1" in
      start)
          start
          ;;
  
      stop)
          stop
          ;;
  
      restart)
          stop
          # Allow the daemons time to exit completely.
          sleep 2
          start
          ;;
  
      reload|force-reload)
          reload
          ;;
  
      *)
          echo "Usage: $0 {start|stop|restart|reload|force-reload}"
          exit 1
  esac
  
  exit 0