Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from vmstan:development
Browse files Browse the repository at this point in the history
v1.4.3
  • Loading branch information
vmstan authored May 27, 2020
2 parents 92a34cf + 905651e commit 4d5f621
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync

```
cd ~
wget https://github.com/vmstan/gravity-sync/archive/v1.4.2.zip
unzip v1.4.2.zip
mv ~/gravity-sync-1.4.2 ~/gravity-sync
wget https://github.com/vmstan/gravity-sync/archive/v1.4.3.zip
unzip v1.4.3.zip
mv ~/gravity-sync-1.4.3 ~/gravity-sync
cd gravity-sync
```

Expand Down
26 changes: 13 additions & 13 deletions gravity-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# GRAVITY SYNC BY VMSTAN #####################
PROGRAM='Gravity Sync'
VERSION='1.4.2'
VERSION='1.4.3'

# Execute from the home folder of the user who own's it (ex: 'cd ~/gravity-sync')
# For documentation or download updates visit https://github.com/vmstan/gravity-sync
Expand Down Expand Up @@ -34,7 +34,7 @@ PIHOLE_BIN='/usr/local/bin/pihole' # default PH binary directory
# Add replacement variables to gravity-sync.conf

SSH_PORT='22' # default SSH port
SSH_PKIF='.ssh/id_rsa.pub' # default local SSH key
SSH_PKIF='.ssh/id_rsa' # default local SSH key

##############################################
### DO NOT CHANGE ANYTHING BELOW THIS LINE ###
Expand Down Expand Up @@ -125,7 +125,7 @@ function pull_gs {

MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}"
echo -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1
${SSHPASSWORD} rsync -e "ssh -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"
Expand Down Expand Up @@ -203,22 +203,22 @@ function push_gs {

MESSAGE="Backing Up ${GRAVITY_FI} from ${REMOTE_HOST}"
echo -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push >/dev/null 2>&1
${SSHPASSWORD} rsync -e "ssh -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 -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "ssh -p ${SSH_PORT}" ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "ssh -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 -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1
${SSHPASSWORD} ssh -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 -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1
${SSHPASSWORD} ssh -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

MESSAGE="Contacting Borg Collective"
Expand All @@ -227,12 +227,12 @@ function push_gs {

MESSAGE="Updating FTLDNS Configuration"
echo -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns reloadlists" >/dev/null 2>&1
${SSHPASSWORD} ssh -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 -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1
${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1
error_validate

logs_export
Expand Down Expand Up @@ -348,7 +348,7 @@ function validate_os_sshpass {
SSHPASSWORD=''
MESSAGE="Using SSH Key-Pair Authentication"
else
timeout 5 ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1
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"
Expand All @@ -367,7 +367,7 @@ function validate_os_sshpass {

MESSAGE="Testing SSH Connection"
echo -en "${STAT} ${MESSAGE}"
timeout 5 ${SSHPASSWORD} ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1
timeout 5 ${SSHPASSWORD} ssh -p ${SSH_PORT} -i '$HOME/${SSH_PKIF}' -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1
error_validate

}
Expand All @@ -388,7 +388,7 @@ function md5_compare {

MESSAGE="Analyzing Remote ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"
primaryMD5=$(${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} 'md5sum /etc/pihole/gravity.db')
primaryMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${GRAVITY_FI}")
error_validate

MESSAGE="Analyzing Local ${GRAVITY_FI}"
Expand Down Expand Up @@ -500,7 +500,7 @@ function config_generate {

echo -e "========================================================"
echo -e "========================================================"
ssh-copy-id -f -i $HOME/${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST}
ssh-copy-id -f -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST}
echo -e "========================================================"
echo -e "========================================================"
else
Expand Down

0 comments on commit 4d5f621

Please sign in to comment.