summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils2015-07-14 10:07:01 +0200
committerNils2015-07-14 10:07:01 +0200
commit05b4bf92a2118fba8dd8eda30060def48985b40c (patch)
treee9adf88c2e73c5512c257203016a20479e048a74
parentc634f714bc82b46db84c700354841c0b5810a962 (diff)
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.
-rwxr-xr-xphpmalwarefinder31
1 files changed, 26 insertions, 5 deletions
diff --git a/phpmalwarefinder b/phpmalwarefinder
index 0a85d85..15354d4 100755
--- a/phpmalwarefinder
+++ b/phpmalwarefinder
@@ -2,15 +2,29 @@
2 2
3YARA=$(which yara) 3YARA=$(which yara)
4CONFIG_PATH='/etc/phpmalwarefinder/malwares.yara' 4CONFIG_PATH='/etc/phpmalwarefinder/malwares.yara'
5IONICE_BIN=$(which ionice)
6NICE_BIN=$(which nice)
5 7
6if [ ! -f "$YARA" ] 8if [ ! -f "$YARA" ]
7then 9then
8 YARA='./yara' 10 YARA='./yara'
9fi 11fi
10 12
11if [ ! -f "$CONFIG_PATH" ] 13if [ ! -f "$CONFIG_PATH" ]
12then 14then
13 CONFIG_PATH='./malwares.yara' 15 CONFIG_PATH='./malwares.yara'
16fi
17
18if [ -f "${IONICE_BIN}" ]
19then
20 NICE=${IONICE_BIN}
21 NICE_OPTS="-c 3"
22else
23 if [ -f "${NICE_BIN}" ]
24 then
25 NICE=${NICE_BIN}
26 NICE_OPTS="-n 20"
27 fi
14fi 28fi
15 29
16show_help() { 30show_help() {
@@ -59,12 +73,19 @@ then
59 exit 1 73 exit 1
60fi 74fi
61 75
76if [ ! -e ${NICE} ]
77then
78 echo "no nice programe available. PLease install ionice or nice."
79 exit 1
80fi
81
62if [ -z $@ ] 82if [ -z $@ ]
63then 83then
64 show_help 84 show_help
65 exit 1 85 exit 1
66fi 86fi
67 87
68OPTS="${OPTS} -r ${CONFIG_PATH}" 88OPTS="${OPTS} -r ${CONFIG_PATH}"
69 89
70ionice -c3 $YARA $OPTS $@ 90${NICE} ${NICE_OPTS} $YARA $OPTS $@
91