summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils2015-07-14 10:03:31 +0200
committerNils2015-07-14 10:03:31 +0200
commit7af3ba89aa11eee89e6b22a9db43074c4c1bd12b (patch)
tree858e2c445f693da4cdfc21e8963b47f0af06d3b9
parentc634f714bc82b46db84c700354841c0b5810a962 (diff)
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.
-rwxr-xr-xphpmalwarefinder22
1 files changed, 21 insertions, 1 deletions
diff --git a/phpmalwarefinder b/phpmalwarefinder
index 0a85d85..1fbe4cf 100755
--- a/phpmalwarefinder
+++ b/phpmalwarefinder
@@ -2,6 +2,8 @@
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
@@ -13,6 +15,18 @@ then
13 CONFIG_PATH='./malwares.yara' 15 CONFIG_PATH='./malwares.yara'
14fi 16fi
15 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
28fi
29
16show_help() { 30show_help() {
17 cat << EOF 31 cat << EOF
18Usage ${0##*/} [-cfhw] <file|folder> ... 32Usage ${0##*/} [-cfhw] <file|folder> ...
@@ -65,6 +79,12 @@ then
65 exit 1 79 exit 1
66fi 80fi
67 81
82if [ ! -e ${NICE} ]
83then
84 echo "no nice program available. Please install ionice or nice."
85 exit 1
86fi
87
68OPTS="${OPTS} -r ${CONFIG_PATH}" 88OPTS="${OPTS} -r ${CONFIG_PATH}"
69 89
70ionice -c3 $YARA $OPTS $@ 90${NICE} ${NICE_OPTS} $YARA $OPTS $@