From 38bd053244b5cdd1c2a8051277640e8bd7d30af8 Mon Sep 17 00:00:00 2001 From: Jesus Alvarez Date: Tue, 13 Aug 2013 00:18:34 -0700 Subject: [PATCH] verifier.sh: Add email notification The script uses mutt to send and email. On my workstation it is configured to use gmail. --- verifier.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/verifier.sh b/verifier.sh index d4fa88e..a450217 100755 --- a/verifier.sh +++ b/verifier.sh @@ -9,6 +9,8 @@ REPO_BASEPATH="/data/pacman/repo" REMOTE_LOGIN="jalvarez@jalvarez.webfactional.com" +EMAIL="jeezusjr@gmail.com" + source "lib.sh" compute_local_repo_hash() { @@ -39,17 +41,23 @@ compute_remote_repo_hash() { compare_repo() { # $1: The repo name to compare - compute_local_repo_hash $1 - echo $LOCAL_REPO_HASH - compute_remote_repo_hash $1 - echo $REMOTE_REPO_HASH + if [[ $(compute_local_repo_hash $1) != $(compute_remote_repo_hash $1) ]]; then + return 1 + fi } # # Check demz-repo-archiso # -compare_repo "demz-repo-archiso" "x86_64" +if [[ $(compare_repo "demz-repo-archiso") != 0 ]]; then + msg "The database is out of sync, sending notification..." + send_email "demz-repo-archiso is out of sync!" "demz-repo-archiso is not in sync!" +fi # # Check demz-repo-core # +if [[ $(compare_repo "demz-repo-core") != 0 ]]; then + msg "The database is out of sync, sending notification..." + send_email "demz-repo-core is out of sync!" "demz-repo-core is not in sync!" +fi