Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -Cu
- based=$(dirname $0)/..
- pname=$(basename $0)
- stime=$(date +%Y%m%d%H%M%S%Z)
- # exec 3>&2
- logd=$based/log
- exec 3>&2 2>$logd/$pname.$stime.$$.log
- set -vx
- MSG() {
- echo "$pname $stime $(date +%Y%m%d%H%M%S%Z) $@" >&3
- }
- tmpd=$(mktemp -d --suffix=".$pname.$stime.$$")/
- if [ 0 -ne "$?" ] ; then
- MSG FATAL can not make temporally directory.
- exit 1
- fi
- trap 'BEFORE_EXIT' EXIT
- BEFORE_EXIT() {
- rm -rf $tmpd
- }
- IS_ERROR() {
- echo ${PIPESTATUS[@]} |
- tr ' \t' '\n' |
- grep -qv '^0$'
- }
- ################################################################
- MSG INFO This is a message.
- true
- IS_ERROR && MSG FATAL unreachable && exit 1
- ################################################################
- exit 0
Add Comment
Please, Sign In to add comment