Quantcast

Added a script to automatically pull new data and commit it

Kevin Lyles [01-07-12 - 17:17]
Added a script to automatically pull new data and commit it
Filename
auto-pull.sh
diff --git a/auto-pull.sh b/auto-pull.sh
new file mode 100755
index 0000000..980bcd6
--- /dev/null
+++ b/auto-pull.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+FILENAME="/home/me/.wine.wow/drive_c/Program Files/World of Warcraft/WTF/Account/IQGRYN/SavedVariables/ItemScanner.lua"
+
+while inotifywait -e close_write "$FILENAME"
+do
+	if lua get-live-data.lua "$FILENAME"
+	then
+		if [ `git diff HEAD | head | wc -l` -gt 0 ]
+		then
+			if ! git commit -a -m "Auto-committing scan results: `date`"
+			then
+				if ! (git add . && git commit -m "NEW FILES! Auto-committing scan results: `date`")
+				then
+					echo "Commit failed, aborting"
+					for i in `seq 5`
+					do
+						echo -n ''
+						sleep 1
+					done
+					exit 1
+				fi
+			fi
+		fi
+	else
+		echo "Getting data failed, aborting"
+		for i in `seq 5`
+		do
+			echo -n ''
+			sleep 1
+		done
+		exit 1
+	fi
+done