From b8288d3393acb10c0e316d7fa89c2a9205954f69 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Mon, 1 Jun 2020 21:04:09 -0500 Subject: [PATCH 01/24] Clean up --- ADVANCED.md | 3 +++ gravity-sync.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ADVANCED.md b/ADVANCED.md index 3f3c977..6beeff2 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -2,6 +2,9 @@ ## Advanced Configuration The purpose of this guide is to break out the manual install instructions, and any advanced configuration flags, into a seperate document to limit confusion from the primary README. It is expected that users have read and are familiar with the process and concepts outlined in the primary README. +## Prerequisites +- If you're installing Gravity Sync on a system running Fedora or CentOS, make sure that you are not just using the built in root account and have a dedicated user in the Administrator group. You'll also need SELinux disabled to install Pi-hole. + ## Installation If you don't trust `git` to install your software, or just like doing things by hand, that's fine. diff --git a/gravity-sync.sh b/gravity-sync.sh index e783d4f..4711c1f 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -320,7 +320,7 @@ function push_gs { fi fi - MESSAGE="Inverting Tachyon Pulse" + MESSAGE="Inverting Tachyon Pulses" echo_info sleep 1 From 33632c04b6e91232fa33d083271d1f229b4c4fcd Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Mon, 1 Jun 2020 21:05:05 -0500 Subject: [PATCH 02/24] Cleaning --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d7731e8..defa437 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ Now, test Gravity Sync. You can run a comparison between primary and secondary d Assuming Gravity Sync runs successfully, it will indicate if there are changes pending between the two databases. If not, make a subtle change to a whitelist/blacklist on your primary Pi-hole, such as changing a description field or disabling a whitelist item, and then running `./gravity-sync.sh compare` again to validate your installation is working correctly. ### The Pull Function - The Gravity Sync Pull, is the standard method of sync operation, and will not prompt for user input after execution. It will perform some checks to help insure success and then stop before making changes if it detects an issue. It will also perform the same `compare` function outlined above, and if there are no changes pending, it will exit without making an attempt to copy data. ```bash From 47d71fd821b0fa6a3652b1128321244fcbe4e144 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 09:43:58 -0500 Subject: [PATCH 03/24] Ping Test on configure input --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- gravity-sync.sh | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index c8a003e..f604b0d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,7 +7,7 @@ assignees: '' --- -**Describe the bug** +**Describe the Issue** A clear and concise description of what the bug is. **Screenshots** @@ -21,5 +21,5 @@ If applicable, add screenshots to help explain your problem. - Gravity Sync Version: [e.g. 1.7.6] - Pi-hole Versions: [e.g. v5.0] -**Additional context** +**Additional Context** Add any other context about the problem here. If you have any advanced flags set in your `gravity-sync.conf` please list them here. diff --git a/gravity-sync.sh b/gravity-sync.sh index 2f6d932..1d0f60d 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -28,6 +28,7 @@ CRONJOB_LOG='gravity-sync.cron' # replace in gravity-sync.conf to overwrite VERIFY_PASS='0' # replace in gravity-sync.conf to overwrite SKIP_CUSTOM='0' # replace in gravity-sync.conf to overwrite DATE_OUTPUT='0' # replace in gravity-sync.conf to overwrite +PING_AVOID='0' # replace in gravity-sync.conf to overwrite # Pi-hole Folder/File Locations PIHOLE_DIR='/etc/pihole' # default Pi-hole data directory @@ -702,7 +703,7 @@ function detect_ssh { else echo_fail MESSAGE="RSYNC is Required" - echo_info + echo_warn distro_check @@ -856,6 +857,18 @@ function config_generate { MESSAGE="Enter IP or DNS of primary Pi-hole server" echo_need read INPUT_REMOTE_HOST + + if [ "${PING_AVOID}" != "1" ] + MESSAGE="Testing Network Connection (PING)" + echo_stat + ping -c 3 ${INPUT_REMOTE_HOST} + if [ "$?" != "127" ] + then + echo_fail + else + echo_good + fi + fi MESSAGE="Enter SSH user with SUDO rights on primary Pi-hole server" echo_need @@ -1323,10 +1336,9 @@ case $# in if [ -f $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} ] then config_delete - else - MESSAGE="${CONFIG_FILE} Missing" - echo_info + MESSAGE="No Active ${CONFIG_FILE}" + echo_warn config_generate fi From 0bf6831bb52eec536d74a82f1c9472d6683191ba Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 09:47:48 -0500 Subject: [PATCH 04/24] Output if bypassed --- gravity-sync.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gravity-sync.sh b/gravity-sync.sh index 1d0f60d..0b22698 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -859,6 +859,7 @@ function config_generate { read INPUT_REMOTE_HOST if [ "${PING_AVOID}" != "1" ] + then MESSAGE="Testing Network Connection (PING)" echo_stat ping -c 3 ${INPUT_REMOTE_HOST} @@ -868,6 +869,9 @@ function config_generate { else echo_good fi + else + MESSAGE="Bypassing Network Testing (PING)" + echo_info fi MESSAGE="Enter SSH user with SUDO rights on primary Pi-hole server" From a9bb52882e284b16a7107ccc6be2ad02139d7c46 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 09:52:29 -0500 Subject: [PATCH 05/24] Documenting PING_AVOID var --- ADVANCED.md | 13 +++++++++---- CHANGELOG.md | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index 6beeff2..43f2744 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -89,24 +89,24 @@ Gravity Sync is configured by default to use the `.ssh/id_rsa` keyfile that is g At this time Gravity Sync does not support passphrases in RSA keyfiles. If you have a passphrase applied to your standard `.ssh/id_rsa` either remove it, or generate a new file and specify that key for use only by Gravity Sync. -Default setting for Gravity Sync is `.ssh/id_rsa` +Default setting in Gravity Sync is `.ssh/id_rsa` #### `LOG_PATH=''` Gravity Sync will place logs in the same folder as the script (identified as .cron and .log) but if you'd like to place these in a another location, you can do that by identifying the full path to the directory. (ex: `/full/path/to/logs`) -Default setting for Gravity Sync is `$HOME/${LOCAL_FOLDR}` +Default setting in Gravity Sync is `$HOME/${LOCAL_FOLDR}` #### `SYNCING_LOG=''` Gravity Sync will write a timestamp for any completed pull, push or restore job to this file. If you want to change the name of this file, you will also need to adjust the LOG_PATH variable above, otherwise your file will be remove during `update` operations. -Default setting for Gravity Sync is `gravity-sync.log` +Default setting in Gravity Sync is `gravity-sync.log` #### `CRONJOB_LOG=''` Gravity Sync will log the execution history of the previous automation task via Cron to this file. If you want to change the name of this file, you will also need to adjust the LOG_PATH variable above, otherwise your file will be remove during `update` operations. This will have an impact to both the `./gravity-sync.sh automate` function and the `./gravity-sync.sh cron` functions. If you need to change this after running the automate function, either modify your crontab manually or delete the entry and re-run the automate function. -Default setting for Gravity Sync is `gravity-sync.cron` +Default setting in Gravity Sync is `gravity-sync.cron` #### `VERIFY_PASS=''` Gravity Sync will prompt to verify user interactivity during push, restore, or config operations (that overwrite an existing configuration) with the intention that it prevents someone from accidentally automating in the wrong direction or overwriting data intentionally. If you'd like to automate a push function, or just don't like to be asked twice to do something distructive, then you can opt-out. @@ -126,6 +126,11 @@ Default setting in Gravity Sync is 0, change to 1 to print timestamped output. #### `BASH_PATH=''` If you need to adjust the path to bash that is identified for automated execution via Crontab, you can do that here. This will only have an impact if changed before generating the crontab via the `./gravity-sync.sh automate` function. If you need to change this after the fact, either modify your crontab manually or delete the entry and re-run the automate function. +#### `PING_AVOID=''` +The `./gravity-sync.sh config` function will attempt to ping the remote host to validate it has a valid network connection. If there is a firewall between your hosts preventing ping replies, or you otherwise wish to skip this step, it can by bypassed here. + +Default setting in Gravity Sync is 0, change to 1 to skip this network test. + ## Execution If you are just straight up unable to run the `gravity-sync.sh` file, make sure it's marked as an executable by Linux. diff --git a/CHANGELOG.md b/CHANGELOG.md index 88dcd17..4f70d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ **Known Issues** - No new Star Trek references. +#### 1.7.7 +- `config` function will attempt to ping remote host to validate network connection, can by bypassed by adding `PING_AVOID='1'` to your `gravity-sync.conf` file. + #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. - Attempts to install OpenSSH Client if not found, and Dropbear is not alternative. From 8e8e3dd06214ed4cf3f0b0396915a48d0aa95e78 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:02:03 -0500 Subject: [PATCH 06/24] Use standard error_val --- gravity-sync.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 0b22698..e7ce31e 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -862,16 +862,11 @@ function config_generate { then MESSAGE="Testing Network Connection (PING)" echo_stat - ping -c 3 ${INPUT_REMOTE_HOST} - if [ "$?" != "127" ] - then - echo_fail - else - echo_good - fi + ping -c 3 ${INPUT_REMOTE_HOST} 2>/dev/null + error_validate else MESSAGE="Bypassing Network Testing (PING)" - echo_info + echo_warn fi MESSAGE="Enter SSH user with SUDO rights on primary Pi-hole server" From 7af4055d1fc350a7cab8e4818f09414258fe8188 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:05:43 -0500 Subject: [PATCH 07/24] Silence ping output --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index e7ce31e..73c86d0 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -862,7 +862,7 @@ function config_generate { then MESSAGE="Testing Network Connection (PING)" echo_stat - ping -c 3 ${INPUT_REMOTE_HOST} 2>/dev/null + ping -c 3 ${INPUT_REMOTE_HOST} >/dev/null 2>&1 error_validate else MESSAGE="Bypassing Network Testing (PING)" From cbbf18bb60f2625eeb5b93063ba5eb14e0d5ea2d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:18:51 -0500 Subject: [PATCH 08/24] Change tasktype output --- CHANGELOG.md | 1 + gravity-sync.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f70d02..f94df47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ #### 1.7.7 - `config` function will attempt to ping remote host to validate network connection, can by bypassed by adding `PING_AVOID='1'` to your `gravity-sync.conf` file. +- Changes some [INFO] messages to [WARN] where approprate #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. diff --git a/gravity-sync.sh b/gravity-sync.sh index 73c86d0..34ffb16 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -2,7 +2,7 @@ # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='1.7.6' +VERSION='1.7.7' # Execute from the home folder of the user who owns it (ex: 'cd ~/gravity-sync') # For documentation or downloading updates visit https://github.com/vmstan/gravity-sync @@ -1187,10 +1187,11 @@ case $# in case $1 in pull) TASKTYPE='PULL' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info import_gs From 2d07e6dbd99e2026d865ac5531f67f5716a57a2a Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:36:59 -0500 Subject: [PATCH 09/24] Add alias for more functions --- CHANGELOG.md | 1 + gravity-sync.sh | 129 ++++++++++++++++++++++++++++++------------------ 2 files changed, 81 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f94df47..b5e3c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ #### 1.7.7 - `config` function will attempt to ping remote host to validate network connection, can by bypassed by adding `PING_AVOID='1'` to your `gravity-sync.conf` file. - Changes some [INFO] messages to [WARN] where approprate +- Adds aliases for more GS functions #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. diff --git a/gravity-sync.sh b/gravity-sync.sh index 34ffb16..fdfbbf6 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1075,6 +1075,7 @@ function show_version { ## Automate Task function task_automate { TASKTYPE='AUTOMATE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good import_gs @@ -1136,6 +1137,50 @@ function task_automate { exit_withchange } +## Configure Task +function task_configure { + TASKTYPE='CONFIGURE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + #MESSAGE="${TASKTYPE} Requested" + #echo_info + + if [ -f $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} ] + then + config_delete + else + MESSAGE="No Active ${CONFIG_FILE}" + echo_warn + + config_generate + fi +} + +function task_devmode { + TASKTYPE='DEV' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + if [ -f $HOME/${LOCAL_FOLDR}/dev ] + then + MESSAGE="Disabling ${TASKTYPE}" + echo_stat + rm -f $HOME/${LOCAL_FOLDR}/dev + error_validate + else + MESSAGE="Enabling ${TASKTYPE}" + echo_stat + touch $HOME/${LOCAL_FOLDR}/dev + error_validate + fi + + MESSAGE="Run UPDATE to apply changes" + echo_info + + exit_withchange +} + # Echo Stack ## Informative function echo_info { @@ -1170,7 +1215,7 @@ function echo_need { # SCRIPT EXECUTION ########################### SCRIPT_START=$SECONDS - MESSAGE="${PROGRAM} Executing" + MESSAGE="${PROGRAM} ${VERSION} Executing" echo_info MESSAGE="Evaluating Arguments" @@ -1207,10 +1252,11 @@ case $# in push) TASKTYPE='PUSH' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info import_gs @@ -1226,10 +1272,11 @@ case $# in restore) TASKTYPE='RESTORE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info import_gs @@ -1245,10 +1292,11 @@ case $# in version) TASKTYPE='VERSION' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info show_version exit_nochange @@ -1256,53 +1304,45 @@ case $# in update) TASKTYPE='UPDATE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info update_gs ;; dev) - TASKTYPE='DEV' - echo_good - - if [ -f $HOME/${LOCAL_FOLDR}/dev ] - then - MESSAGE="Disabling ${TASKTYPE}" - echo_stat - rm -f $HOME/${LOCAL_FOLDR}/dev - error_validate - else - MESSAGE="Enabling ${TASKTYPE}" - echo_stat - touch $HOME/${LOCAL_FOLDR}/dev - error_validate - fi - - MESSAGE="Run UPDATE to apply changes" - echo_info - - exit_withchange + task_devmode + ;; + + devmode) + task_devmode + ;; + + development) + task_devmode ;; logs) TASKTYPE='LOGS' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info logs_gs ;; compare) TASKTYPE='COMPARE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info import_gs @@ -1318,30 +1358,21 @@ case $# in cron) TASKTYPE='CRON' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - MESSAGE="${TASKTYPE} Requested" - echo_info + #MESSAGE="${TASKTYPE} Requested" + #echo_info show_crontab ;; config) - TASKTYPE='CONFIGURE' - echo_good + task_configure + ;; - MESSAGE="${TASKTYPE} Requested" - echo_info - - if [ -f $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} ] - then - config_delete - else - MESSAGE="No Active ${CONFIG_FILE}" - echo_warn - - config_generate - fi + configure) + task_configure ;; auto) From 5ba9da0f3bdc391456265ab0c039f39e2e3ea15d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:42:19 -0500 Subject: [PATCH 10/24] Move more tasks to the stack --- gravity-sync.sh | 130 +++++++++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 50 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index fdfbbf6..c161037 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1157,6 +1157,7 @@ function task_configure { fi } +## Devmode Task function task_devmode { TASKTYPE='DEV' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" @@ -1181,6 +1182,76 @@ function task_devmode { exit_withchange } +## Update Task +function task_update { + TASKTYPE='UPDATE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + #MESSAGE="${TASKTYPE} Requested" + #echo_info + + update_gs +} + +## Version Task +function task_version { + TASKTYPE='VERSION' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + #MESSAGE="${TASKTYPE} Requested" + #echo_info + + show_version + exit_nochange +} + +## Logs Task +function task_logs { + TASKTYPE='LOGS' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + #MESSAGE="${TASKTYPE} Requested" + #echo_info + + logs_gs +} + +## Compare Task +function task_compare { + TASKTYPE='COMPARE' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + #MESSAGE="${TASKTYPE} Requested" + #echo_info + + import_gs + + # MESSAGE="Validating OS Configuration" + # echo_info + + validate_gs_folders + validate_ph_folders + validate_os_sshpass + + md5_compare +} + +## Cron Task +function task_cron { + TASKTYPE='CRON' + MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" + echo_good + + #MESSAGE="${TASKTYPE} Requested" + #echo_info + + show_crontab +} + # Echo Stack ## Informative function echo_info { @@ -1291,26 +1362,15 @@ case $# in ;; version) - TASKTYPE='VERSION' - MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" - echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info - - show_version - exit_nochange + task_version ;; update) - TASKTYPE='UPDATE' - MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" - echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info - - update_gs + task_update + ;; + + upgrade) + task_update ;; dev) @@ -1326,45 +1386,15 @@ case $# in ;; logs) - TASKTYPE='LOGS' - MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" - echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info - - logs_gs + task_logs ;; compare) - TASKTYPE='COMPARE' - MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" - echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info - - import_gs - - # MESSAGE="Validating OS Configuration" - # echo_info - - validate_gs_folders - validate_ph_folders - validate_os_sshpass - - md5_compare + task_compare ;; cron) - TASKTYPE='CRON' - MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" - echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info - - show_crontab + task_cron ;; config) From be5afa2d7bd1a546f9ec41ba9932fbd41912a72d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:44:16 -0500 Subject: [PATCH 11/24] Move script_start to very first line --- CHANGELOG.md | 1 + gravity-sync.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5e3c79..9c5ddb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - `config` function will attempt to ping remote host to validate network connection, can by bypassed by adding `PING_AVOID='1'` to your `gravity-sync.conf` file. - Changes some [INFO] messages to [WARN] where approprate - Adds aliases for more GS functions +- Shows current version on each script execution #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. diff --git a/gravity-sync.sh b/gravity-sync.sh index c161037..8158606 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1,4 +1,5 @@ #!/bin/bash +SCRIPT_START=$SECONDS # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' @@ -1284,7 +1285,6 @@ function echo_need { } # SCRIPT EXECUTION ########################### -SCRIPT_START=$SECONDS MESSAGE="${PROGRAM} ${VERSION} Executing" echo_info From eb864a614b57781c71de9d848ee7b7a572280b2b Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 10:46:02 -0500 Subject: [PATCH 12/24] Adds invalid task --- gravity-sync.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 8158606..78785c2 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -1253,6 +1253,11 @@ function task_cron { show_crontab } +function task_invalid { + echo_fail + list_gs_arguments +} + # Echo Stack ## Informative function echo_info { @@ -1295,8 +1300,7 @@ function echo_need { case $# in 0) - echo_fail - list_gs_arguments + task_invalid ;; 1) @@ -1414,14 +1418,12 @@ case $# in ;; *) - echo_fail - list_gs_arguments + task_invalid ;; esac ;; *) - echo_fail - list_gs_arguments + task_invalid ;; esac From abc3273f55c85d106f013e51f150d0079652a6fb Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:03:57 -0500 Subject: [PATCH 13/24] 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 } From 98c807fadc7b22c618e87c47426698eefc0ee117 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:04:55 -0500 Subject: [PATCH 14/24] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b305900..88511b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - 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 +- Less chatty about each step of configuration validation if it completes #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. From c0c4009825572d7e96226816df66cc80dc43f7e2 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:07:51 -0500 Subject: [PATCH 15/24] Better way to check validation --- gravity-sync.sh | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index e61d499..66c833c 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -531,24 +531,19 @@ function show_crontab { function validate_gs_folders { MESSAGE="Validating ${PROGRAM} Folders on $HOSTNAME" echo_stat - if [ -d $HOME/${LOCAL_FOLDR} ] + if [ ! -d $HOME/${LOCAL_FOLDR} ] then - - else MESSAGE="Unable to Find $HOME/${LOCAL_FOLDR}" echo_fail exit_nochange fi - if [ -d $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD} ] + if [ ! -d $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD} ] then - - else MESSAGE="Unable to Find $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}" echo_fail exit_nochange fi - echo_good } @@ -556,24 +551,19 @@ function validate_gs_folders { function validate_ph_folders { MESSAGE="Validating Pi-hole Configuration on $HOSTNAME" echo_stat - if [ -f ${PIHOLE_BIN} ] + if [ ! -f ${PIHOLE_BIN} ] then - - else MESSAGE="Unable to Validate Pi-Hole is Installed" echo_fail exit_nochange fi - if [ -d ${PIHOLE_DIR} ] + if [ ! -d ${PIHOLE_DIR} ] then - - else MESSAGE="Unable to Validate Pi-Hole Configuration Directory" echo_fail exit_nochange fi - echo_good } From 1a00f1e57c2c8122c373fb19783885400992f7f9 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:23:21 -0500 Subject: [PATCH 16/24] Less chatty about replication validation --- gravity-sync.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 66c833c..28fb38d 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -580,21 +580,24 @@ function validate_os_sshpass { MESSAGE="Using SSH Key-Pair Authentication" else timeout 5 ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - if [ "$?" != "0" ]; then + if [ "$?" != "0" ] + then SSHPASSWORD="sshpass -p ${REMOTE_PASS}" MESSAGE="Using SSH Password Authentication" + echo_warn else SSHPASSWORD='' MESSAGE="Using SSH Key-Pair Authentication" + echo_info fi fi else SSHPASSWORD='' MESSAGE="Using SSH Key-Pair Authentication" + echo_info fi - echo_info MESSAGE="Validating SSH Connection to ${REMOTE_HOST}" echo_stat @@ -604,7 +607,6 @@ function validate_os_sshpass { error_validate elif hash dbclient 2>/dev/null then - # if [ "$SSH_CMD" = "dbclient" ]; then echo ''; fi; timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 error_validate fi @@ -674,17 +676,17 @@ function distro_check { ## Detect SSH & RSYNC function detect_ssh { - MESSAGE="Validating SSH on $HOSTNAME" + MESSAGE="Validating SSH Client on $HOSTNAME" echo_stat if hash ssh 2>/dev/null then - MESSAGE="Validating SSH on $HOSTNAME (OpenSSH)" + MESSAGE="${MESSAGE} (OpenSSH)" echo_good SSH_CMD='ssh' elif hash dbclient 2>/dev/null then - MESSAGE="Validating SSH on $HOSTNAME (Dropbear)" + MESSAGE="${MESSAGE} (Dropbear)" echo_good SSH_CMD='dbclient' else @@ -699,7 +701,7 @@ function detect_ssh { error_validate fi - MESSAGE="Validating RSYNC on $HOSTNAME" + MESSAGE="Validating RSYNC Installed on $HOSTNAME" echo_stat if hash rsync 2>/dev/null @@ -748,11 +750,11 @@ function md5_compare { if [ "$primaryDBMD5" == "$secondDBMD5" ] then - MESSAGE="${GRAVITY_FI} Identical" - echo_info + # MESSAGE="Identical ${GRAVITY_FI} Detected" + # echo_info HASHMARK=$((HASHMARK+0)) else - MESSAGE="${GRAVITY_FI} Differenced" + MESSAGE="Differenced ${GRAVITY_FI} Detected" echo_warn HASHMARK=$((HASHMARK+1)) fi @@ -777,11 +779,11 @@ function md5_compare { if [ "$primaryCLMD5" == "$secondCLMD5" ] then - MESSAGE="${CUSTOM_DNS} Identical" - echo_info + # MESSAGE="${CUSTOM_DNS} Identical" + # echo_info HASHMARK=$((HASHMARK+0)) else - MESSAGE="${CUSTOM_DNS} Differenced" + MESSAGE="Differenced ${CUSTOM_DNS} Detected" echo_warn HASHMARK=$((HASHMARK+1)) fi @@ -807,7 +809,7 @@ function md5_compare { echo_warn HASHMARK=$((HASHMARK+0)) else - MESSAGE="No Changes to Replicate" + MESSAGE="No Replication Required" echo_info exit_nochange fi From 4f7987a3720684a1dccdf035b3c9bae75e85c0e0 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:27:46 -0500 Subject: [PATCH 17/24] Cleanup analyzing output --- CHANGELOG.md | 1 + gravity-sync.sh | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88511b5..d306006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Adds time output to Aborting message (exit without change) - Checks for existance of Pi-hole binaries during validation - Less chatty about each step of configuration validation if it completes +- Less chatty about replication validation if it's not necessary #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. diff --git a/gravity-sync.sh b/gravity-sync.sh index 28fb38d..f08cebd 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -599,7 +599,7 @@ function validate_os_sshpass { fi - MESSAGE="Validating SSH Connection to ${REMOTE_HOST}" + MESSAGE="Validating Connection to ${REMOTE_HOST}" echo_stat if hash ssh 2>/dev/null then @@ -612,7 +612,6 @@ function validate_os_sshpass { fi } - ## Detect SSH-KEYGEN function detect_sshkeygen { MESSAGE="Validating SSH-KEYGEN install on $HOSTNAME" @@ -738,12 +737,12 @@ function error_validate { function md5_compare { HASHMARK='0' - MESSAGE="Analyzing ${REMOTE_HOST} ${GRAVITY_FI}" + MESSAGE="Analyzing ${GRAVITY_FI} on ${REMOTE_HOST}" echo_stat primaryDBMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${GRAVITY_FI}" | sed 's/\s.*$//') error_validate - MESSAGE="Analyzing $HOSTNAME ${GRAVITY_FI}" + MESSAGE="Analyzing ${GRAVITY_FI} on $HOSTNAME" echo_stat secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//') error_validate @@ -766,13 +765,13 @@ function md5_compare { if ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} test -e ${PIHOLE_DIR}/${CUSTOM_DNS} then REMOTE_CUSTOM_DNS="1" - MESSAGE="Analyzing ${REMOTE_HOST} ${CUSTOM_DNS}" + MESSAGE="Analyzing ${CUSTOM_DNS} on ${REMOTE_HOST}" echo_stat primaryCLMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//'") error_validate - MESSAGE="Analyzing $HOSTNAME ${CUSTOM_DNS}" + MESSAGE="Analyzing ${CUSTOM_DNS} on $HOSTNAME" echo_stat secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//') error_validate From 6e86e4dc4d23704813ad61091bdd0e3ba5de1062 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:31:07 -0500 Subject: [PATCH 18/24] Show dev branch on update --- gravity-sync.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index f08cebd..34f473f 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -106,8 +106,10 @@ function update_gs { if [ -f "$HOME/${LOCAL_FOLDR}/dev" ] then BRANCH='development' + B_SHORT='DEV' else BRANCH='master' + B_SHORT='' fi GIT_CHECK=$(git status | awk '{print $1}') @@ -123,7 +125,7 @@ function update_gs { echo_stat git fetch --all >/dev/null 2>&1 error_validate - MESSAGE="Applying Update" + MESSAGE="Applying Update ${B_SHORT}" echo_stat git reset --hard origin/${BRANCH} >/dev/null 2>&1 error_validate From a5497b5cd963ab627ede71b3b26e21505e5266f5 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:32:38 -0500 Subject: [PATCH 19/24] Better way to show dev branch --- gravity-sync.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 34f473f..19077f9 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -106,10 +106,14 @@ function update_gs { if [ -f "$HOME/${LOCAL_FOLDR}/dev" ] then BRANCH='development' - B_SHORT='DEV' else BRANCH='master' - B_SHORT='' + fi + + if [ "$BRANCH" = "development" ] + then + MESSAGE="Pulling from origin/development" + echo_info fi GIT_CHECK=$(git status | awk '{print $1}') @@ -125,7 +129,7 @@ function update_gs { echo_stat git fetch --all >/dev/null 2>&1 error_validate - MESSAGE="Applying Update ${B_SHORT}" + MESSAGE="Applying Update" echo_stat git reset --hard origin/${BRANCH} >/dev/null 2>&1 error_validate From 37705f066f28b765b878cecce95b53e14fae0e66 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:33:00 -0500 Subject: [PATCH 20/24] Even better way to show dev --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 19077f9..5850af2 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -112,7 +112,7 @@ function update_gs { if [ "$BRANCH" = "development" ] then - MESSAGE="Pulling from origin/development" + MESSAGE="Pulling from origin/${BRANCH}" echo_info fi From 7665834caf5d69f9d278a9f4825a6db7b9e047ef Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:35:30 -0500 Subject: [PATCH 21/24] Latest changes --- CHANGELOG.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d306006..8ec68f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,13 +13,14 @@ #### 1.7.7 - `config` function will attempt to ping remote host to validate network connection, can by bypassed by adding `PING_AVOID='1'` to your `gravity-sync.conf` file. -- 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 -- Less chatty about each step of configuration validation if it completes -- Less chatty about replication validation if it's not necessary +- Changes some [INFO] messages to [WARN] where approprate. +- Adds aliases for more Gravity Sync 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. +- Less chatty about each step of configuration validation if it completes. +- Less chatty about replication validation if it's not necessary. +- When applying `update` in DEV mode, the Git branch used will be shown. #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. From e45fde8e8ac388550506bcbaeed45836226caf69 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:52:07 -0500 Subject: [PATCH 22/24] Less chatty about file validation --- CHANGELOG.md | 1 + gravity-sync.sh | 70 +++++++++++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ec68f9..40bb657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Checks for existance of Pi-hole binaries during validation. - Less chatty about each step of configuration validation if it completes. - Less chatty about replication validation if it's not necessary. +- Less chatty about file validation if no changes are required. - When applying `update` in DEV mode, the Git branch used will be shown. #### 1.7.6 diff --git a/gravity-sync.sh b/gravity-sync.sh index 5850af2..d5cdfa8 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -158,44 +158,47 @@ function pull_gs { sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 error_validate - MESSAGE="Validating Ownership on ${GRAVITY_FI}" + MESSAGE="Validating Settings of ${GRAVITY_FI}" echo_stat GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk '{print $3 $4}') - if [ $GRAVDB_OWN == "piholepihole" ] + if [ $GRAVDB_OWN != "piholepihole" ] then - echo_good - else + MESSAGE="Validating Ownership on ${GRAVITY_FI}" echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${GRAVITY_FI}" echo_stat sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 error_validate + + MESSAGE="Continuing Validation of ${GRAVITY_FI}" + echo_stat fi - MESSAGE="Validating Permissions on ${GRAVITY_FI}" - echo_stat - GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}') - if [ $GRAVDB_RWE = "-rw-rw-r--" ] + if [ $GRAVDB_RWE != "-rw-rw-r--" ] then - echo_good - else + MESSAGE="Validating Permissions on ${GRAVITY_FI}" echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn - MESSAGE="Setting Ownership on ${GRAVITY_FI}" + MESSAGE="Setting Permissions on ${GRAVITY_FI}" echo_stat sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 error_validate + + MESSAGE="Continuing Validation of ${GRAVITY_FI}" + echo_stat fi + echo_good + if [ "$SKIP_CUSTOM" != '1' ] then if [ "$REMOTE_CUSTOM_DNS" == "1" ] @@ -218,43 +221,46 @@ function pull_gs { sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1 error_validate - MESSAGE="Validating Ownership on ${CUSTOM_DNS}" + MESSAGE="Validating Settings on ${CUSTOM_DNS}" echo_stat CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}') - if [ $CUSTOMLS_OWN == "rootroot" ] + if [ $CUSTOMLS_OWN != "rootroot" ] then - echo_good - else + MESSAGE="Validating Ownership on ${CUSTOM_DNS}" echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${CUSTOM_DNS}" echo_stat sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1 error_validate + + MESSAGE="Continuing Validation of ${GRAVITY_FI}" + echo_stat fi - - MESSAGE="Validating Permissions on ${CUSTOM_DNS}" - echo_stat CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}') - if [ $CUSTOMLS_RWE == "-rw-r--r--" ] + if [ $CUSTOMLS_RWE != "-rw-r--r--" ] then - echo_good - else + MESSAGE="Validating Permissions on ${CUSTOM_DNS}" echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${CUSTOM_DNS}" echo_stat sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1 error_validate + + MESSAGE="Continuing Validation of ${GRAVITY_FI}" + echo_stat fi + + echo_good fi fi @@ -369,7 +375,7 @@ function restore_gs { echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${GRAVITY_FI}" echo_stat @@ -388,7 +394,7 @@ function restore_gs { echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${GRAVITY_FI}" echo_stat @@ -416,7 +422,7 @@ function restore_gs { echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${CUSTOM_DNS}" echo_stat @@ -435,7 +441,7 @@ function restore_gs { echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Setting Ownership on ${CUSTOM_DNS}" echo_stat @@ -631,7 +637,7 @@ function detect_sshkeygen { MESSAGE="SSH-KEYGEN is Required" echo_info MESSAGE="Attempting to Compensate" - echo_info + echo_warn if hash dropbearkey >/dev/null 2>&1 then @@ -698,7 +704,7 @@ function detect_ssh { echo_fail MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Installing SSH Client with ${PKG_MANAGER}" echo_stat @@ -720,7 +726,7 @@ function detect_ssh { distro_check MESSAGE="Attempting to Compensate" - echo_info + echo_warn MESSAGE="Installing RSYNC with ${PKG_MANAGER}" echo_stat From cf7bc4a798cb0ab8d8d051cf618eddf0592c60e0 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:55:35 -0500 Subject: [PATCH 23/24] Validate log export --- CHANGELOG.md | 1 + gravity-sync.sh | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40bb657..6190d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Less chatty about replication validation if it's not necessary. - Less chatty about file validation if no changes are required. - When applying `update` in DEV mode, the Git branch used will be shown. +- Validates log export operation #### 1.7.6 - Detects `dbclient` install as alternative to OpenSSH Client. diff --git a/gravity-sync.sh b/gravity-sync.sh index d5cdfa8..dc3a88a 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -473,10 +473,10 @@ function restore_gs { ## Core Logging ### Write Logs Out function logs_export { - MESSAGE="Logging Timestamps to ${SYNCING_LOG}" - echo_info - - echo -e $(date) "[${TASKTYPE}]" >> ${LOG_PATH}/${SYNCING_LOG} + MESSAGE="Logging Successful ${TASKTYPE}" + echo_stat + echo -e $(date) "[${TASKTYPE}]" >> ${LOG_PATH}/${SYNCING_LOG} + error_validate } ### Output Sync Logs From b53a34b96aff57d2a7e557c9fa24fc9d6bc55241 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 11:59:48 -0500 Subject: [PATCH 24/24] 1.7.7 --- ADVANCED.md | 4 ++-- CHANGELOG.md | 1 + VERSION | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index 43f2744..418c296 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -14,8 +14,8 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync ```bash cd ~ -wget https://github.com/vmstan/gravity-sync/archive/v1.7.6.zip -unzip v1.7.6.zip -d gravity-sync +wget https://github.com/vmstan/gravity-sync/archive/v1.7.7.zip +unzip v1.7.7.zip -d gravity-sync cd gravity-sync ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 6190d85..4431af2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Adds aliases for more Gravity Sync functions. - Shows current version on each script execution. - Adds time output to Aborting message (exit without change.) +- Includes parsing of functions in time calculation. - Checks for existance of Pi-hole binaries during validation. - Less chatty about each step of configuration validation if it completes. - Less chatty about replication validation if it's not necessary. diff --git a/VERSION b/VERSION index d263485..73c8b4f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.6 \ No newline at end of file +1.7.7 \ No newline at end of file