[Pkg-net-snmp-commits] [pkg-net-snmp] 12/12: split snmpd.init to snmptrapd.init
Hideki Yamane
henrich at moszumanska.debian.org
Sun Mar 30 10:01:31 UTC 2014
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch master
in repository pkg-net-snmp.
commit 2e1eed1b0e9b58b2fe99a2867a3036b6327e112b
Author: Hideki Yamane <henrich at debian.org>
Date: Sun Mar 30 18:56:52 2014 +0900
split snmpd.init to snmptrapd.init
---
debian/snmpd.init | 28 +++-------------------
debian/snmptrapd.init | 65 ++++++++++++++++-----------------------------------
2 files changed, 23 insertions(+), 70 deletions(-)
diff --git a/debian/snmpd.init b/debian/snmpd.init
index 91de917..3275f57 100644
--- a/debian/snmpd.init
+++ b/debian/snmpd.init
@@ -1,6 +1,6 @@
-#! /bin/sh -e
+#! /bin/sh
### BEGIN INIT INFO
-# Provides: snmpd snmptrapd
+# Provides: snmpd
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
@@ -13,12 +13,10 @@
#
set -e
-. /lib/lsb/init-functions
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
test -x /usr/sbin/snmpd || exit 0
-test -x /usr/sbin/snmptrapd || exit 0
# Defaults
OLD_MIBS_DIR="/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp"
@@ -26,11 +24,8 @@ MIBS_DIR="/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ie
export MIBDIRS="$MIBS_DIR:$OLD_MIBS_DIR"
SNMP_PID="/run/snmpd.pid"
-TRAPD_PID="/run/snmptrapd.pid"
SNMPDRUN="yes"
SNMPDOPTS="-Lsd -Lf /dev/null -p $SNMP_PID"
-TRAPDRUN=no
-TRAPDOPTS="-Lsd -p $TRAPD_PID"
# Reads config file (will override defaults above)
[ -r /etc/default/snmpd ] && . /etc/default/snmpd
@@ -53,39 +48,25 @@ case "$1" in
-- $SNMPDOPTS
log_progress_msg " snmpd"
fi
- if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
- start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmptrapd \
- -- $TRAPDOPTS
- log_progress_msg " snmptrapd"
- fi
;;
stop)
log_daemon_msg "Stopping SNMP services:"
start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmpd && [ ! -f $SNMP_PID ] || rm $SNMP_PID
log_progress_msg " snmpd"
- start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmptrapd && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
- log_progress_msg " snmptrapd"
;;
restart)
log_daemon_msg "Restarting SNMP services:"
start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmpd && [ ! -f $SNMP_PID ] || rm $SNMP_PID
- start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmptrapd && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
start-stop-daemon --quiet --start --exec /usr/sbin/snmpd -- $SNMPDOPTS
log_progress_msg " snmpd"
fi
- if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
- # Allow snmpd time to start up.
- sleep 1
- start-stop-daemon --quiet --start --exec /usr/sbin/snmptrapd -- $TRAPDOPTS
- log_progress_msg " snmptrapd"
- fi
;;
reload|force-reload)
log_daemon_msg "Reloading SNMP services:"
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
start-stop-daemon --quiet --stop --signal 1 \
- --pidfile /var/run/snmpd.pid --exec /usr/sbin/snmpd
+ --pidfile "$SNMP_PID" --exec /usr/sbin/snmpd
log_progress_msg " snmpd"
fi
;;
@@ -94,9 +75,6 @@ case "$1" in
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
status_of_proc /usr/sbin/snmpd snmpd || status=$?
fi
- if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
- status_of_proc /usr/sbin/snmptrapd snmptrapd || status=$?
- fi
exit $status
;;
*)
diff --git a/debian/snmptrapd.init b/debian/snmptrapd.init
index 1c5b46a..f426e13 100644
--- a/debian/snmptrapd.init
+++ b/debian/snmptrapd.init
@@ -1,22 +1,22 @@
-#! /bin/sh -e
+#! /bin/sh
### BEGIN INIT INFO
-# Provides: snmpd snmptrapd
+# Provides: snmptrapd
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
-# Short-Description: SNMP agents
-# Description: NET SNMP (Simple Network Management Protocol) Agents
+# Short-Description: SNMP Trap daemon
+# Description: NET SNMP (Simple Network Management Protocol) trap daemon
### END INIT INFO
#
-# Author: Jochen Friedrich <jochen at scram.de>
+# Author: Hideki Yamane <henrich at debian.org>
+# (based on Jochen Friedrich <jochen at scram.de>'s snmpd.init)
#
set -e
. /lib/lsb/init-functions
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
-
test -x /usr/sbin/snmpd || exit 0
test -x /usr/sbin/snmptrapd || exit 0
@@ -25,34 +25,19 @@ OLD_MIBS_DIR="/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/us
MIBS_DIR="/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf"
export MIBDIRS="$MIBS_DIR:$OLD_MIBS_DIR"
-SNMP_PID="/run/snmpd.pid"
TRAPD_PID="/run/snmptrapd.pid"
-SNMPDRUN="yes"
-SNMPDOPTS="-Lsd -Lf /dev/null -p $SNMP_PID"
TRAPDRUN=no
TRAPDOPTS="-Lsd -p $TRAPD_PID"
# Reads config file (will override defaults above)
-[ -r /etc/default/snmpd ] && . /etc/default/snmpd
+[ -r /etc/default/snmptrapd ] && . /etc/default/snmptrapd
# Cd to / before starting any daemons.
cd /
case "$1" in
start)
- log_daemon_msg "Starting SNMP services:"
- # remove old symlink with previous version
- if [ -L /var/run/agentx ]; then
- rm -f /var/run/agentx
- fi
- if [ ! -d /var/run/agentx ]; then
- mkdir -p /var/run/agentx
- fi
- if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
- start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmpd \
- -- $SNMPDOPTS
- log_progress_msg " snmpd"
- fi
+ log_daemon_msg "Starting SNMP trap services:"
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmptrapd \
-- $TRAPDOPTS
@@ -60,47 +45,37 @@ case "$1" in
fi
;;
stop)
- log_daemon_msg "Stopping SNMP services:"
- start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmpd && [ ! -f $SNMP_PID ] || rm $SNMP_PID
- log_progress_msg " snmpd"
- start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmptrapd && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
+ log_daemon_msg "Stopping SNMP trap services:"
+ start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmptrapd \
+ && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
log_progress_msg " snmptrapd"
;;
restart)
- log_daemon_msg "Restarting SNMP services:"
- start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmpd && [ ! -f $SNMP_PID ] || rm $SNMP_PID
- start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmptrapd && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
- if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
- start-stop-daemon --quiet --start --exec /usr/sbin/snmpd -- $SNMPDOPTS
- log_progress_msg " snmpd"
- fi
+ log_daemon_msg "Restarting SNMP trap services:"
+ start-stop-daemon --quiet --stop --oknodo --exec --retry 3 /usr/sbin/snmptrapd \
+ && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
- # Allow snmpd time to start up.
- sleep 1
- start-stop-daemon --quiet --start --exec /usr/sbin/snmptrapd -- $TRAPDOPTS
+ start-stop-daemon --quiet --start --exec --retry 3 /usr/sbin/snmptrapd -- $TRAPDOPTS
log_progress_msg " snmptrapd"
fi
;;
reload|force-reload)
- log_daemon_msg "Reloading SNMP services:"
- if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
+ log_daemon_msg "Reloading SNMP trap services:"
+ if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
start-stop-daemon --quiet --stop --signal 1 \
- --pidfile /var/run/snmpd.pid --exec /usr/sbin/snmpd
- log_progress_msg " snmpd"
+ --pidfile "$TRAPD_PID" --exec /usr/sbin/snmpd
+ log_progress_msg " snmptrapd"
fi
;;
status)
status=0
- if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
- status_of_proc /usr/sbin/snmpd snmpd || status=$?
- fi
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
status_of_proc /usr/sbin/snmptrapd snmptrapd || status=$?
fi
exit $status
;;
*)
- echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload|status}"
+ echo "Usage: /etc/init.d/snmptrapd {start|stop|restart|reload|force-reload|status}"
exit 1
esac
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-net-snmp/pkg-net-snmp.git
More information about the Pkg-net-snmp-commits
mailing list