From 05b4bf92a2118fba8dd8eda30060def48985b40c Mon Sep 17 00:00:00 2001 From: Nils Date: Tue, 14 Jul 2015 10:07:01 +0200 Subject: added usage of nice when ionice is not available On some platforms (e.g. NetBSD, OS X), ionice is not available. This patch enables a fallback to nice. If neither ionice or nice are installed, an error message is displayed.--- phpmalwarefinder | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/phpmalwarefinder b/phpmalwarefinder index 0a85d85..15354d4 100755 --- a/phpmalwarefinder +++ b/phpmalwarefinder @@ -2,15 +2,29 @@ YARA=$(which yara) CONFIG_PATH='/etc/phpmalwarefinder/malwares.yara' +IONICE_BIN=$(which ionice) +NICE_BIN=$(which nice) if [ ! -f "$YARA" ] then - YARA='./yara' + YARA='./yara' fi if [ ! -f "$CONFIG_PATH" ] then - CONFIG_PATH='./malwares.yara' + CONFIG_PATH='./malwares.yara' +fi + +if [ -f "${IONICE_BIN}" ] +then + NICE=${IONICE_BIN} + NICE_OPTS="-c 3" +else + if [ -f "${NICE_BIN}" ] + then + NICE=${NICE_BIN} + NICE_OPTS="-n 20" + fi fi show_help() { @@ -59,12 +73,19 @@ then exit 1 fi +if [ ! -e ${NICE} ] +then + echo "no nice programe available. PLease install ionice or nice." + exit 1 +fi + if [ -z $@ ] then - show_help - exit 1 + show_help + exit 1 fi OPTS="${OPTS} -r ${CONFIG_PATH}" -ionice -c3 $YARA $OPTS $@ +${NICE} ${NICE_OPTS} $YARA $OPTS $@ + -- cgit v1.3