summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-protocols/net-snmp/files
diff options
context:
space:
mode:
authorJackie Huang <jackie.huang@windriver.com>2015-01-16 14:14:03 +0800
committerJoe MacDonald <joe_macdonald@mentor.com>2015-03-11 19:27:43 -0400
commita95929030293324cab989c6ab6675606ead1d7a6 (patch)
treecf09624f884f8fb529059d850701cb9fccafd0e6 /meta-networking/recipes-protocols/net-snmp/files
parent3e6e606cdce1959c7efe36f62d1b621f4a54c6e9 (diff)
downloadmeta-openembedded-a95929030293324cab989c6ab6675606ead1d7a6.tar.gz
net-snmp: init script fixes
Changes: 1. Add source function and status command. 2. make it possible to change the start arguments with a default file in the same way as debian. 3. change the default INITSCRIPT_PARAMS 4. Add PIDFILE and fix restart 5. remove the postrm sicne we use the one from update-rc.d Signed-off-by: Jackie Huang <jackie.huang@windriver.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
Diffstat (limited to 'meta-networking/recipes-protocols/net-snmp/files')
-rwxr-xr-xmeta-networking/recipes-protocols/net-snmp/files/init51
1 files changed, 26 insertions, 25 deletions
diff --git a/meta-networking/recipes-protocols/net-snmp/files/init b/meta-networking/recipes-protocols/net-snmp/files/init
index 6b02570c6..2b8fe18b3 100755
--- a/meta-networking/recipes-protocols/net-snmp/files/init
+++ b/meta-networking/recipes-protocols/net-snmp/files/init
@@ -1,6 +1,8 @@
1#! /bin/sh 1#! /bin/sh
2# /etc/init.d/snmpd: start snmp daemon. 2# /etc/init.d/snmpd: start snmp daemon.
3 3
4. /etc/init.d/functions
5
4test -x /usr/sbin/snmpd || exit 0 6test -x /usr/sbin/snmpd || exit 0
5test -x /usr/sbin/snmptrapd || exit 0 7test -x /usr/sbin/snmptrapd || exit 0
6 8
@@ -10,21 +12,23 @@ SNMPDRUN=yes
10SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid' 12SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
11TRAPDRUN=no 13TRAPDRUN=no
12TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' 14TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
15PIDFILE=/var/run/snmpd.pid
16SPIDFILE=/var/run/snmptrapd.pid
13 17
14# Cd to / before starting any daemons. 18# Reads config file if exists (will override defaults above)
15cd / 19[ -r /etc/default/snmpd ] && . /etc/default/snmpd
16 20
17case "$1" in 21case "$1" in
18 start) 22 start)
19 echo -n "Starting network management services:" 23 echo -n "Starting network management services:"
20 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then 24 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf -a ! -f "$PIDFILE" ]; then
21 start-stop-daemon -S -x /usr/sbin/snmpd \ 25 start-stop-daemon -o --start --quiet --name snmpd --pidfile "$PIDFILE" \
22 -- $SNMPDOPTS 26 --exec /usr/sbin/snmpd -- $SNMPDOPTS
23 echo -n " snmpd" 27 echo -n " snmpd"
24 fi 28 fi
25 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then 29 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf -a ! -f "$SPIDFILE" ]; then
26 start-stop-daemon -S -x /usr/sbin/snmptrapd \ 30 start-stop-daemon -o --start --quiet --name snmptrapd --pidfile "$SPIDFILE" \
27 -- $TRAPDOPTS 31 --exec /usr/sbin/snmptrapd -- $TRAPDOPTS
28 echo -n " snmptrapd" 32 echo -n " snmptrapd"
29 fi 33 fi
30 echo "." 34 echo "."
@@ -33,32 +37,29 @@ case "$1" in
33 ;; 37 ;;
34 stop) 38 stop)
35 echo -n "Stopping network management services:" 39 echo -n "Stopping network management services:"
36 start-stop-daemon -K -x /usr/sbin/snmpd 40 if [ -f "$PIDFILE" ] ; then
41 start-stop-daemon -o --stop --quiet --pidfile $PIDFILE --name snmpd
42 fi
37 echo -n " snmpd" 43 echo -n " snmpd"
38 start-stop-daemon -K -x /usr/sbin/snmptrapd 44 if [ -f "$SPIDFILE" ] ; then
45 start-stop-daemon -o --stop --quiet --pidfile $SPIDFILE --name snmptrapd
46 rm -rf $SPIDFILE
47 fi
39 echo -n " snmptrapd" 48 echo -n " snmptrapd"
40 echo "." 49 echo "."
41 ;; 50 ;;
51 status)
52 status /usr/sbin/snmpd;
53 exit $?
54 ;;
42 restart|reload|force-reload) 55 restart|reload|force-reload)
43 echo -n "Restarting network management services:" 56 $0 stop
44 start-stop-daemon -K -x /usr/sbin/snmpd
45 start-stop-daemon -K -x /usr/sbin/snmptrapd
46 # Allow the daemons time to exit completely. 57 # Allow the daemons time to exit completely.
47 sleep 2 58 sleep 2
48 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then 59 $0 start
49 start-stop-daemon -S -x /usr/sbin/snmpd -- $SNMPDOPTS
50 echo -n " snmpd"
51 fi
52 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
53 # Allow snmpd time to start up.
54 sleep 1
55 start-stop-daemon -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
56 echo -n " snmptrapd"
57 fi
58 echo "."
59 ;; 60 ;;
60 *) 61 *)
61 echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}" 62 echo "Usage: /etc/init.d/snmpd {start|stop|status|restart|reload|force-reload}"
62 exit 1 63 exit 1
63esac 64esac
64 65