Sha256: 206e103209d739ede48ab85031c8be33089f62917eb36d050eee7826b50c6cc4

Contents?: true

Size: 842 Bytes

Versions: 3

Compression:

Stored size: 842 Bytes

Contents

#!/bin/bash

FILE=`mktemp -t okidok.XXXXX`
LOGFILE=/var/log/riccardo/ok.log
touch "$LOGFILE"

# logs and prints output!
oklog() {
	MSG="$1"
	logger -f "$LOGFILE" -p info -t ok "$MSG"
}

oklog "Started with args: '$*'"

if [ "$1" = '-' ] ; then
 echo 'Called ok with -, assuming STDIN!'	>&2
 oklog "called from stdin"
 cat | ricnotify yellow "OK from STDIN '$*'"
 RET=$?
 oklog "End STDIN RET=$RET for: '$*'" 
 exit $RET
fi

echo "`data` Start '$*'"

# The 2 followign must NOT be separated!!!
"$@" 2>&1 | tee "$FILE"
RET=$PIPESTATUS

MSG=_NONE_

if [ 0 = $RET ] ; then 
	verde "OK: $*"
	tail -20 "$FILE" | ricnotify green "OK '$*'"
	echo "`data` End OK"
else
	rosso "NO(ret=$RET): $*" 
	echo "`data` End (ERR) '$*'"
	echo "There were some errors which returned: $RET" | ricnotify red "Err with '$*'"
fi
oklog "End $MSG($RET): '$*'"
exit $RET

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sakuric-2.1.3 bin/ok
sakuric-2.0.3 bin/ok
sakuric-2.0.1 bin/ok