4 WORKDIR=/opt/expire-sites
6 CONFIGFILE=${APACHEDIR}/conf-available/disable-expired-site.conf
9 if [ ! -e ${WORKDIR} ]; then
10 echo 'Unable to find work directory: ' ${WORKDIR} >&2
14 if [ ! -e ${APACHEDIR} ]; then
15 echo 'Unable to find Apache configuration directory: ' ${APACHEDIR} >&2
21 echo 'Updating repository'
24 # Ensure there are no uncommitted changes
26 echo 'Checking for uncommited changes'
27 git diff --name-only --exit-code > /dev/null
30 echo "There are uncommited changes in ${APACHEDIR}." >&2
31 echo "Sincerely yours," >&2
32 echo "$(hostname)" >&2
36 # Generate updated configuration
38 echo 'Generating new configuration'
39 ./generate-expire-config > ${CONFIGFILE}
41 # Check if file has changed
44 echo 'Checking for changes'
45 git diff --name-only --exit-code ${CONFIGFILE} > /dev/null
48 echo 'Changes detected: Commiting updated configuration'
50 git commit -m '[CRON] Updated list of expired sites'
52 echo 'Reloading apache'
53 service apache2 reload
55 echo 'No changes detected'