Last active
December 13, 2015 18:38
-
-
Save tafkey/4956411 to your computer and use it in GitHub Desktop.
GLN worflows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# NOTE: Using msmtp to overcome firewall restrictions on usage of port 25. | |
# In order for the msmtp mailer to function properly the ~/.msmtprc file | |
# should have been configured appropriately (for the user who will be | |
# running this script. | |
# Added bonus: all emails are logged (e.g. in ~/msmtp.log) | |
# | |
# FIXME: add some check and error reporting here | |
SET=$1 | |
PWD="/home/workflow/dataflows/010ingestion/scripts/$1" | |
FROM="alert engine @ glnfinder <[email protected]>" | |
TO="[email protected], [email protected]" | |
# NOTE: set this to cat while testing, unless you really enjoy some spam! | |
MAILER="/bin/cat" | |
#MAILER="/usr/bin/msmtp -t" | |
DATE="/bin/date" | |
CAT="/bin/cat" | |
MAIL_MSG="/tmp/${SET}" | |
MAIL_HEAD="/tmp/${SET}_HEAD" | |
SUCCESS_SUBJECT="Subject: [gln-workflow] $($DATE +%Y-%m-%d) Success" | |
FAILURE_SUBJECT="Subject: [gln-workflow] $($DATE +%Y-%m-%d) Failure" | |
echo "From: $FROM" > $MAIL_HEAD | |
echo "To: $TO" >> $MAIL_HEAD | |
echo "$($DATE) - Starting worfklow for ${SET}" > $MAIL_MSG | |
cd ${PWD} | |
for step in step*.sh | |
do | |
echo " $($DATE +%H:%M:%S) - $step" >>$MAIL_MSG | |
${PWD}/${step} || ( echo $FAILURE_SUBJECT >> $MAIL_HEAD && ${CAT} $MAIL_HEAD $MAIL_MSG | ${MAILER} && exit 1 ) | |
done | |
echo " $($DATE +%H:%M:%S) - Worfklow completed!" >>$MAIL_MSG | |
echo $SUCCESS_SUBJECT >> $MAIL_HEAD | |
${CAT} $MAIL_HEAD $MAIL_MSG | ${MAILER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SETX="001set.sh" | |
for set in $(find * -maxdepth 0 -type d); | |
do | |
echo -n "Starting $(basename $set)." | |
SSETX="$set/$SETX" | |
if [ -x $SSETX ]; then | |
echo " Found script [$SSETX]" | |
./$SSETX $set | |
else | |
echo " No script found..." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment