From 2f21bddd947ad0bffe2a6bd2f12543d41c905a09 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 14:51:11 -0500 Subject: [PATCH 01/57] Cleanup SSHPASS prompts --- CHANGELOG.md | 5 ++++- gravity-sync.sh | 43 +++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4431af2..6208fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ **Known Issues** - No new Star Trek references. +#### 1.7.8 +- Removes INFO that SSHPASS is not installed during config, if it's not needed. + #### 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. @@ -23,7 +26,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 +- 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 dc3a88a..85b7599 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -872,7 +872,7 @@ function config_generate { cp $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}.example $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} error_validate - MESSAGE="Enter IP or DNS of primary Pi-hole server" + MESSAGE="IP or DNS of primary Pi-hole" echo_need read INPUT_REMOTE_HOST @@ -887,7 +887,7 @@ function config_generate { echo_warn fi - MESSAGE="Enter SSH user with SUDO rights on primary Pi-hole server" + MESSAGE="SSH User with SUDO rights" echo_need read INPUT_REMOTE_USER @@ -904,28 +904,31 @@ function config_generate { if hash sshpass 2>/dev/null then MESSAGE="SSHPASS Utility Detected" - echo_info - - MESSAGE="Do you want to configure password based SSH authentication?" - echo_warn - MESSAGE="Your password will be stored clear-text in the ${CONFIG_FILE}!" echo_warn + if hash ssh 2>/dev/null + MESSAGE="Before proceeding reference ${BLUE}https://github.com/vmstan/gravity-sync/blob/master/ADVANCED.md#ssh-configuration${NC}" + echo_info - MESSAGE="Leave blank to use (preferred) SSH Key-Pair Authentication" - echo_need - read INPUT_REMOTE_PASS + MESSAGE="Leave blank to use SSH Key-Pair" + echo_warn - MESSAGE="Saving Password to ${CONFIG_FILE}" - echo_stat - sed -i "/REMOTE_PASS=''/c\REMOTE_PASS='${INPUT_REMOTE_PASS}'" $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} - error_validate - + MESSAGE="SSH User Password" + echo_need + read INPUT_REMOTE_PASS + + MESSAGE="Saving Password to ${CONFIG_FILE}" + echo_stat + sed -i "/REMOTE_PASS=''/c\REMOTE_PASS='${INPUT_REMOTE_PASS}'" $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} + error_validate + elif hash dbclient 2>/dev/null + MESSAGE="Dropbear SSH Detected" + echo_warn + MESSAGE="Skipping Password Setup" + echo_info + fi else - MESSAGE="SSHPASS Not Installed" - echo_info - - MESSAGE="Defaulting to SSH Key-Pair Authentication" - echo_info + # MESSAGE="Defaulting to SSH Key-Pair Authentication" + # echo_info fi if [ -z $INPUT_REMOTE_PASS ] From 98daf0a893f5d2f3cf3f076fd579cf89f8ab77a6 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 14:54:09 -0500 Subject: [PATCH 02/57] Better process handling --- CHANGELOG.md | 3 ++- gravity-sync.sh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6208fa7..59205ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ - No new Star Trek references. #### 1.7.8 -- Removes INFO that SSHPASS is not installed during config, if it's not needed. +- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. +- Better error handling of configuration options. #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index 85b7599..4506f1d 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -845,7 +845,7 @@ function intent_validate { INTENT="ENGAGE TRACTOR BEAM" fi - MESSAGE="Enter ${INTENT} at this prompt to confirm" + MESSAGE="Type ${INTENT} to Confirm" echo_need read INPUT_INTENT @@ -872,7 +872,7 @@ function config_generate { cp $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}.example $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} error_validate - MESSAGE="IP or DNS of primary Pi-hole" + MESSAGE="IP or DNS of Primary Pi-hole" echo_need read INPUT_REMOTE_HOST @@ -909,7 +909,7 @@ function config_generate { MESSAGE="Before proceeding reference ${BLUE}https://github.com/vmstan/gravity-sync/blob/master/ADVANCED.md#ssh-configuration${NC}" echo_info - MESSAGE="Leave blank to use SSH Key-Pair" + MESSAGE="Leave password blank to use key-pair! (reccomended)" echo_warn MESSAGE="SSH User Password" From 920099044f4e5fa42f2903394cb226858873a5f0 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 14:55:05 -0500 Subject: [PATCH 03/57] And then --- gravity-sync.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gravity-sync.sh b/gravity-sync.sh index 4506f1d..9fb6959 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -906,6 +906,7 @@ function config_generate { MESSAGE="SSHPASS Utility Detected" echo_warn if hash ssh 2>/dev/null + then MESSAGE="Before proceeding reference ${BLUE}https://github.com/vmstan/gravity-sync/blob/master/ADVANCED.md#ssh-configuration${NC}" echo_info @@ -921,6 +922,7 @@ function config_generate { sed -i "/REMOTE_PASS=''/c\REMOTE_PASS='${INPUT_REMOTE_PASS}'" $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} error_validate elif hash dbclient 2>/dev/null + then MESSAGE="Dropbear SSH Detected" echo_warn MESSAGE="Skipping Password Setup" From d48cc54b77d3de6e473313aea61c9a6cf61e60f4 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 14:58:12 -0500 Subject: [PATCH 04/57] Stray else --- ADVANCED.md | 1 - gravity-sync.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index 418c296..f8b9baa 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -138,7 +138,6 @@ If you are just straight up unable to run the `gravity-sync.sh` file, make sure chmod +x gravity-sync.sh ``` - ## Updates If you manually installed Gravity Sync via .zip or .tar.gz you will need to download and overwrite the `gravity-sync.sh` file with a newer version. If you've chosen this path, I won't lay out exactly what you'll need to do every time, but you should at least review the contents of the script bundle (specifically the example configuration file) to make sure there are no new additional files or required settings. diff --git a/gravity-sync.sh b/gravity-sync.sh index 9fb6959..6e7a276 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -928,7 +928,7 @@ function config_generate { MESSAGE="Skipping Password Setup" echo_info fi - else + # else # MESSAGE="Defaulting to SSH Key-Pair Authentication" # echo_info fi From 0bbadbf16643c37a9592bbd0e0ccbdaf4642fb9a Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 15:26:25 -0500 Subject: [PATCH 05/57] Change reference --- gravity-sync.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 6e7a276..f0fbbec 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -610,7 +610,6 @@ function validate_os_sshpass { echo_info fi - MESSAGE="Validating Connection to ${REMOTE_HOST}" echo_stat if hash ssh 2>/dev/null @@ -907,7 +906,10 @@ function config_generate { echo_warn if hash ssh 2>/dev/null then - MESSAGE="Before proceeding reference ${BLUE}https://github.com/vmstan/gravity-sync/blob/master/ADVANCED.md#ssh-configuration${NC}" + MESSAGE="Please Reference Documentation" + echo_info + + MESSAGE="${BLUE}https://github.com/vmstan/gravity-sync/blob/master/ADVANCED.md#ssh-configuration${NC}" echo_info MESSAGE="Leave password blank to use key-pair! (reccomended)" From 60dee286fd9784baa2acfb1042f5682fa04aee73 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 15:30:57 -0500 Subject: [PATCH 06/57] Add variable to default --- gravity-sync.conf.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity-sync.conf.example b/gravity-sync.conf.example index 127dea3..8388f89 100644 --- a/gravity-sync.conf.example +++ b/gravity-sync.conf.example @@ -30,4 +30,5 @@ REMOTE_PASS='' # VERIFY_PASS='' # SKIP_CUSTOM='' -# DATE_OUTPUT='' \ No newline at end of file +# DATE_OUTPUT='' +# PING_AVOID='' From 4f5c38c389e605d9c10b7df6115e6cfbec08cd9c Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 15:45:44 -0500 Subject: [PATCH 07/57] Fix bug where password not used --- gravity-sync.sh | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index f0fbbec..b299827 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -583,27 +583,32 @@ function validate_ph_folders { function validate_os_sshpass { # MESSAGE="Checking SSH Configuration" # echo_info - + + SSHPASSWORD='' + if hash sshpass 2>/dev/null then - if test -z "$REMOTE_PASS" - then - SSHPASSWORD='' - 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" ] + MESSAGE="SSHPASS Utility Detected" + echo_warn + if [ -z "$REMOTE_PASS" ] then - SSHPASSWORD="sshpass -p ${REMOTE_PASS}" - MESSAGE="Using SSH Password Authentication" - echo_warn - else - SSHPASSWORD='' MESSAGE="Using SSH Key-Pair Authentication" echo_info + else + MESSAGE="Testing Authentication Options" + echo_info + + 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 + SSHPASSWORD="sshpass -p ${REMOTE_PASS}" + MESSAGE="Using SSH Password Authentication" + echo_warn + else + MESSAGE="${RED}Password Override${NC} - Valid Key-Pair Detected" + echo_info + fi fi - - fi else SSHPASSWORD='' MESSAGE="Using SSH Key-Pair Authentication" @@ -995,6 +1000,9 @@ function config_generate { fi fi + MESSAGE="Testing Configuration" + echo_info + validate_os_sshpass exit_withchange From b86106d7e3e6511d04a9b6478476cc29b413b22e Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 15:48:26 -0500 Subject: [PATCH 08/57] Better colors --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index b299827..f7c7519 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -605,7 +605,7 @@ function validate_os_sshpass { MESSAGE="Using SSH Password Authentication" echo_warn else - MESSAGE="${RED}Password Override${NC} - Valid Key-Pair Detected" + MESSAGE="Valid Key-Pair Detected ${NC}(${RED}Password Override${NC})" echo_info fi fi From b4cc029d7e227ee5347baa2dee8fabc61e64df96 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 17:27:49 -0500 Subject: [PATCH 09/57] Break up SSHPASS --- gravity-sync.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index f7c7519..0d74083 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -605,7 +605,7 @@ function validate_os_sshpass { MESSAGE="Using SSH Password Authentication" echo_warn else - MESSAGE="Valid Key-Pair Detected ${NC}(${RED}Password Override${NC})" + MESSAGE="Valid Key-Pair Detected ${NC}(${RED}Password Ignored${NC})" echo_info fi fi @@ -619,8 +619,14 @@ function validate_os_sshpass { echo_stat if hash ssh 2>/dev/null then - timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + if [ -z "$SSHPASSWORD" ] + then + timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + error_validate + else + timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + error_validate + fi elif hash dbclient 2>/dev/null then timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 From 92269fe4c30033f3cdeb9bfb48bfbec84996d49f Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:44:46 -0500 Subject: [PATCH 10/57] Test new SSH function --- CHANGELOG.md | 11 +++++++---- gravity-sync.sh | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59205ae..647b182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # The Changelog +## 1.8 +### The Logical Release + +- All of the SSH connection logic has been rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. +- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. +- Better error handling of configuration options. + ## 1.7 ### The Andrew Release @@ -11,10 +18,6 @@ **Known Issues** - No new Star Trek references. -#### 1.7.8 -- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. -- Better error handling of configuration options. - #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index 0d74083..9a91953 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -617,23 +617,47 @@ function validate_os_sshpass { MESSAGE="Validating Connection to ${REMOTE_HOST}" echo_stat + + ssh_function + + CMD_TIMEOUT='5' + CMD_REQUESTED="exit" + ${SSH_SEND} + error_validate + if hash ssh 2>/dev/null then if [ -z "$SSHPASSWORD" ] then - timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + # timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + # error_validate else - timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + # error_validate fi elif hash dbclient 2>/dev/null then - timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + # error_validate fi } +## Determine SSH Pathways +function ssh_function { + if hash ssh 2>/dev/null + then + if [ -z "$SSHPASSWORD" ] + then + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + else + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + fi + elif hash dbclient 2>/dev/null + then + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + fi +} + ## Detect SSH-KEYGEN function detect_sshkeygen { MESSAGE="Validating SSH-KEYGEN install on $HOSTNAME" From fc030ba9bfd81d6f750192b18dda3e9abd248590 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:45:25 -0500 Subject: [PATCH 11/57] Devnull --- gravity-sync.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 9a91953..33d3055 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -617,12 +617,12 @@ function validate_os_sshpass { MESSAGE="Validating Connection to ${REMOTE_HOST}" echo_stat - + ssh_function CMD_TIMEOUT='5' CMD_REQUESTED="exit" - ${SSH_SEND} + ${SSH_SEND} >/dev/null 2>&1 error_validate if hash ssh 2>/dev/null From fdeb2be94ffaacf87bb3f1345c12af35b1353dcd Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:46:34 -0500 Subject: [PATCH 12/57] Comment the entire block --- gravity-sync.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 33d3055..4026634 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -625,21 +625,21 @@ function validate_os_sshpass { ${SSH_SEND} >/dev/null 2>&1 error_validate - if hash ssh 2>/dev/null - then - if [ -z "$SSHPASSWORD" ] - then + # if hash ssh 2>/dev/null + # then + # if [ -z "$SSHPASSWORD" ] + # then # timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 # error_validate - else + # else # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 # error_validate - fi - elif hash dbclient 2>/dev/null - then + # fi + # elif hash dbclient 2>/dev/null + # then # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 # error_validate - fi + # fi } ## Determine SSH Pathways From e436c8bd5ef66ebbc5ca47673cd609e9f962d112 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:47:36 -0500 Subject: [PATCH 13/57] Test output of command --- gravity-sync.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gravity-sync.sh b/gravity-sync.sh index 4026634..de0bdf3 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -622,6 +622,7 @@ function validate_os_sshpass { CMD_TIMEOUT='5' CMD_REQUESTED="exit" + echo -e "${SSH_SEND}" ${SSH_SEND} >/dev/null 2>&1 error_validate From e48353724f5b8837a04d8a851031fb52db8028a6 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:51:16 -0500 Subject: [PATCH 14/57] Change function call position --- gravity-sync.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index de0bdf3..3b5f794 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -618,11 +618,10 @@ function validate_os_sshpass { MESSAGE="Validating Connection to ${REMOTE_HOST}" echo_stat - ssh_function - CMD_TIMEOUT='5' CMD_REQUESTED="exit" - echo -e "${SSH_SEND}" + ssh_function + echo -en "${SSH_SEND}" ${SSH_SEND} >/dev/null 2>&1 error_validate From 4c8b76c15fc5254906dfaa030ad65a776a038f78 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:55:17 -0500 Subject: [PATCH 15/57] Preserve status on timeout --- gravity-sync.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 3b5f794..857e683 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -648,13 +648,13 @@ function ssh_function { then if [ -z "$SSHPASSWORD" ] then - SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" else - SSH_SEND="timeout ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" fi } From 6b6ab7619c4329735ada4e3e4c500abd7b25d74b Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:56:59 -0500 Subject: [PATCH 16/57] Remove testing echo --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 857e683..29eedc8 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -621,7 +621,7 @@ function validate_os_sshpass { CMD_TIMEOUT='5' CMD_REQUESTED="exit" ssh_function - echo -en "${SSH_SEND}" + # echo -en "${SSH_SEND}" ${SSH_SEND} >/dev/null 2>&1 error_validate From 84a7189858833aad27d7124ddf52ccd96870893b Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:58:47 -0500 Subject: [PATCH 17/57] Put the echo back --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 29eedc8..857e683 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -621,7 +621,7 @@ function validate_os_sshpass { CMD_TIMEOUT='5' CMD_REQUESTED="exit" ssh_function - # echo -en "${SSH_SEND}" + echo -en "${SSH_SEND}" ${SSH_SEND} >/dev/null 2>&1 error_validate From ab9fced32dd8faaee7c04d16d5c8346fef5b300d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:00:31 -0500 Subject: [PATCH 18/57] Simpler than I thought? --- gravity-sync.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 857e683..eb59f5d 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -648,13 +648,13 @@ function ssh_function { then if [ -z "$SSHPASSWORD" ] then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" else - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" fi } From 9d64fa9a65514d3fdd199482286a0741eeac645a Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:04:02 -0500 Subject: [PATCH 19/57] Test --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index eb59f5d..41b9d3d 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -654,7 +654,7 @@ function ssh_function { fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" fi } From dc20d24d653e7d00e9c8c54ae13e7bc948e2f440 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:08:05 -0500 Subject: [PATCH 20/57] QUotes? --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 41b9d3d..cb494c3 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -654,7 +654,7 @@ function ssh_function { fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" fi } From 71133d4acde2653736bb71cf8f7bbe3207ed1798 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:09:26 -0500 Subject: [PATCH 21/57] More quotes --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index cb494c3..6d6fe3e 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -654,7 +654,7 @@ function ssh_function { fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" fi } From ec5171f35273f41d08a4c76be27c9c369cf22df5 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:15:35 -0500 Subject: [PATCH 22/57] Grrr --- gravity-sync.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 6d6fe3e..35f60bb 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -621,8 +621,8 @@ function validate_os_sshpass { CMD_TIMEOUT='5' CMD_REQUESTED="exit" ssh_function - echo -en "${SSH_SEND}" - ${SSH_SEND} >/dev/null 2>&1 + #echo -en "${SSH_SEND}" + ${SSH_SEND} #>/dev/null 2>&1 error_validate # if hash ssh 2>/dev/null From 480cf29b071bda8e49fc101643ffd310c99a9db7 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:18:53 -0500 Subject: [PATCH 23/57] Comment out --- gravity-sync.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 35f60bb..604549a 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -648,13 +648,13 @@ function ssh_function { then if [ -z "$SSHPASSWORD" ] then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME\/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" else SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME\/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" fi } From e3f6925bbfbbc3396f31ac88ccc95b274375719c Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 21:19:36 -0500 Subject: [PATCH 24/57] remove quotes --- gravity-sync.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 604549a..f45fa16 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -648,13 +648,13 @@ function ssh_function { then if [ -z "$SSHPASSWORD" ] then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i '$HOME\/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" else SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME\/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" fi } From beb9e8513f0f9180e440140af932341e88a49d88 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:09:46 -0500 Subject: [PATCH 25/57] Rsync rewrite test --- ADVANCED.md | 10 ++-------- CHANGELOG.md | 12 +++++------ gravity-sync.sh | 53 +++++++++++++++++++++++++++---------------------- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index f8b9baa..fa461a8 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -97,12 +97,12 @@ Gravity Sync will place logs in the same folder as the script (identified as .cr 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. +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 an `update` operations. 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. +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 an `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. @@ -175,9 +175,3 @@ If you prefer to still use cron but modify your settings by hand, using the entr crontab -e */30 * * * * /bin/bash /home/USER/gravity-sync/gravity-sync.sh pull > /home/USER/gravity-sync/gravity-sync.cron ``` - -## Troubleshooting - -- If it doesn't kick off, you can manually execute a `git pull` while in the `gravity-sync` directory. - -If all else fails, delete the entire `gravity-sync` folder from your system and re-deploy. This will have no impact on your replicated databases. diff --git a/CHANGELOG.md b/CHANGELOG.md index 647b182..016535b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,5 @@ # The Changelog -## 1.8 -### The Logical Release - -- All of the SSH connection logic has been rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. -- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. -- Better error handling of configuration options. - ## 1.7 ### The Andrew Release @@ -18,6 +11,11 @@ **Known Issues** - No new Star Trek references. +#### 1.7.8 +- SSH connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. +- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. +- Better error handling of configuration options. + #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index f45fa16..d9ef5e8 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -150,8 +150,14 @@ function pull_gs { MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}" echo_stat - ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 - error_validate + RSYNC_SOURCE="${PIHOLE_DIR}/${GRAVITY_FI}" + RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull" + create_rsynccmd + ${RSYNC_SEND} >/dev/null 2>&1 + error_validate + + #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 + #error_validate MESSAGE="Replacing ${GRAVITY_FI} on $HOSTNAME" echo_stat @@ -596,7 +602,7 @@ function validate_os_sshpass { echo_info else MESSAGE="Testing Authentication Options" - echo_info + echo_stat timeout 5 ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 if [ "$?" != "0" ] @@ -620,30 +626,13 @@ function validate_os_sshpass { CMD_TIMEOUT='5' CMD_REQUESTED="exit" - ssh_function - #echo -en "${SSH_SEND}" - ${SSH_SEND} #>/dev/null 2>&1 + create_sshcmd + ${SSH_SEND} >/dev/null 2>&1 error_validate - - # if hash ssh 2>/dev/null - # then - # if [ -z "$SSHPASSWORD" ] - # then - # timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - # error_validate - # else - # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - # error_validate - # fi - # elif hash dbclient 2>/dev/null - # then - # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - # error_validate - # fi } ## Determine SSH Pathways -function ssh_function { +function create_sshcmd { if hash ssh 2>/dev/null then if [ -z "$SSHPASSWORD" ] @@ -654,7 +643,23 @@ function ssh_function { fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + fi +} + +## Determine SSH Pathways +function create_rsynccmd { + if hash ssh 2>/dev/null + then + if [ -z "$SSHPASSWORD" ] + then + RSYNC_SEND="rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + else + RSYNC_SEND="rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + fi + elif hash dbclient 2>/dev/null + then + RSYNC_SEND="rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi } From 411a401b0705a36983b42b342b3b6f96334e0314 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:12:29 -0500 Subject: [PATCH 26/57] Quites? --- gravity-sync.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index d9ef5e8..7f68c65 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -653,13 +653,13 @@ function create_rsynccmd { then if [ -z "$SSHPASSWORD" ] then - RSYNC_SEND="rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e \"${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then - RSYNC_SEND="rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi } From 2662a7e8523343246705cafd002c39871ac8dc1d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:18:37 -0500 Subject: [PATCH 27/57] Double quote? --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 7f68c65..55e7d0a 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -655,7 +655,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e \"${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e '"'${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\'"' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From 33078e2018aabb2b9420aeb16984a021a52797ea Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:27:11 -0500 Subject: [PATCH 28/57] Remove a slash --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 55e7d0a..a1ec09c 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -655,7 +655,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e '"'${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\'"' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e '"'${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}'"' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From 2e6fc960d72d46c657440a3d5a3d86871623e3b9 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:28:14 -0500 Subject: [PATCH 29/57] Comment output --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index a1ec09c..4b3f4d0 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -153,7 +153,7 @@ function pull_gs { RSYNC_SOURCE="${PIHOLE_DIR}/${GRAVITY_FI}" RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull" create_rsynccmd - ${RSYNC_SEND} >/dev/null 2>&1 + ${RSYNC_SEND} # >/dev/null 2>&1 error_validate #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 From ba6980c5585403345cfac1094421fa2700be8c59 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:29:33 -0500 Subject: [PATCH 30/57] Test --- gravity-sync.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 4b3f4d0..06fd172 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -154,7 +154,8 @@ function pull_gs { RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull" create_rsynccmd ${RSYNC_SEND} # >/dev/null 2>&1 - error_validate + echo -en ${RSYNC_SEND} + #error_validate #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 #error_validate From 60d676b8ff8a78fba6ee6821cae2c88b6f8da8b6 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:31:20 -0500 Subject: [PATCH 31/57] Test --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 06fd172..64abf49 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -656,7 +656,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e '"'${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}'"' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e \"${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From a13d8ba887401d2396964098ff84af8fecbffae2 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:32:32 -0500 Subject: [PATCH 32/57] I HATE THIS --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 64abf49..d0088ab 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -656,7 +656,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e \"${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e \'${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From abb50c135a300de9e909ebc175857c88258ef4cc Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:33:16 -0500 Subject: [PATCH 33/57] BLAH --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index d0088ab..715db3a 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -656,7 +656,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e \'${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -e '${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From 5b6e4a5990220f7a53e49c94160c46a9ed0dcec5 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:42:08 -0500 Subject: [PATCH 34/57] Test --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 715db3a..4c7bf11 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -656,7 +656,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -e '${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -v -e '${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From 54efb9858a80db12f152bb46d30e89ea9aa4b19e Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 23:49:43 -0500 Subject: [PATCH 35/57] PLEASE --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 4c7bf11..fb1f688 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -656,7 +656,7 @@ function create_rsynccmd { then RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" else - RSYNC_SEND="rsync -v -e '${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + RSYNC_SEND="rsync -v -e ''${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}'' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" fi elif hash dbclient 2>/dev/null then From af11f11a6bd5ced2a27838f28f6e4a3dbe57c45d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 00:07:54 -0500 Subject: [PATCH 36/57] Duh --- gravity-sync.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index fb1f688..f021c00 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -153,9 +153,6 @@ function pull_gs { RSYNC_SOURCE="${PIHOLE_DIR}/${GRAVITY_FI}" RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull" create_rsynccmd - ${RSYNC_SEND} # >/dev/null 2>&1 - echo -en ${RSYNC_SEND} - #error_validate #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 #error_validate @@ -654,13 +651,13 @@ function create_rsynccmd { then if [ -z "$SSHPASSWORD" ] then - RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} else - RSYNC_SEND="rsync -v -e ''${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}'' ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} fi elif hash dbclient 2>/dev/null then - RSYNC_SEND="rsync -e \"${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET}" + rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} fi } From 529789a4c14183c53dff8af15d1275e3d3158b7d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 00:09:34 -0500 Subject: [PATCH 37/57] Fuck quotes --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index f021c00..7252724 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -651,7 +651,7 @@ function create_rsynccmd { then if [ -z "$SSHPASSWORD" ] then - rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} else rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} fi From 89740497e9e6c3022ddd53f3d9a9e2bf0b560dad Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 00:11:02 -0500 Subject: [PATCH 38/57] error validate --- gravity-sync.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gravity-sync.sh b/gravity-sync.sh index 7252724..0a4aa56 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -652,12 +652,15 @@ function create_rsynccmd { if [ -z "$SSHPASSWORD" ] then rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + error_validate else rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + error_validate fi elif hash dbclient 2>/dev/null then rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + error_validate fi } From 8cfdd153920167471f9b21b3cdddf3d7cf1ce583 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 09:20:35 -0500 Subject: [PATCH 39/57] Rewrite SSH function --- gravity-sync.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 0a4aa56..4036c66 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -625,8 +625,7 @@ function validate_os_sshpass { CMD_TIMEOUT='5' CMD_REQUESTED="exit" create_sshcmd - ${SSH_SEND} >/dev/null 2>&1 - error_validate + } ## Determine SSH Pathways @@ -635,13 +634,16 @@ function create_sshcmd { then if [ -z "$SSHPASSWORD" ] then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} "${CMD_REQUESTED}" + error_validate else - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${CMD_REQUESTED}'" + timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} "${CMD_REQUESTED}" + error_validate fi elif hash dbclient 2>/dev/null then - SSH_SEND="timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} "${CMD_REQUESTED}" + error_validate fi } @@ -651,15 +653,15 @@ function create_rsynccmd { then if [ -z "$SSHPASSWORD" ] then - rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 error_validate else - rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 error_validate fi elif hash dbclient 2>/dev/null then - rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} + rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 error_validate fi } From f75a045f87eab8c5a7b8ad431d83d9a5a17af42d Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 09:45:06 -0500 Subject: [PATCH 40/57] Replace SSH commands --- gravity-sync.sh | 113 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 81 insertions(+), 32 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 4036c66..e365262 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -150,7 +150,8 @@ function pull_gs { MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}" echo_stat - RSYNC_SOURCE="${PIHOLE_DIR}/${GRAVITY_FI}" + RSYNC_REPATH="rsync" + RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}" RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull" create_rsynccmd @@ -217,8 +218,13 @@ function pull_gs { MESSAGE="Pulling ${CUSTOM_DNS} from ${REMOTE_HOST}" echo_stat - ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull >/dev/null 2>&1 - error_validate + RSYNC_REPATH="rsync" + RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}" + RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull" + create_rsynccmd + + #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull >/dev/null 2>&1 + #error_validate MESSAGE="Replacing ${CUSTOM_DNS} on $HOSTNAME" echo_stat @@ -294,23 +300,41 @@ function push_gs { MESSAGE="Backing Up ${GRAVITY_FI} from ${REMOTE_HOST}" echo_stat - ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push >/dev/null 2>&1 - error_validate + RSYNC_REPATH="rsync" + RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}" + RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push" + create_rsynccmd + + # ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push >/dev/null 2>&1 + # error_validate MESSAGE="Pushing ${GRAVITY_FI} to ${REMOTE_HOST}" echo_stat - ${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 - error_validate + RSYNC_REPATH="sudo rsync" + RSYNC_SOURCE="${PIHOLE_DIR}/${GRAVITY_FI}" + RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}" + create_rsynccmd + + #${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 + #error_validate MESSAGE="Setting Permissions on ${GRAVITY_FI}" - echo_stat - ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 - error_validate + echo_stat + CMD_TIMEOUT='15' + CMD_REQUESTED="sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" + create_sshcmd + + #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 + #error_validate MESSAGE="Setting Ownership on ${GRAVITY_FI}" - echo_stat - ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 - error_validate + echo_stat + CMD_TIMEOUT='15' + CMD_REQUESTED="sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" + create_sshcmd + + # ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 + # error_validate if [ "$SKIP_CUSTOM" != '1' ] then @@ -318,23 +342,41 @@ function push_gs { then MESSAGE="Backing Up ${CUSTOM_DNS} from ${REMOTE_HOST}" echo_stat - ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push >/dev/null 2>&1 - error_validate + RSYNC_REPATH="rsync" + RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}" + RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push" + create_rsynccmd + + # ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push >/dev/null 2>&1 + # error_validate MESSAGE="Pushing ${CUSTOM_DNS} to ${REMOTE_HOST}" echo_stat - ${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${PIHOLE_DIR}/${CUSTOM_DNS} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1 - error_validate + RSYNC_REPATH="sudo rsync" + RSYNC_SOURCE="${PIHOLE_DIR}/${CUSTOM_DNS}" + RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}" + create_rsynccmd + + # ${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${PIHOLE_DIR}/${CUSTOM_DNS} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1 + # error_validate MESSAGE="Setting Permissions on ${CUSTOM_DNS}" - echo_stat - ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS}" >/dev/null 2>&1 - error_validate + echo_stat + CMD_TIMEOUT='15' + CMD_REQUESTED="sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS}" + create_sshcmd + + #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS}" >/dev/null 2>&1 + #error_validate MESSAGE="Setting Ownership on ${CUSTOM_DNS}" - echo_stat - ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS}" >/dev/null 2>&1 - error_validate + echo_stat + CMD_TIMEOUT='15' + CMD_REQUESTED="sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS}" + create_sshcmd + + #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS}" >/dev/null 2>&1 + #error_validate fi fi @@ -344,14 +386,21 @@ function push_gs { MESSAGE="Updating FTLDNS Configuration" echo_stat - ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns reloadlists" >/dev/null 2>&1 - error_validate + CMD_TIMEOUT='15' + CMD_REQUESTED="${PIHOLE_BIN} restartdns reloadlists" + create_sshcmd + + #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns reloadlists" >/dev/null 2>&1 + #error_validate MESSAGE="Reloading FTLDNS Services" - echo_stat - ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1 - error_validate - + echo_stat + CMD_TIMEOUT='15' + CMD_REQUESTED="${PIHOLE_BIN} restartdns" + create_sshcmd + + # ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1 + # error_validate logs_export exit_withchange @@ -653,15 +702,15 @@ function create_rsynccmd { then if [ -z "$SSHPASSWORD" ] then - rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 + rsync --rsync-path="${RSYNC_REPATH}" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 error_validate else - rsync -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 + rsync --rsync-path="${RSYNC_REPATH}" -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 error_validate fi elif hash dbclient 2>/dev/null then - rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 + rsync --rsync-path="${RSYNC_REPATH}" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1 error_validate fi } From ff97527661219db559b4a35a7252107b3ccd87ce Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 13:07:15 -0500 Subject: [PATCH 41/57] Remove old code comments --- gravity-sync.sh | 109 ++++-------------------------------------------- 1 file changed, 9 insertions(+), 100 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index e365262..7b87534 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -93,7 +93,6 @@ function import_gs { TASKTYPE='CONFIG' config_generate - # echo -e "Please run ${YELLOW}$#${NC} again." fi } @@ -101,8 +100,7 @@ function import_gs { ## Master Branch function update_gs { TASKTYPE='UPDATE' - # logs_export # dumps log prior to execution because script stops after successful pull - + if [ -f "$HOME/${LOCAL_FOLDR}/dev" ] then BRANCH='development' @@ -123,8 +121,6 @@ function update_gs { echo_warn exit_nochange else - # MESSAGE="This might break..." - # echo_warn MESSAGE="Updating Cache" echo_stat git fetch --all >/dev/null 2>&1 @@ -154,9 +150,6 @@ function pull_gs { RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}" RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull" create_rsynccmd - - #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 - #error_validate MESSAGE="Replacing ${GRAVITY_FI} on $HOSTNAME" echo_stat @@ -222,9 +215,6 @@ function pull_gs { RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}" RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull" create_rsynccmd - - #${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull >/dev/null 2>&1 - #error_validate MESSAGE="Replacing ${CUSTOM_DNS} on $HOSTNAME" echo_stat @@ -305,27 +295,18 @@ function push_gs { RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push" create_rsynccmd - # ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push >/dev/null 2>&1 - # error_validate - MESSAGE="Pushing ${GRAVITY_FI} to ${REMOTE_HOST}" echo_stat RSYNC_REPATH="sudo rsync" RSYNC_SOURCE="${PIHOLE_DIR}/${GRAVITY_FI}" RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}" create_rsynccmd - - #${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 - #error_validate MESSAGE="Setting Permissions on ${GRAVITY_FI}" echo_stat CMD_TIMEOUT='15' CMD_REQUESTED="sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" create_sshcmd - - #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 - #error_validate MESSAGE="Setting Ownership on ${GRAVITY_FI}" echo_stat @@ -333,9 +314,6 @@ function push_gs { CMD_REQUESTED="sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" create_sshcmd - # ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 - # error_validate - if [ "$SKIP_CUSTOM" != '1' ] then if [ "$REMOTE_CUSTOM_DNS" == "1" ] @@ -346,9 +324,6 @@ function push_gs { RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}" RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push" create_rsynccmd - - # ${SSHPASSWORD} rsync -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push >/dev/null 2>&1 - # error_validate MESSAGE="Pushing ${CUSTOM_DNS} to ${REMOTE_HOST}" echo_stat @@ -357,26 +332,17 @@ function push_gs { RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}" create_rsynccmd - # ${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${PIHOLE_DIR}/${CUSTOM_DNS} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1 - # error_validate - MESSAGE="Setting Permissions on ${CUSTOM_DNS}" echo_stat CMD_TIMEOUT='15' CMD_REQUESTED="sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS}" create_sshcmd - #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS}" >/dev/null 2>&1 - #error_validate - MESSAGE="Setting Ownership on ${CUSTOM_DNS}" echo_stat CMD_TIMEOUT='15' CMD_REQUESTED="sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS}" create_sshcmd - - #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS}" >/dev/null 2>&1 - #error_validate fi fi @@ -389,9 +355,6 @@ function push_gs { CMD_TIMEOUT='15' CMD_REQUESTED="${PIHOLE_BIN} restartdns reloadlists" create_sshcmd - - #${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns reloadlists" >/dev/null 2>&1 - #error_validate MESSAGE="Reloading FTLDNS Services" echo_stat @@ -399,8 +362,6 @@ function push_gs { CMD_REQUESTED="${PIHOLE_BIN} restartdns" create_sshcmd - # ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1 - # error_validate logs_export exit_withchange @@ -634,9 +595,6 @@ function validate_ph_folders { ## Validate SSHPASS function validate_os_sshpass { - # MESSAGE="Checking SSH Configuration" - # echo_info - SSHPASSWORD='' if hash sshpass 2>/dev/null @@ -852,8 +810,6 @@ function md5_compare { if [ "$primaryDBMD5" == "$secondDBMD5" ] then - # MESSAGE="Identical ${GRAVITY_FI} Detected" - # echo_info HASHMARK=$((HASHMARK+0)) else MESSAGE="Differenced ${GRAVITY_FI} Detected" @@ -1022,9 +978,6 @@ function config_generate { MESSAGE="Skipping Password Setup" echo_info fi - # else - # MESSAGE="Defaulting to SSH Key-Pair Authentication" - # echo_info fi if [ -z $INPUT_REMOTE_PASS ] @@ -1152,10 +1105,6 @@ function list_gs_arguments { echo -e " ${YELLOW}restore${NC} Restore ${GRAVITY_FI} on this server" echo -e " ${YELLOW}compare${NC} Just check for differences" echo -e "" -# echo -e "Update Options:" -# echo -e " ${YELLOW}update${NC} Use GitHub to update this script to the latest version" -# echo -e " ${YELLOW}beta${NC} Use GitHub to update this script to the latest beta version" -# echo -e "" echo -e "Debug Options:" echo -e " ${YELLOW}logs${NC} Show recent successful replication jobs" echo -e " ${YELLOW}cron${NC} Display output of last crontab execution" @@ -1263,9 +1212,6 @@ function task_configure { TASKTYPE='CONFIGURE' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info if [ -f $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} ] then @@ -1308,9 +1254,6 @@ function task_update { TASKTYPE='UPDATE' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info update_gs } @@ -1321,9 +1264,6 @@ function task_version { MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - #MESSAGE="${TASKTYPE} Requested" - #echo_info - show_version exit_nochange } @@ -1333,9 +1273,6 @@ function task_logs { TASKTYPE='LOGS' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info logs_gs } @@ -1345,14 +1282,8 @@ 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 @@ -1366,9 +1297,6 @@ function task_cron { TASKTYPE='CRON' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info show_crontab } @@ -1429,17 +1357,11 @@ case $# in TASKTYPE='PULL' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info import_gs - - # MESSAGE="Validating Folder Configuration" - # echo_info - validate_gs_folders - validate_ph_folders - validate_os_sshpass + validate_gs_folders + validate_ph_folders + validate_os_sshpass pull_gs exit @@ -1449,17 +1371,11 @@ case $# in TASKTYPE='PUSH' MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - - #MESSAGE="${TASKTYPE} Requested" - #echo_info import_gs - - # MESSAGE="Validating Folder Configuration" - # echo_info - validate_gs_folders - validate_ph_folders - validate_os_sshpass + validate_gs_folders + validate_ph_folders + validate_os_sshpass push_gs exit @@ -1470,17 +1386,10 @@ case $# in MESSAGE="${MESSAGE}: ${TASKTYPE} Requested" echo_good - #MESSAGE="${TASKTYPE} Requested" - #echo_info - import_gs + validate_gs_folders + validate_ph_folders - # MESSAGE="Validating Folder Configuration" - # echo_info - validate_gs_folders - validate_ph_folders - # validate_os_sshpass - restore_gs exit ;; From 8601137799f34d4e0067b5d9e229df86be9ac5cd Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 13:26:00 -0500 Subject: [PATCH 42/57] Silence SSH keygen --- CHANGELOG.md | 2 +- VERSION | 2 +- gravity-sync.sh | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 016535b..1dd3922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - No new Star Trek references. #### 1.7.8 -- SSH connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. +- SSH/RSYNC connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. - Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. - Better error handling of configuration options. diff --git a/VERSION b/VERSION index 73c8b4f..25a6ced 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.7 \ No newline at end of file +1.7.8 \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index 7b87534..fbe5112 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -3,7 +3,7 @@ SCRIPT_START=$SECONDS # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='1.7.7' +VERSION='1.7.8' # 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 @@ -987,7 +987,7 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -t rsa -f" + KEYGEN_COMMAND="ssh-keygen -t rsa -f -q -N ''" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" @@ -1284,10 +1284,9 @@ function task_compare { echo_good import_gs - - validate_gs_folders - validate_ph_folders - validate_os_sshpass + validate_gs_folders + validate_ph_folders + validate_os_sshpass md5_compare } From e359ef73659ddfbe09ad74b6f1d818632f0dcf83 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 13:31:29 -0500 Subject: [PATCH 43/57] Rework Ssh-keygen option order --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index fbe5112..87d3d8b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -987,7 +987,7 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -t rsa -f -q -N ''" + KEYGEN_COMMAND="ssh-keygen -q -N '' -t rsa -f" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" From be2881d629ead0f638729bee062548b45343dde6 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 13:58:05 -0500 Subject: [PATCH 44/57] Dropbear key creation update --- ADVANCED.md | 4 ++-- CHANGELOG.md | 2 ++ gravity-sync.sh | 10 ++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index fa461a8..36ea8aa 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.7.zip -unzip v1.7.7.zip -d gravity-sync +wget https://github.com/vmstan/gravity-sync/archive/v1.7.8.zip +unzip v1.7.8.zip -d gravity-sync cd gravity-sync ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd3922..30fb765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - SSH/RSYNC connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. - Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. - Better error handling of configuration options. +- Adds custom port specification to ssh-copy-id command during configuration generation. +- OpenSSH key generation works without user prompts. #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index 87d3d8b..bf78339 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -692,13 +692,11 @@ function detect_sshkeygen { then MESSAGE="Using DROPBEARKEY Instead" echo_info - if [ -d $HOME/.ssh ] + if [ ! -d $HOME/.ssh ] then - KEYGEN_COMMAND="dropbearkey -t rsa -f" - else mkdir $HOME/.ssh >/dev/null 2>&1 - KEYGEN_COMMAND="dropbearkey -t rsa -f $HOME/${SSH_PKIF}" fi + KEYGEN_COMMAND="dropbearkey -t rsa -f" else MESSAGE="No Alternatives Located" echo_info @@ -987,7 +985,7 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -q -N '' -t rsa -f" + KEYGEN_COMMAND="ssh-keygen -q -N \"\" -t rsa -f" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" @@ -1026,7 +1024,7 @@ function config_generate { echo -e "========================================================" if hash ssh-copy-id 2>/dev/null then - ssh-copy-id -f -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} + ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} elif hash dbclient 2>/dev/null then dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub From 23f390f4aba575cfabf364a57bc69f73fb19befa Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 13:58:58 -0500 Subject: [PATCH 45/57] Fewer --- CHANGELOG.md | 2 +- gravity-sync.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30fb765..8137018 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ - Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. - Better error handling of configuration options. - Adds custom port specification to ssh-copy-id command during configuration generation. -- OpenSSH key generation works without user prompts. +- OpenSSH key generation works fewer user prompts. #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index bf78339..cc1b60f 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -985,13 +985,13 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -q -N \"\" -t rsa -f" + KEYGEN_COMMAND="ssh-keygen -N \"\" -t rsa -f" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" echo_info - MESSAGE="Accept All Defaults" + MESSAGE="Accept All Defaults If Prompted" echo_warn MESSAGE="Complete Key-Pair Creation" From 3073063f93691214a366670ad1c9d1720e52317e Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:04:52 -0500 Subject: [PATCH 46/57] Maybe not? --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index cc1b60f..9c1d26a 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -985,7 +985,7 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -N \"\" -t rsa -f" + KEYGEN_COMMAND="ssh-keygen -N "" -t rsa -f" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" From aac13988d753dd0e1fdb1abc50bd5bd108e42dce Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:06:53 -0500 Subject: [PATCH 47/57] I will make this work --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 9c1d26a..1c369e1 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -985,7 +985,7 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -N "" -t rsa -f" + KEYGEN_COMMAND="ssh-keygen -N "\"\"" -t rsa -f" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" From bdb770ef608f1e06d75f909383b813ec3330a397 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:07:36 -0500 Subject: [PATCH 48/57] TRY THIS --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 1c369e1..24e617b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -985,7 +985,7 @@ function config_generate { MESSAGE="Using Existing ~/${SSH_PKIF}" echo_info else - KEYGEN_COMMAND="ssh-keygen -N "\"\"" -t rsa -f" + KEYGEN_COMMAND="ssh-keygen -N \"""\" -t rsa -f" detect_sshkeygen MESSAGE="Generating ~/${SSH_PKIF}" From 1ab2a4ffe9c4773ab8dfa2c1e7fc0d73776511d5 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:30:33 -0500 Subject: [PATCH 49/57] Rewrite SSH key generation --- CHANGELOG.md | 2 +- gravity-sync.sh | 125 +++++++++++++++++++++++++++--------------------- 2 files changed, 72 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8137018..63aa32b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ - Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. - Better error handling of configuration options. - Adds custom port specification to ssh-copy-id command during configuration generation. -- OpenSSH key generation works fewer user prompts. +- OpenSSH key generation works with fewer user prompts. #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index 24e617b..359d172 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -705,6 +705,74 @@ function detect_sshkeygen { fi } +function generate_sshkey { + if [ -z $INPUT_REMOTE_PASS ] + then + if [ -f $HOME/${SSH_PKIF} ] + then + MESSAGE="Using Existing ~/${SSH_PKIF}" + echo_info + else + if hash ssh-keygen >/dev/null 2>&1 + then + MESSAGE="Generating ~/${SSH_PKIF} (SSH-KEYGEN)" + echo_stat + + ssh-keygen -q -P "" -t rsa -f $HOME/${SSH_PKIF} + error_validate + + elif hash dropbearkey >/dev/null 2>&1 + then + MESSAGE="Generating ~/${SSH_PKIF} (DROPBEARKEY)" + echo_info + if [ ! -d $HOME/.ssh ] + then + mkdir $HOME/.ssh >/dev/null 2>&1 + fi + echo -e "========================================================" + echo -e "========================================================" + dropbearkey -t rsa -f $HOME/${SSH_PKIF} + echo -e "========================================================" + echo -e "========================================================" + else + MESSAGE="No SSH Key Generator Located" + echo_warn + exit_nochange + fi + fi + fi +} + +function export_sshkey { + if [ -z $REMOTE_PASS ] + then + if [ -f $HOME/${SSH_PKIF} ] + then + MESSAGE="Registering Key-Pair on ${REMOTE_HOST}" + echo_info + + MESSAGE="Enter ${REMOTE_USER}@${REMOTE_HOST} Password Below" + echo -e "${NEED} ${MESSAGE}" + + echo -e "========================================================" + echo -e "========================================================" + if hash ssh-copy-id 2>/dev/null + then + ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} + elif hash dbclient 2>/dev/null + then + dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub + cat $HOME/${SSH_PKIF}.pub | dbclient ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' + fi + echo -e "========================================================" + echo -e "========================================================" + else + MESSAGE="Error Creating Key-Pair" + echo -e "${FAIL} ${MESSAGE}" + fi + fi +} + ## Detect Package Manager function distro_check { if hash apt-get 2>/dev/null @@ -978,65 +1046,14 @@ function config_generate { fi fi - if [ -z $INPUT_REMOTE_PASS ] - then - if [ -f $HOME/${SSH_PKIF} ] - then - MESSAGE="Using Existing ~/${SSH_PKIF}" - echo_info - else - KEYGEN_COMMAND="ssh-keygen -N \"""\" -t rsa -f" - detect_sshkeygen - - MESSAGE="Generating ~/${SSH_PKIF}" - echo_info - - MESSAGE="Accept All Defaults If Prompted" - echo_warn - - MESSAGE="Complete Key-Pair Creation" - echo -e "${NEED} ${MESSAGE}" - - echo -e "========================================================" - echo -e "========================================================" - ${KEYGEN_COMMAND} $HOME/${SSH_PKIF} - echo -e "========================================================" - echo -e "========================================================" - fi - fi + generate_sshkey MESSAGE="Importing New ${CONFIG_FILE}" echo_stat source $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} error_validate - - if [ -z $REMOTE_PASS ] - then - if [ -f $HOME/${SSH_PKIF} ] - then - MESSAGE="Registering Key-Pair on ${REMOTE_HOST}" - echo_info - - MESSAGE="Enter ${REMOTE_USER}@${REMOTE_HOST} Password Below" - echo -e "${NEED} ${MESSAGE}" - - echo -e "========================================================" - echo -e "========================================================" - if hash ssh-copy-id 2>/dev/null - then - ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} - elif hash dbclient 2>/dev/null - then - dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub - cat $HOME/${SSH_PKIF}.pub | dbclient ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' - fi - echo -e "========================================================" - echo -e "========================================================" - else - MESSAGE="Error Creating Key-Pair" - echo -e "${FAIL} ${MESSAGE}" - fi - fi + + export_sshkey MESSAGE="Testing Configuration" echo_info From 2fcaeb4428faa22e614efb6d3fd918748a2d5308 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:38:50 -0500 Subject: [PATCH 50/57] Clean up key registration output --- gravity-sync.sh | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 359d172..7edddc7 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -718,22 +718,20 @@ function generate_sshkey { MESSAGE="Generating ~/${SSH_PKIF} (SSH-KEYGEN)" echo_stat - ssh-keygen -q -P "" -t rsa -f $HOME/${SSH_PKIF} + ssh-keygen -q -P "" -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1 error_validate elif hash dropbearkey >/dev/null 2>&1 then MESSAGE="Generating ~/${SSH_PKIF} (DROPBEARKEY)" - echo_info + echo_stat if [ ! -d $HOME/.ssh ] then mkdir $HOME/.ssh >/dev/null 2>&1 fi - echo -e "========================================================" - echo -e "========================================================" - dropbearkey -t rsa -f $HOME/${SSH_PKIF} - echo -e "========================================================" - echo -e "========================================================" + + dropbearkey -y -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1 + error_validate else MESSAGE="No SSH Key Generator Located" echo_warn @@ -751,11 +749,9 @@ function export_sshkey { MESSAGE="Registering Key-Pair on ${REMOTE_HOST}" echo_info - MESSAGE="Enter ${REMOTE_USER}@${REMOTE_HOST} Password Below" - echo -e "${NEED} ${MESSAGE}" - - echo -e "========================================================" - echo -e "========================================================" + #MESSAGE="Enter ${REMOTE_USER}@${REMOTE_HOST} Password Below" + #echo -e "${NEED} ${MESSAGE}" + if hash ssh-copy-id 2>/dev/null then ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} @@ -764,11 +760,9 @@ function export_sshkey { dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub cat $HOME/${SSH_PKIF}.pub | dbclient ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' fi - echo -e "========================================================" - echo -e "========================================================" else - MESSAGE="Error Creating Key-Pair" - echo -e "${FAIL} ${MESSAGE}" + MESSAGE="Error Registering Key-Pair" + echo_warn fi fi } From 13d91792e03cc64e53d9a874970f8e60ab91b8f1 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:44:49 -0500 Subject: [PATCH 51/57] Silence dbclient --- CHANGELOG.md | 4 ++-- gravity-sync.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63aa32b..14ecb31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,8 @@ - SSH/RSYNC connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. - Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. - Better error handling of configuration options. -- Adds custom port specification to ssh-copy-id command during configuration generation. -- OpenSSH key generation works with fewer user prompts. +- Adds custom port specification to ssh-copy-id and dropbearkey commands during configuration generation. +- Key generation works with fewer no user prompts. #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index 7edddc7..396ea74 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -757,8 +757,8 @@ function export_sshkey { ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} elif hash dbclient 2>/dev/null then - dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub - cat $HOME/${SSH_PKIF}.pub | dbclient ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' + dropbearkey -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub + cat $HOME/${SSH_PKIF}.pub | dbclient -p ${SSH_PORT} -y ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' fi else MESSAGE="Error Registering Key-Pair" From 136a818d69c6c705f5904839d9f322b9d3409784 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:47:40 -0500 Subject: [PATCH 52/57] Regression --- gravity-sync.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 396ea74..84bce43 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -730,7 +730,7 @@ function generate_sshkey { mkdir $HOME/.ssh >/dev/null 2>&1 fi - dropbearkey -y -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1 + dropbearkey -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1 error_validate else MESSAGE="No SSH Key Generator Located" @@ -757,7 +757,7 @@ function export_sshkey { ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} elif hash dbclient 2>/dev/null then - dropbearkey -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub + dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub cat $HOME/${SSH_PKIF}.pub | dbclient -p ${SSH_PORT} -y ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' fi else From 2616ab5987c64a28911d694ed7b66788ab2d9867 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 14:53:09 -0500 Subject: [PATCH 53/57] Remove unconditional connection --- gravity-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 84bce43..5ca7f54 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -758,7 +758,7 @@ function export_sshkey { elif hash dbclient 2>/dev/null then dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub - cat $HOME/${SSH_PKIF}.pub | dbclient -p ${SSH_PORT} -y ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' + cat $HOME/${SSH_PKIF}.pub | dbclient -p ${SSH_PORT} ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' fi else MESSAGE="Error Registering Key-Pair" From 8c4b3a1268389fcfbfcfa197a554acd4b2267595 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:06:03 -0500 Subject: [PATCH 54/57] sed instead of awk --- CHANGELOG.md | 18 +++++++++++------- gravity-sync.sh | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ecb31..94177f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # The Changelog +## 1.8 +### The Logical Release +**Features** +There is nothing really sexy here, but a lot of changes under the covers to improve reliablity between different SSH client types. A lot of the logic and functions are more consistent and cleaner. In some cultures, fewer bugs and more reliablity are considered features. + +- SSH/RSYNC connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. +- Key-pair generation functions rewritten to be specific to client options, also now works with no (or at least fewer) user prompts. +- SSHPASS options should be more reliable if used, but removes messages that SSHPASS is not installed during setup, if it's not needed and Redirects user to documentation. +- Adds custom port specification to ssh-copy-id and dropbearkey commands during configuration generation. +- Generally better error handling of configuration options. + ## 1.7 ### The Andrew Release @@ -11,13 +22,6 @@ **Known Issues** - No new Star Trek references. -#### 1.7.8 -- SSH/RSYNC connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. -- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. -- Better error handling of configuration options. -- Adds custom port specification to ssh-copy-id and dropbearkey commands during configuration generation. -- Key generation works with fewer no user prompts. - #### 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. diff --git a/gravity-sync.sh b/gravity-sync.sh index 5ca7f54..b7b07eb 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -114,7 +114,7 @@ function update_gs { echo_info fi - GIT_CHECK=$(git status | awk '{print $1}') + GIT_CHECK=$(git status | sed 's/\s.*$//') if [ "$GIT_CHECK" == "fatal:" ] then MESSAGE="Requires GitHub Installation" @@ -177,7 +177,7 @@ function pull_gs { echo_stat fi - GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}') + GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | sed 's/\s.*$//') if [ $GRAVDB_RWE != "-rw-rw-r--" ] then MESSAGE="Validating Permissions on ${GRAVITY_FI}" @@ -242,7 +242,7 @@ function pull_gs { echo_stat fi - CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}') + CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | sed 's/\s.*$//') if [ $CUSTOMLS_RWE != "-rw-r--r--" ] then MESSAGE="Validating Permissions on ${CUSTOM_DNS}" @@ -400,7 +400,7 @@ function restore_gs { 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}') + GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | sed 's/\s.*$//') if [ $GRAVDB_RWE = "-rw-rw-r--" ] then echo_good @@ -447,7 +447,7 @@ function restore_gs { 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}') + CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | sed 's/\s.*$//') if [ $CUSTOMLS_RWE == "-rw-r--r--" ] then echo_good From 44f9f70cef7e048a90458f5087c91b6555b01550 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:09:26 -0500 Subject: [PATCH 55/57] Some day I'll understand how quotes work in bash --- gravity-sync.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index b7b07eb..20d230b 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -160,7 +160,7 @@ function pull_gs { echo_stat GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk '{print $3 $4}') - if [ $GRAVDB_OWN != "piholepihole" ] + if [ "$GRAVDB_OWN" != "piholepihole" ] then MESSAGE="Validating Ownership on ${GRAVITY_FI}" echo_fail @@ -178,7 +178,7 @@ function pull_gs { fi GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | sed 's/\s.*$//') - if [ $GRAVDB_RWE != "-rw-rw-r--" ] + if [ "$GRAVDB_RWE" != "-rw-rw-r--" ] then MESSAGE="Validating Permissions on ${GRAVITY_FI}" echo_fail @@ -225,7 +225,7 @@ function pull_gs { echo_stat CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}') - if [ $CUSTOMLS_OWN != "rootroot" ] + if [ "$CUSTOMLS_OWN" != "rootroot" ] then MESSAGE="Validating Ownership on ${CUSTOM_DNS}" echo_fail @@ -243,7 +243,7 @@ function pull_gs { fi CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | sed 's/\s.*$//') - if [ $CUSTOMLS_RWE != "-rw-r--r--" ] + if [ "$CUSTOMLS_RWE" != "-rw-r--r--" ] then MESSAGE="Validating Permissions on ${CUSTOM_DNS}" echo_fail @@ -382,7 +382,7 @@ function restore_gs { 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 @@ -401,7 +401,7 @@ function restore_gs { echo_stat GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | sed 's/\s.*$//') - if [ $GRAVDB_RWE = "-rw-rw-r--" ] + if [ "$GRAVDB_RWE" = "-rw-rw-r--" ] then echo_good else @@ -429,7 +429,7 @@ function restore_gs { 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 @@ -448,7 +448,7 @@ function restore_gs { echo_stat CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | sed 's/\s.*$//') - if [ $CUSTOMLS_RWE == "-rw-r--r--" ] + if [ "$CUSTOMLS_RWE" == "-rw-r--r--" ] then echo_good else From 3810b678082dd22045663271790a67ae5dd3d2ab Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:12:39 -0500 Subject: [PATCH 56/57] Back to awk --- gravity-sync.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 20d230b..031e3fb 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -114,7 +114,7 @@ function update_gs { echo_info fi - GIT_CHECK=$(git status | sed 's/\s.*$//') + GIT_CHECK=$(git status | awk '{print $1}') if [ "$GIT_CHECK" == "fatal:" ] then MESSAGE="Requires GitHub Installation" @@ -177,7 +177,7 @@ function pull_gs { echo_stat fi - GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | sed 's/\s.*$//') + GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}') if [ "$GRAVDB_RWE" != "-rw-rw-r--" ] then MESSAGE="Validating Permissions on ${GRAVITY_FI}" @@ -242,7 +242,7 @@ function pull_gs { echo_stat fi - CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | sed 's/\s.*$//') + CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}') if [ "$CUSTOMLS_RWE" != "-rw-r--r--" ] then MESSAGE="Validating Permissions on ${CUSTOM_DNS}" @@ -400,7 +400,7 @@ function restore_gs { MESSAGE="Validating Permissions on ${GRAVITY_FI}" echo_stat - GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | sed 's/\s.*$//') + GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}') if [ "$GRAVDB_RWE" = "-rw-rw-r--" ] then echo_good @@ -447,7 +447,7 @@ function restore_gs { MESSAGE="Validating Permissions on ${CUSTOM_DNS}" echo_stat - CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | sed 's/\s.*$//') + CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}') if [ "$CUSTOMLS_RWE" == "-rw-r--r--" ] then echo_good From 99e04ffa08e747c110fdcce95b3b2b222be6c695 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 3 Jun 2020 15:15:45 -0500 Subject: [PATCH 57/57] 1.8.0(1) --- ADVANCED.md | 4 ++-- CHANGELOG.md | 2 +- VERSION | 2 +- gravity-sync.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ADVANCED.md b/ADVANCED.md index 36ea8aa..2424cd9 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.8.zip -unzip v1.7.8.zip -d gravity-sync +wget https://github.com/vmstan/gravity-sync/archive/v1.8.0.zip +unzip v1.8.0.zip -d gravity-sync cd gravity-sync ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 94177f0..2838506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.8 ### The Logical Release **Features** -There is nothing really sexy here, but a lot of changes under the covers to improve reliablity between different SSH client types. A lot of the logic and functions are more consistent and cleaner. In some cultures, fewer bugs and more reliablity are considered features. +There is nothing really sexy here, but a lot of changes under the covers to improve reliablity between different SSH client types. A lot of the logic and functions are more consistent and cleaner. In some cultures, fewer bugs and more reliablity are considered features. Much of this will continue through the 1.8.x line. - SSH/RSYNC connection logic rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. - Key-pair generation functions rewritten to be specific to client options, also now works with no (or at least fewer) user prompts. diff --git a/VERSION b/VERSION index 25a6ced..afa2b35 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.8 \ No newline at end of file +1.8.0 \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index 031e3fb..89f3185 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -3,7 +3,7 @@ SCRIPT_START=$SECONDS # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='1.7.8' +VERSION='1.8.0' # 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