From 7af3ba89aa11eee89e6b22a9db43074c4c1bd12b Mon Sep 17 00:00:00 2001 From: Nils Date: Tue, 14 Jul 2015 10:03:31 +0200 Subject: added usage of nice when ionice is not available On some platforms (e.g. NetBSD, OS X), ionice is not available by default. This patch checks for ionice availability, and switch back to nice if needed. In the case none of them are installed, an error is displayed.--- phpmalwarefinder | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/phpmalwarefinder b/phpmalwarefinder index 0a85d85..1fbe4cf 100755 --- a/phpmalwarefinder +++ b/phpmalwarefinder @@ -2,6 +2,8 @@ YARA=$(which yara) CONFIG_PATH='/etc/phpmalwarefinder/malwares.yara' +IONICE_BIN=$(which ionice) +NICE_BIN=$(which nice) if [ ! -f "$YARA" ] then @@ -13,6 +15,18 @@ then 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() { cat << EOF Usage ${0##*/} [-cfhw] ... @@ -65,6 +79,12 @@ then exit 1 fi +if [ ! -e ${NICE} ] +then + echo "no nice program available. Please install ionice or nice." + exit 1 +fi + OPTS="${OPTS} -r ${CONFIG_PATH}" -ionice -c3 $YARA $OPTS $@ +${NICE} ${NICE_OPTS} $YARA $OPTS $@ -- cgit v1.3