diff options
| author | Nils | 2015-07-14 10:07:01 +0200 |
|---|---|---|
| committer | Nils | 2015-07-14 10:07:01 +0200 |
| commit | 05b4bf92a2118fba8dd8eda30060def48985b40c (patch) | |
| tree | e9adf88c2e73c5512c257203016a20479e048a74 | |
| parent | c634f714bc82b46db84c700354841c0b5810a962 (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-x | phpmalwarefinder | 31 |
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 | ||
| 3 | YARA=$(which yara) | 3 | YARA=$(which yara) |
| 4 | CONFIG_PATH='/etc/phpmalwarefinder/malwares.yara' | 4 | CONFIG_PATH='/etc/phpmalwarefinder/malwares.yara' |
| 5 | IONICE_BIN=$(which ionice) | ||
| 6 | NICE_BIN=$(which nice) | ||
| 5 | 7 | ||
| 6 | if [ ! -f "$YARA" ] | 8 | if [ ! -f "$YARA" ] |
| 7 | then | 9 | then |
| 8 | YARA='./yara' | 10 | YARA='./yara' |
| 9 | fi | 11 | fi |
| 10 | 12 | ||
| 11 | if [ ! -f "$CONFIG_PATH" ] | 13 | if [ ! -f "$CONFIG_PATH" ] |
| 12 | then | 14 | then |
| 13 | CONFIG_PATH='./malwares.yara' | 15 | CONFIG_PATH='./malwares.yara' |
| 16 | fi | ||
| 17 | |||
| 18 | if [ -f "${IONICE_BIN}" ] | ||
| 19 | then | ||
| 20 | NICE=${IONICE_BIN} | ||
| 21 | NICE_OPTS="-c 3" | ||
| 22 | else | ||
| 23 | if [ -f "${NICE_BIN}" ] | ||
| 24 | then | ||
| 25 | NICE=${NICE_BIN} | ||
| 26 | NICE_OPTS="-n 20" | ||
| 27 | fi | ||
| 14 | fi | 28 | fi |
| 15 | 29 | ||
| 16 | show_help() { | 30 | show_help() { |
| @@ -59,12 +73,19 @@ then | |||
| 59 | exit 1 | 73 | exit 1 |
| 60 | fi | 74 | fi |
| 61 | 75 | ||
| 76 | if [ ! -e ${NICE} ] | ||
| 77 | then | ||
| 78 | echo "no nice programe available. PLease install ionice or nice." | ||
| 79 | exit 1 | ||
| 80 | fi | ||
| 81 | |||
| 62 | if [ -z $@ ] | 82 | if [ -z $@ ] |
| 63 | then | 83 | then |
| 64 | show_help | 84 | show_help |
| 65 | exit 1 | 85 | exit 1 |
| 66 | fi | 86 | fi |
| 67 | 87 | ||
| 68 | OPTS="${OPTS} -r ${CONFIG_PATH}" | 88 | OPTS="${OPTS} -r ${CONFIG_PATH}" |
| 69 | 89 | ||
| 70 | ionice -c3 $YARA $OPTS $@ | 90 | ${NICE} ${NICE_OPTS} $YARA $OPTS $@ |
| 91 | |||
