Skip to contentSkip to conversation

net-snmp: check that executable is used before testing for existance

PATCH New Bill Randle 1 participant 1 message Sep 24, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net-snmp: check that executable is used before testing for existance

The recipe for net-snmp has snmpd and snmptrapd in seperate packages, so one or the other or both could be installed. In a common case where only snmpd is installed, the startup script will fail to run because the snmptrapd executable does not exist.

This patch simply qualifies the test by first checking to see if the executable is to be used.

-Bill

---
 meta-networking/recipes-protocols/net-snmp/files/init | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
meta-networking/recipes-protocols/net-snmp/files/init +3 -3
index 2b8fe18..4799546 100755
@@ -3,9 +3,6 @@
 
 . /etc/init.d/functions
 
-test -x /usr/sbin/snmpd || exit 0
-test -x /usr/sbin/snmptrapd || exit 0
-
 # Defaults
 export MIBDIRS=/usr/share/snmp/mibs
 SNMPDRUN=yes
@@ -18,6 +15,9 @@ SPIDFILE=/var/run/snmptrapd.pid
 # Reads config file if exists (will override defaults above)
 [ -r /etc/default/snmpd ] && . /etc/default/snmpd
 
+[ "$SNMPDRUN" = "yes" ] && { test -x /usr/sbin/snmpd || exit 0; }
+[ "$TRAPDRUN" = "yes" ] && { test -x /usr/sbin/snmptrapd || exit 0; }
+
 case "$1" in
   start)
     echo -n "Starting network management services:"
Signature · 1 line
2.7.4