From abc3273f55c85d106f013e51f150d0079652a6fb Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:03:57 -0500 Subject: [PATCH] Less chatty during validation --- CHANGELOG.md | 2 ++ gravity-sync.sh | 35 +++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5ddb2..b305900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ - Changes some [INFO] messages to [WARN] where approprate - Adds aliases for more GS functions - Shows current version on each script execution +- Adds time output to Aborting message (exit without change) +- Checks for existance of Pi-hole binaries during validation #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. diff --git a/gravity-sync.sh b/gravity-sync.sh index 78785c2..e61d499 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -529,38 +529,52 @@ function show_crontab { # Validate Functions ## Validate GS Folders function validate_gs_folders { - MESSAGE="Validating $HOSTNAME:$HOME/${LOCAL_FOLDR}" + MESSAGE="Validating ${PROGRAM} Folders on $HOSTNAME" echo_stat if [ -d $HOME/${LOCAL_FOLDR} ] then - echo_good + else + MESSAGE="Unable to Find $HOME/${LOCAL_FOLDR}" echo_fail exit_nochange fi - MESSAGE="Validating $HOSTNAME:$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}" - echo_stat if [ -d $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD} ] then - echo_good + else + MESSAGE="Unable to Find $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}" echo_fail exit_nochange fi + + echo_good } ## Validate Pi-hole Folders function validate_ph_folders { - MESSAGE="Validating $HOSTNAME:${PIHOLE_DIR}" + MESSAGE="Validating Pi-hole Configuration on $HOSTNAME" echo_stat - if [ -d ${PIHOLE_DIR} ] + if [ -f ${PIHOLE_BIN} ] then - echo_good + else + MESSAGE="Unable to Validate Pi-Hole is Installed" echo_fail exit_nochange fi + + if [ -d ${PIHOLE_DIR} ] + then + + else + MESSAGE="Unable to Validate Pi-Hole Configuration Directory" + echo_fail + exit_nochange + fi + + echo_good } ## Validate SSHPASS @@ -1002,7 +1016,8 @@ function config_delete { # Exit Codes ## No Changes Made function exit_nochange { - MESSAGE="${PROGRAM} ${TASKTYPE} Aborting" + SCRIPT_END=$SECONDS + MESSAGE="${PROGRAM} ${TASKTYPE} Aborting ($((SCRIPT_END-SCRIPT_START)) seconds)" echo_info exit 0 } @@ -1010,7 +1025,7 @@ function exit_nochange { ## Changes Made function exit_withchange { SCRIPT_END=$SECONDS - MESSAGE="${PROGRAM} ${TASKTYPE} Completed in $((SCRIPT_END-SCRIPT_START)) seconds" + MESSAGE="${PROGRAM} ${TASKTYPE} Completed ($((SCRIPT_END-SCRIPT_START)) seconds)" echo_info exit 0 }