cd before git pull
[public/expire-sites.git] / expire-sites
index 855b8bf..b1599e9 100755 (executable)
@@ -16,13 +16,25 @@ if [ ! -e ${APACHEDIR} ]; then
    exit 1
 fi
 
-# Setup
+# Update repository
 cd ${WORKDIR}
-
 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}