Skip to content

Instantly share code, notes, and snippets.

@tafkey
Last active December 13, 2015 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tafkey/4956411 to your computer and use it in GitHub Desktop.
Save tafkey/4956411 to your computer and use it in GitHub Desktop.
GLN worflows
#!/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 <alerts@agroknow.gr>"
TO="tkout@agroknow.gr, manolisn23@gmail.com"
# 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}
#!/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