Skip to content

Instantly share code, notes, and snippets.

@mjung
Last active October 1, 2015 11:13
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 mjung/abcddccacdcbb17f5c63 to your computer and use it in GitHub Desktop.
Save mjung/abcddccacdcbb17f5c63 to your computer and use it in GitHub Desktop.
Simple loop based script to run multiple recipes
#!/bin/bash
#
# create files/links matching recipe names to be run in the ${BUILD_RECIPE_DIR}
#
exec > >(logger -i -t autopkg-build) 2>&1
BUILD_RECIPE_DIR="/srv/autopkg/BuildRecipes"
EMAIL_ERRORS_TO='incidents@acme.corp'
my_name=$(basename $0)
set -o pipefail
echo "$(date) BEGIN AUTOPKG BUILD RUN"
for recipe in $(cd ${BUILD_RECIPE_DIR}; ls ); do
OUTPUT_FILE=$(mktemp /tmp/${my_name}.XXXXXXXXX)
echo "$(date) Autopkg running ${recipe} ... "
/usr/local/bin/autopkg run ${recipe} | tee ${OUTPUT_FILE}
if [ $? -ne 0 ]; then
mail -s "Failed to build ${recipe}" ${EMAIL_ERRORS_TO} < ${OUTPUT_FILE}
fi
echo "$(date) ... end run of $recipe"
rm -f ${OUTPUT_FILE}
done
echo "$(date) END AUTOPKG BUILD RUN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment