Skip to content

Commit

Permalink
Chanege dsk-wz.sh script to execute just development commands
Browse files Browse the repository at this point in the history
Store the error message in log file and out it to stderr
  • Loading branch information
AhmedKamal1432 committed Aug 8, 2015
1 parent dc4b8bf commit 97d3107
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions vendor/bash/dsk-wz.sh
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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;

0 comments on commit 97d3107

Please sign in to comment.