storage-fixup: make a quiet/silent mode work
PATCH 3/5 storage-fixup: make a quiet/silent mode work
Add a quiet mode. Remove the seemingly unused sact variable.
Signed-off-by Kel Modderman <[email protected]>
---
storage-fixup +10 -12
@@ -27,10 +27,6 @@ # Executes ACTION on matched devices. ACTION can contain $DEV # which will be substituted with device file of matching device. # -# sact ACTION -# Silent version of "act". Useful when the action to take is -# printing out a warning message. -# # PATTERN is bash extglob pattern. # # For example, the following (useless) rule disables APM on the first
@@ -47,10 +43,11 @@ # declare usage=" -Usage: storage-fixup [-h] [-V] [-v] [-b] [-c config_file] [-m max_devs] +Usage: storage-fixup [-h] [-V] [-q] [-v] [-b] [-c config_file] [-m max_devs] -h Print this help message and exit -V Print version and exit + -q Quiet -v Verbose -d Dry run, don't actually execute action -c Use config_file instead of /etc/storage-fixup.conf
@@ -81,7 +78,7 @@ warn() { } debug() { - if [ $verbose -ne 0 ]; then + if [ $verbose -gt 0 ]; then warn "$@" fi }
@@ -242,8 +239,10 @@ do_act() { for idx in ${matches[@]}; do DEV=${storage_devs[idx]} if [ $dry_run -eq 0 ]; then - if [ $verbose -ne 0 ]; then + if [ $verbose -gt 0 ]; then eval log "$rule_name: executing \"$act\"" + elif [ $verbose -lt 0 ]; then + act=${act//$hdparm/$hdparm -q} fi eval "$act" else
@@ -259,10 +258,12 @@ do_act() { # shopt -s extglob -while getopts "dvVc:m:h" option; do +while getopts "dqvVc:m:h" option; do case $option in d) dry_run=1;; + q) + verbose=-1;; v) verbose=1;; V)
@@ -345,10 +346,7 @@ while read f0 f1 f2; do do_storage scsi "$f1" "$f2" ;; act) - do_act "$f1 $f2" 1 - ;; - sact) - do_act "$f1 $f2" 0 + do_act "$f1 $f2" "$verbose" ;; *) false
---
Quoted 1 line · Kel Modderman
Add a quiet mode. Remove the seemingly unused sact variable.
Modified so that execution header is printed on !quiet. (the "storage-fixup: RULE: executing ..." line and use "eval $act > /dev/null" for quiet mode instead and revive sact (I'm planning on using it for drives to issue warning messages which we can't do much about).
Signature · 1 line
tejun