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 #13 from vmstan/development
Browse files Browse the repository at this point in the history
v1.3.4
  • Loading branch information
vmstan authored May 26, 2020
2 parents 4497b40 + c7eeabb commit 314cb67
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 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.3.3.zip
unzip v1.3.3.zip
mv ~/gravity-sync-1.3.3 ~/gravity-sync
wget https://github.com/vmstan/gravity-sync/archive/v1.3.4.zip
unzip v1.3.4.zip
mv ~/gravity-sync-1.3.4 ~/gravity-sync
cd gravity-sync
```

Expand Down
72 changes: 51 additions & 21 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.3.3'
VERSION='1.3.4'

# Must execute from a location in the home folder of the user who own's it (ex: /home/pi/gravity-sync)
# Configure certificate based SSH authentication between the Pi-hole HA nodes - it does not use passwords
Expand Down Expand Up @@ -106,34 +106,64 @@ function pull_gs {
echo -e "${INFO} ${TASKTYPE} Requested"
md5_compare

MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}"
echo -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} rsync -v -e 'ssh -p 22' ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1
error_validate
echo -e "${INFO} ${TASKTYPE} Commencing"

MESSAGE="Backing Up ${GRAVITY_FI} on $HOSTNAME"
echo -en "${STAT} ${MESSAGE}"
cp -v ${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.backup >/dev/null 2>&1
cp ${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.backup >/dev/null 2>&1
error_validate

MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}"
echo -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} rsync -e 'ssh -p 22' ${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 -en "${STAT} ${MESSAGE}"
sudo cp -v $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate

MESSAGE="Setting Permissions on ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"
sudo chmod 644 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
MESSAGE="Validating Ownership on ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"

MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"
sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk '{print $3 $4}')
if [ $GRAVDB_OWN == "piholepihole" ]
then
echo -e "\r${GOOD} ${MESSAGE}"
else
echo -e "\r${FAIL} $MESSAGE"

MESSAGE2="Attempting to Compensate"
echo -e "${INFO} ${MESSAGE2}"

MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"
sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi

MESSAGE="Validating Permissions on ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"

GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}')
if [ $GRAVDB_RWE = "-rw-r--r--" ]
then
echo -e "\r${GOOD} ${MESSAGE}"
else
echo -e "\r${FAIL} ${MESSAGE}"

MESSAGE2="Attempting to Compensate"
echo -e "${INFO} ${MESSAGE2}"

MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo -en "${STAT} ${MESSAGE}"
sudo chmod 644 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi

MESSAGE="Pausing One Second"
MESSAGE="Inverting Tachyon Pulse"
echo -e "${INFO} ${MESSAGE}"
sleep 1
sleep 1

MESSAGE="Updating FTLDNS Configuration"
echo -en "${STAT} ${MESSAGE}"
Expand Down Expand Up @@ -163,12 +193,12 @@ function push_gs {

MESSAGE="Backing Up ${GRAVITY_FI} from ${REMOTE_HOST}"
echo -en "${STAT} ${MESSAGE}"
${SSHPASSWORD} rsync -v -e 'ssh -p 22' ${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 22' ${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" -v -e 'ssh -p 22' ${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 22' ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate

MESSAGE="Setting Permissions on ${GRAVITY_FI}"
Expand All @@ -181,9 +211,9 @@ function push_gs {
${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1
error_validate

MESSAGE="Pausing One Second"
MESSAGE="Contacting Borg Collective"
echo -e "${INFO} ${MESSAGE}"
sleep 1
sleep 1

MESSAGE="Updating FTLDNS Configuration"
echo -en "${STAT} ${MESSAGE}"
Expand Down

0 comments on commit 314cb67

Please sign in to comment.