From 97d3107f2010c4e4e4ba3f79b79380e24164f7a4 Mon Sep 17 00:00:00 2001 From: Ahmed Kamal Date: Sat, 8 Aug 2015 19:02:42 +0300 Subject: [PATCH] Chanege dsk-wz.sh script to execute just development commands Store the error message in log file and out it to stderr --- vendor/bash/dsk-wz.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/vendor/bash/dsk-wz.sh b/vendor/bash/dsk-wz.sh index 6680e2f..bd0e38a 100755 --- a/vendor/bash/dsk-wz.sh +++ b/vendor/bash/dsk-wz.sh @@ -12,7 +12,12 @@ write_log() LOGTIME=`date "+%Y-%m-%d %H:%M:%S"` LOG="dsw.log" touch $LOG - if [ ! -f $LOG ]; then echo "ERROR!! Cannot create log file $LOG. Exiting."; exit -1; fi + if [ ! -f $LOG ]; then + message="ERROR!! Cannot create log file $LOG. Exiting."; + echo -e $message >&2; + echo $message | write_log; + exit -1; + fi echo $LOGTIME": $text" >> $LOG; fi done @@ -28,7 +33,9 @@ executor(){ if [ $# -lt 2 ] then - echo -e "An insufficient number of arguments(arguments)" | write_log ; + message="An insufficient number of arguments"; + echo -e $message >&2; + echo $message | write_log; exit -1; fi @@ -38,21 +45,17 @@ arguments="$@"; # Pattern matching Ref: http://goo.gl/JnXS5y case $command in -parted) - executor $command $arguments; -;; -mkfs.*) - executor $command $arguments; -;; -lsblk) - executor $command $arguments; -;; -fdisk) +parted | mkfs.* | lsblk | fdisk | df | udevadm | e2label | fatlabel | ntfslabel | blkid |\ + umount | mount | partprobe | echo | trigger | hdparm | multipath | mkdir | systemctl) executor $command $arguments; ;; + *) - executor $command $arguments; - # if a command is not one we know, we exit with an error + # if a command is not one we know, we exit with an error + message="Sorry, command $command is not known"; + echo -e $message >&2; + echo $message | write_log; + exit -1; ;; esac exit 0;