Bug fix: check for uncomitted changes first
This commit is contained in:
parent
d804149aa9
commit
682003c29d
27
expire-sites
27
expire-sites
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue