Bug fix: check for uncomitted changes first

This commit is contained in:
Zachary Seguin 2016-02-02 09:12:05 -05:00
parent d804149aa9
commit 682003c29d
1 changed files with 14 additions and 13 deletions

View File

@ -16,13 +16,24 @@ if [ ! -e ${APACHEDIR} ]; then
exit 1
fi
# Setup
cd ${WORKDIR}
# Update repository
echo 'Updating repository'
git pull
# Ensure there are no uncommitted changes
cd ${APACHEDIR}
echo 'Checking for uncommited changes'
git diff --name-only --exit-code > /dev/null
if [ $? -ne 0 ]; then
echo "There are uncommited changes in ${APACHEDIR}." >&2
echo "Sincerely yours," >&2
echo "$(hostname)" >&2
exit 1
fi
# Generate updated configuration
cd ${WORKDIR}
echo 'Generating new configuration'
./generate-expire-config > ${CONFIGFILE}
@ -33,16 +44,6 @@ echo 'Checking for changes'
git diff --name-only --exit-code ${CONFIGFILE} > /dev/null
if [ $? -ne 0 ]; then
echo 'Checking for uncommited changes'
git diff --name-only --exit-code > /dev/null
if [ $? -ne 0 ]; then
echo "There are uncommited changes in ${APACHEDIR}." >&2
echo "Sincerely yours," >&2
echo "$(hostname)" >&2
exit 1
fi
echo 'Changes detected: Commiting updated configuration'
git add ${CONFIGFILE}
git commit -m '[CRON] Updated list of expired sites'