Last active
March 21, 2016 00:04
-
-
Save pschichtel/e0c230030478be61dc01 to your computer and use it in GitHub Desktop.
A simple hook execution script
This file contains hidden or 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 | |
self="$(readlink -f "$0")" | |
scriptdir="${self}.d" | |
if ! test -d "$scriptdir" | |
then | |
echo "Hook directory ${scriptdir} not found!" | |
exit 1 | |
fi | |
fail_counter=0 | |
if ls "$scriptdir"/* 1>/dev/null 2>&1 | |
then | |
for script in "$scriptdir"/* | |
do | |
"$script" | |
if ! test $? -eq 0 | |
then | |
fail_counter=$((fail_counter+1)) | |
fi | |
done | |
fi | |
echo "Hook execution completed!" | |
if test $fail_counter -gt 0 | |
then | |
echo "${fail_counter} hooks failed to execute" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment