From 1b4d73ebb5d2ea818e54ab86a842d227e76c14f2 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Sun, 24 May 2020 20:19:40 -0500 Subject: [PATCH] Add md5 comparison function --- gravity-sync.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gravity-sync.sh b/gravity-sync.sh index 5e8df45..6588474 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -296,6 +296,21 @@ function show_version { echo -e "${INFO} ${PROGRAM} ${VERSION}" } +# Look for Changes +function md5_compare { + primaryMD5=$(ssh ${REMOTE_USER}@${REMOTE_HOST} 'md5sum ${PIHOLE_DIR}/${GRAVITY_FI}') + secondMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI}) + + if [ "$primaryMD5" == "$secondMD5" ] + then + echo "MD5 Match" + else + echo "MD5 Changed" + fi + + exit_nochange +} + # SCRIPT EXECUTION ########################### show_version @@ -359,6 +374,11 @@ case $# in logs_gs ;; + compare) + TASKTYPE='COMPARE' + echo -e "${GOOD} ${MESSAGE}" + md5_compare + cron) TASKTYPE='CRON' echo -e "${GOOD} ${MESSAGE}"