Automate update

This commit is contained in:
Michael Stanclift 2020-06-29 14:42:53 -05:00
parent 9abf85c3f7
commit 5cee345ee9
2 changed files with 18 additions and 25 deletions

View File

@ -1,5 +1,17 @@
# The Changelog
## 2.0
### The Smart Release
**Features**
For 2.0, the `push` and `pull` functions have been broken up for each component part (`gravity.db` and `custom.list`), and Gravity Sync will now detect not only if each component has changed since the last sync but also what direction they need to go.
Example: If the `gravity.db` has been modified on the primary Pi-hole, but the `custom.list` file has been changed on the secondary, Gravity Sync will now do a pull and a push of each part and then restart the correct components on each server.
This allows you to be more flexible in where you make your configuration changes to block/allow lists, but it's still suggested to identify a primary server to make these changes on. In the event there are configuration changes to the same element (`custom.list` changes at both sides) then the primary will still be the authoritative source and overwrite the secondary copy.
Existing users who want to use this new method as their standard should run `./gravity-sync.sh automate` function to replace the existing automated `pull` with the new Smart Sync.
## 1.8
### The Logical Release

View File

@ -402,41 +402,22 @@ function smart_gs {
last_primaryCLMD5=$(sed "3q;d" ${HISTORY_MD5})
last_secondCLMD5=$(sed "4q;d" ${HISTORY_MD5})
echo -e ${primaryDBMD5} " 1"
echo -e ${secondDBMD5} " 2"
echo -e ${primaryCLMD5} " 3"
echo -e ${secondCLMD5} " 4"
echo -e ${last_primaryDBMD5} " 5"
echo -e ${last_secondDBMD5} " 6"
echo -e ${last_primaryCLMD5} " 7"
echo -e ${last_secondCLMD5} " 8"
DB_SMARTPULL="0"
DB_SMARTPUSH="0"
CL_SMARTPULL="0"
CL_SMARTPUSH="0"
if [ "${primaryDBMD5}" != "${last_primaryDBMD5}" ]
then
echo "Primary DB has changed"
DB_SMARTPULL="1"
pull_gs_grav
elif [ "${secondDBMD5}" != "${last_secondDBMD5}" ]
then
echo "Secondary DB has changed"
DB_SMARTPUSH="1"
push_gs_grav
else
echo "No DB changes"
fi
if [ "${primaryCLMD5}" != "${last_primaryCLMD5}" ]
then
echo "Primary CL has changed"
CL_SMARTPULL="1"
pull_gs_cust
elif [ "${secondCLMD5}" != "${last_secondCLMD5}" ]
then
echo "Secondary CL has changed"
CL_SMARTPUSH="1"
push_gs_cust
else
echo "No CL changes"
fi
@ -1293,7 +1274,7 @@ function task_automate {
MESSAGE="Saving New Automation"
echo_stat
(crontab -l 2>/dev/null; echo "*/${INPUT_AUTO_FREQ} * * * * ${BASH_PATH} $HOME/${LOCAL_FOLDR}/${GS_FILENAME} pull > ${LOG_PATH}/${CRONJOB_LOG}") | crontab -
(crontab -l 2>/dev/null; echo "*/${INPUT_AUTO_FREQ} * * * * ${BASH_PATH} $HOME/${LOCAL_FOLDR}/${GS_FILENAME} > ${LOG_PATH}/${CRONJOB_LOG}") | crontab -
error_validate
fi
exit_withchange
@ -1305,7 +1286,7 @@ function clear_cron {
echo_stat
crontab -l > cronjob-old.tmp
sed '/.sh pull/d' cronjob-old.tmp > cronjob-new.tmp
sed '/${GS_FILENAME}/d' cronjob-old.tmp > cronjob-new.tmp
crontab cronjob-new.tmp 2>/dev/null
error_validate
rm cronjob-old.tmp