0f75b2635e
'echo -n' is not a POSIX construct (no flag support), we shoud use 'printf', especially in init script. This patch was generated by the following command line: git grep -l 'echo -n' -- `git ls-files | grep -v 'patch'` | xargs sed -i 's/echo -n/printf/' Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
94 lines
2.6 KiB
Bash
Executable File
94 lines
2.6 KiB
Bash
Executable File
#! /bin/sh -e
|
|
### 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>
|
|
#
|
|
set -e
|
|
|
|
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
|
|
|
|
case "$1" in
|
|
start)
|
|
printf "Starting network management services:"
|
|
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
|
|
start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
|
|
printf " snmpd"
|
|
fi
|
|
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
|
|
start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
|
|
printf " snmptrapd"
|
|
fi
|
|
echo "."
|
|
;;
|
|
stop)
|
|
printf "Stopping network management services:"
|
|
start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
|
|
printf " snmpd"
|
|
start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
|
|
printf " snmptrapd"
|
|
echo "."
|
|
;;
|
|
restart)
|
|
printf "Restarting network management services:"
|
|
start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
|
|
start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
|
|
# Allow the daemons time to exit completely.
|
|
sleep 2
|
|
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
|
|
start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
|
|
printf " snmpd"
|
|
fi
|
|
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
|
|
# Allow snmpd time to start up.
|
|
sleep 1
|
|
start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
|
|
printf " snmptrapd"
|
|
fi
|
|
echo "."
|
|
;;
|
|
reload|force-reload)
|
|
printf "Reloading network management services:"
|
|
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
|
|
start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
|
|
printf " snmpd"
|
|
fi
|
|
echo "."
|
|
;;
|
|
*)
|
|
echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
|
|
exit 1
|
|
esac
|
|
|
|
exit 0
|