From 9e7810607e6d64abf23979b063cf6777cf39ba16 Mon Sep 17 00:00:00 2001 From: Steve Jenkins Date: Mon, 8 Jul 2019 21:28:26 -0700 Subject: [PATCH] Added git status test --- pihole-cloudsync.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pihole-cloudsync.sh b/pihole-cloudsync.sh index 82e4b7e..8195233 100755 --- a/pihole-cloudsync.sh +++ b/pihole-cloudsync.sh @@ -41,23 +41,45 @@ do cd $pihole_dir || exit cp $ad_list $black_list $blacklist_list $whitelist_list $regex_list $personal_git_dir cd $personal_git_dir || exit - + CHANGED=$(git --work-tree=$personal_git_dir status --porcelain) if [ -n "${CHANGED}" ]; then echo 'changed'; else - echo 'not changed'; + echo 'Remote repo matches local Pi-hole lists. No further action required.'; + exit 0 fi # Pull / Download elif [ "$arg" == "--pull" ] || [ "$arg" == "--download" ] || [ "$arg" == "-d" ] then echo "Pull (Download) argument detected." + cd $personal_git_dir || exit + CHANGED=$(git --work-tree=$personal_git_dir status --porcelain) + if [ -n "${CHANGED}" ]; then + echo 'changed'; + else + echo 'Local Pi-hole lists match remote repo. No further action required.'; + exit 0 + fi # Help elif [ "$arg" == "--help" ] || [ "$arg" == "-h" ] then - echo "Help argument detected." + cat << EOF +Usage: pihole-cloudsync