From 6510eb17fce404d2db10d47777b1957579d23079 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Tue, 10 Mar 2015 10:24:33 +0100 Subject: [PATCH] ionice may not be available --- lib/config/getGeneral | 83 ++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/lib/config/getGeneral b/lib/config/getGeneral index ec183ab..1e7797d 100644 --- a/lib/config/getGeneral +++ b/lib/config/getGeneral @@ -24,47 +24,50 @@ getConfigGeneral() { unset expr ;; 'ionice') - read class niceness <<<"$value" - case $class in - 1) - # real-time class, only root can do that - if (( UID )) - then - echo "IO class 'realtime' is"\ - "not available to unprivileged"\ - "users" >&2 + if which ionice >/dev/null + then + read class niceness <<<"$value" + case $class in + 1) + # real-time class, only root can do that + if (( UID )) + then + echo "IO class 'realtime' is"\ + "not available to unprivileged"\ + "users" >&2 + exit $EIONICE + fi + if [ -n "$niceness" ] \ + && (( niceness >= 0 && niceness <= 7 )) + then + ionice="ionice -c1 -n$niceness " + else + echo "Invalid IO priority"\ + "'$niceness'" >&2 + exit $EIONICE + fi + ;; + 2) + if [ -n "$niceness" ] \ + && (( niceness >= 0 && niceness <= 7 )) + then + ionice="ionice -c2 -n$niceness " + else + echo "Invalid IO priority"\ + "'$niceness'" >&2 + exit $EIONICE + fi + ;; + 3) + ionice="ionice -c3 " + ;; + *) + echo "Invalid ionice parameters $value"\ + >&2 exit $EIONICE - fi - if [ -n "$niceness" ] \ - && (( niceness >= 0 && niceness <= 7 )) - then - ionice="ionice -c1 -n$niceness " - else - echo "Invalid IO priority"\ - "'$niceness'" >&2 - exit $EIONICE - fi - ;; - 2) - if [ -n "$niceness" ] \ - && (( niceness >= 0 && niceness <= 7 )) - then - ionice="ionice -c2 -n$niceness " - else - echo "Invalid IO priority"\ - "'$niceness'" >&2 - exit $EIONICE - fi - ;; - 3) - ionice="ionice -c3 " - ;; - *) - echo "Invalid ionice parameters $value"\ - >&2 - exit $EIONICE - ;; - esac + ;; + esac + fi ;; 'temporary-directory') tempdir="$value"