[oe-commits] Jackie Huang : net-snmp: init script fixes
git at git.openembedded.org
git at git.openembedded.org
Thu Mar 12 11:55:13 UTC 2015
Module: meta-openembedded.git
Branch: master-next
Commit: a95929030293324cab989c6ab6675606ead1d7a6
URL: http://git.openembedded.org/?p=meta-openembedded.git&a=commit;h=a95929030293324cab989c6ab6675606ead1d7a6
Author: Jackie Huang <jackie.huang at windriver.com>
Date: Fri Jan 16 14:14:03 2015 +0800
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 at windriver.com>
Signed-off-by: Joe MacDonald <joe_macdonald at mentor.com>
---
.../recipes-protocols/net-snmp/files/init | 51 +++++++++++-----------
.../recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb | 11 +----
2 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/meta-networking/recipes-protocols/net-snmp/files/init b/meta-networking/recipes-protocols/net-snmp/files/init
index 6b02570..2b8fe18 100755
--- a/meta-networking/recipes-protocols/net-snmp/files/init
+++ b/meta-networking/recipes-protocols/net-snmp/files/init
@@ -1,6 +1,8 @@
#! /bin/sh
# /etc/init.d/snmpd: start snmp daemon.
+. /etc/init.d/functions
+
test -x /usr/sbin/snmpd || exit 0
test -x /usr/sbin/snmptrapd || exit 0
@@ -10,21 +12,23 @@ SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
TRAPDRUN=no
TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
+PIDFILE=/var/run/snmpd.pid
+SPIDFILE=/var/run/snmptrapd.pid
-# Cd to / before starting any daemons.
-cd /
+# Reads config file if exists (will override defaults above)
+[ -r /etc/default/snmpd ] && . /etc/default/snmpd
case "$1" in
start)
echo -n "Starting network management services:"
- if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
- start-stop-daemon -S -x /usr/sbin/snmpd \
- -- $SNMPDOPTS
+ if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf -a ! -f "$PIDFILE" ]; then
+ start-stop-daemon -o --start --quiet --name snmpd --pidfile "$PIDFILE" \
+ --exec /usr/sbin/snmpd -- $SNMPDOPTS
echo -n " snmpd"
fi
- if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
- start-stop-daemon -S -x /usr/sbin/snmptrapd \
- -- $TRAPDOPTS
+ if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf -a ! -f "$SPIDFILE" ]; then
+ start-stop-daemon -o --start --quiet --name snmptrapd --pidfile "$SPIDFILE" \
+ --exec /usr/sbin/snmptrapd -- $TRAPDOPTS
echo -n " snmptrapd"
fi
echo "."
@@ -33,32 +37,29 @@ case "$1" in
;;
stop)
echo -n "Stopping network management services:"
- start-stop-daemon -K -x /usr/sbin/snmpd
+ if [ -f "$PIDFILE" ] ; then
+ start-stop-daemon -o --stop --quiet --pidfile $PIDFILE --name snmpd
+ fi
echo -n " snmpd"
- start-stop-daemon -K -x /usr/sbin/snmptrapd
+ if [ -f "$SPIDFILE" ] ; then
+ start-stop-daemon -o --stop --quiet --pidfile $SPIDFILE --name snmptrapd
+ rm -rf $SPIDFILE
+ fi
echo -n " snmptrapd"
echo "."
;;
+ status)
+ status /usr/sbin/snmpd;
+ exit $?
+ ;;
restart|reload|force-reload)
- echo -n "Restarting network management services:"
- start-stop-daemon -K -x /usr/sbin/snmpd
- start-stop-daemon -K -x /usr/sbin/snmptrapd
+ $0 stop
# Allow the daemons time to exit completely.
sleep 2
- if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
- start-stop-daemon -S -x /usr/sbin/snmpd -- $SNMPDOPTS
- echo -n " snmpd"
- fi
- if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
- # Allow snmpd time to start up.
- sleep 1
- start-stop-daemon -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
- echo -n " snmptrapd"
- fi
- echo "."
+ $0 start
;;
*)
- echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
+ echo "Usage: /etc/init.d/snmpd {start|stop|status|restart|reload|force-reload}"
exit 1
esac
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
index 7b9730a..87ee3e6 100644
--- a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
@@ -107,7 +107,7 @@ CONFFILES_${PN}-server-snmptrapd = "${sysconfdir}/snmp/snmptrapd.conf"
INITSCRIPT_PACKAGES = "${PN}-server"
INITSCRIPT_NAME_${PN}-server = "snmpd"
-INITSCRIPT_PARAMS_${PN}-server = "defaults"
+INITSCRIPT_PARAMS_${PN}-server = "start 90 2 3 4 5 . stop 60 0 1 6 ."
EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'systemd', '--with-systemd', '--without-systemd', d)}"
@@ -133,12 +133,3 @@ RREPLACES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
RCONFLICTS_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
LEAD_SONAME = "libnetsnmp.so"
-
-pkg_postrm_${PN}-server() {
- if test "x$D" != "x"; then
- OPT="-r $D "
- else
- OPT=""
- /etc/init.d/snmpd stop
- fi
-}
More information about the Openembedded-commits
mailing list