From 5d1ef9f3cd3aefa94efac29fc384820164436173 Mon Sep 17 00:00:00 2001 From: mboelen Date: Thu, 28 Aug 2014 13:58:41 +0200 Subject: [PATCH] Test if there are files in /etc/modprobe.d before grepping in it --- include/tests_storage | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/tests_storage b/include/tests_storage index 16d0a874..cdad2bcb 100644 --- a/include/tests_storage +++ b/include/tests_storage @@ -31,7 +31,7 @@ FOUND=0 logtext "Test: Checking USB storage driver in directory /etc/modprobe.d and configuration file /etc/modprobe.conf" if [ -d /etc/modprobe.d ]; then - FIND=`ls /etc/modprobe.d/* 2>/dev/null` + FIND=`ls /etc/modprobe.d/* 2> /dev/null` if [ ! "${FIND}" = "" ]; then FIND=`grep -r "install usb-storage /bin/true" /etc/modprobe.d/* | grep "usb-storage" | grep -v "#"` FIND2=`egrep -r "^blacklist (usb_storage|usb-storage)" /etc/modprobe.d/*` @@ -71,15 +71,20 @@ FOUND=0 logtext "Test: Checking firewire storage driver in directory /etc/modprobe.d and configuration file /etc/modprobe.conf" if [ -d /etc/modprobe.d ]; then - FIND1=`egrep "blacklist (ohci1394|firewire-ohci)" /etc/modprobe.d/* | grep "ohci" | grep -v "#"` - FIND2=`egrep "install (ohci1394|firewire-ohci) /bin/true" /etc/modprobe.d/* | grep "ohci" | grep -v "#"` - if [ ! "${FIND1}" = "" -o ! "${FIND2}" = "" ]; then - FOUND=1 - logtext "Result: found firewire ohci driver in disabled state" + FIND=`ls /etc/modprobe.d/* 2> /dev/null` + if [ ! "${FIND}" = "" ]; then + FIND1=`egrep "blacklist (ohci1394|firewire-ohci)" /etc/modprobe.d/* | grep "ohci" | grep -v "#"` + FIND2=`egrep "install (ohci1394|firewire-ohci) /bin/true" /etc/modprobe.d/* | grep "ohci" | grep -v "#"` + if [ ! "${FIND1}" = "" -o ! "${FIND2}" = "" ]; then + FOUND=1 + logtext "Result: found firewire ohci driver in disabled state" + fi + else + logtext "Result: skipping /etc/modprobe.d, directory found but no files in it" fi fi if [ -f /etc/modprobe.conf ]; then - FIND1=`egrep -r "blacklist (ohci1394|firewire-ohci)" /etc/modprobe.conf | grep "ohci" | grep -v "#"` + FIND1=`egrep -r "blacklist (ohci1394|firewire-ohci)" /etc/modprobe.conf | grep "ohci" | grep -v "#"` FIND2=`egrep -r "install (ohci1394|firewire-ohci) /bin/true" /etc/modprobe.conf | grep "ohci" | grep -v "#"` if [ ! "${FIND1}" = "" -o ! "${FIND2}" = "" ]; then FOUND=1