Quantcast
#!/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