Skip to content

Instantly share code, notes, and snippets.

@fuzzylogiq
Last active November 2, 2015 16:34
Show Gist options
  • Save fuzzylogiq/a2b922b41aa7d320dfc1 to your computer and use it in GitHub Desktop.
Save fuzzylogiq/a2b922b41aa7d320dfc1 to your computer and use it in GitHub Desktop.
#!/bin/bash
exec > >(logger -i -t autopkg-build) 2>&1
BUILD_RECIPE_DIR="/dir/with/autopkg/recipenames"
EMAIL_ERRORS_TO='blah@acme.com'
my_name=$(basename $0)
# Allows us to get exit code of autopkg and not tee
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"
@fuzzylogiq
Copy link
Author

Relies on having a dir with files with the same name as recipes you want to run (we use symlinks to recipes/overrides in a separate dir so we can add/remove them easily from the build process)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment