Last active
October 1, 2015 11:13
-
-
Save mjung/abcddccacdcbb17f5c63 to your computer and use it in GitHub Desktop.
Simple loop based script to run multiple recipes
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 | |
# | |
# 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