Merge pull request #60 from vmstan/development

2.1.5 beta
This commit is contained in:
Michael Stanclift 2020-07-11 21:17:16 -05:00 committed by GitHub
commit f2dacc1581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 36 deletions

View File

@ -28,6 +28,9 @@ The `./gravity-sync.sh update` and `version` functions will look for the `dbclie
#### 2.1.5 #### 2.1.5
Skipping a few digits because what does it really matter? Skipping a few digits because what does it really matter?
- Implements a new beta branch, and with it a new `./gravity-sync.sh beta` function to enable it. This will hopefully allow new features and such to be added for test users who can adopt them and provide feedback before rolling out to the main update branch.
- Uses new SQLITE3 backup methodology introduced in 2.1, for all push/pull sync operations.
## 2.0 ## 2.0
### The Smart Release ### The Smart Release

View File

@ -108,6 +108,9 @@ function update_gs {
if [ -f "$HOME/${LOCAL_FOLDR}/dev" ] if [ -f "$HOME/${LOCAL_FOLDR}/dev" ]
then then
BRANCH='development' BRANCH='development'
elif [ -f "$HOME/${LOCAL_FOLDR}/beta" ]
then
BRANCH='beta'
else else
BRANCH='master' BRANCH='master'
fi fi
@ -299,12 +302,14 @@ function pull_gs_reload {
## Pull Function ## Pull Function
function pull_gs { function pull_gs {
previous_md5
md5_compare md5_compare
backup_settime backup_settime
pull_gs_grav pull_gs_grav
pull_gs_cust pull_gs_cust
pull_gs_reload pull_gs_reload
md5_recheck
logs_export logs_export
exit_withchange exit_withchange
@ -401,7 +406,9 @@ function push_gs_reload {
## Push Function ## Push Function
function push_gs { function push_gs {
previous_md5
md5_compare md5_compare
backup_settime
intent_validate intent_validate
@ -409,15 +416,12 @@ function push_gs {
push_gs_cust push_gs_cust
push_gs_reload push_gs_reload
md5_recheck
logs_export logs_export
exit_withchange exit_withchange
} }
## Smart Sync Function function previous_md5 {
function smart_gs {
md5_compare
backup_settime
if [ -f "${LOG_PATH}/${HISTORY_MD5}" ] if [ -f "${LOG_PATH}/${HISTORY_MD5}" ]
then then
last_primaryDBMD5=$(sed "1q;d" ${LOG_PATH}/${HISTORY_MD5}) last_primaryDBMD5=$(sed "1q;d" ${LOG_PATH}/${HISTORY_MD5})
@ -430,6 +434,13 @@ function smart_gs {
last_primaryCLMD5="0" last_primaryCLMD5="0"
last_secondCLMD5="0" last_secondCLMD5="0"
fi fi
}
## Smart Sync Function
function smart_gs {
previous_md5
md5_compare
backup_settime
PRIDBCHANGE="0" PRIDBCHANGE="0"
SECDBCHANGE="0" SECDBCHANGE="0"
@ -1115,6 +1126,11 @@ function error_validate {
## Validate Sync Required ## Validate Sync Required
function md5_compare { function md5_compare {
# last_primaryDBMD5="0"
# last_secondDBMD5="0"
# last_primaryCLMD5="0"
# last_secondCLMD5="0"
HASHMARK='0' HASHMARK='0'
MESSAGE="Analyzing ${GRAVITY_FI} on ${REMOTE_HOST}" MESSAGE="Analyzing ${GRAVITY_FI} on ${REMOTE_HOST}"
@ -1127,7 +1143,7 @@ function md5_compare {
secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//') secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//')
error_validate error_validate
if [ "$primaryDBMD5" == "$secondDBMD5" ] if [ "$primaryDBMD5" == "$last_primaryDBMD5" ] && [ "$secondDBMD5" == "$last_secondDBMD5" ]
then then
HASHMARK=$((HASHMARK+0)) HASHMARK=$((HASHMARK+0))
else else
@ -1154,7 +1170,7 @@ function md5_compare {
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//') secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//')
error_validate error_validate
if [ "$primaryCLMD5" == "$secondCLMD5" ] if [ "$primaryCLMD5" == "$last_primaryCLMD5" ] && [ "$secondCLMD5" == "$last_secondCLMD5" ]
then then
# MESSAGE="${CUSTOM_DNS} Identical" # MESSAGE="${CUSTOM_DNS} Identical"
# echo_info # echo_info
@ -1209,14 +1225,14 @@ function md5_recheck {
secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//') secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//')
error_validate error_validate
if [ "$primaryDBMD5" == "$secondDBMD5" ] # if [ "$primaryDBMD5" == "$secondDBMD5" ]
then # then
HASHMARK=$((HASHMARK+0)) # HASHMARK=$((HASHMARK+0))
else # else
MESSAGE="Differenced ${GRAVITY_FI} Detected" # MESSAGE="Differenced ${GRAVITY_FI} Detected"
echo_warn # echo_warn
HASHMARK=$((HASHMARK+1)) # HASHMARK=$((HASHMARK+1))
fi # fi
if [ "$SKIP_CUSTOM" != '1' ] if [ "$SKIP_CUSTOM" != '1' ]
then then
@ -1236,16 +1252,16 @@ function md5_recheck {
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//') secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//')
error_validate error_validate
if [ "$primaryCLMD5" == "$secondCLMD5" ] # if [ "$primaryCLMD5" == "$secondCLMD5" ]
then # then
# MESSAGE="${CUSTOM_DNS} Identical" # MESSAGE="${CUSTOM_DNS} Identical"
# echo_info # echo_info
HASHMARK=$((HASHMARK+0)) # HASHMARK=$((HASHMARK+0))
else # else
MESSAGE="Differenced ${CUSTOM_DNS} Detected" # MESSAGE="Differenced ${CUSTOM_DNS} Detected"
echo_warn # echo_warn
HASHMARK=$((HASHMARK+1)) # HASHMARK=$((HASHMARK+1))
fi # fi
else else
MESSAGE="No ${CUSTOM_DNS} Detected on ${REMOTE_HOST}" MESSAGE="No ${CUSTOM_DNS} Detected on ${REMOTE_HOST}"
echo_info echo_info
@ -1255,7 +1271,7 @@ function md5_recheck {
then then
REMOTE_CUSTOM_DNS="1" REMOTE_CUSTOM_DNS="1"
MESSAGE="${REMOTE_HOST} has ${CUSTOM_DNS}" MESSAGE="${REMOTE_HOST} has ${CUSTOM_DNS}"
HASHMARK=$((HASHMARK+1)) # HASHMARK=$((HASHMARK+1))
echo_info echo_info
fi fi
MESSAGE="No ${CUSTOM_DNS} Detected on $HOSTNAME" MESSAGE="No ${CUSTOM_DNS} Detected on $HOSTNAME"
@ -1263,14 +1279,14 @@ function md5_recheck {
fi fi
fi fi
if [ "$HASHMARK" != "0" ] # if [ "$HASHMARK" != "0" ]
then # then
MESSAGE="Replication Checks Failed" # MESSAGE="Replication Checks Failed"
echo_warn # echo_warn
else # else
MESSAGE="Replication Was Successful" # MESSAGE="Replication Was Successful"
echo_info # echo_info
fi # fi
} }
## Validate Intent ## Validate Intent
@ -1479,6 +1495,9 @@ function show_version {
if [ -f $HOME/${LOCAL_FOLDR}/dev ] if [ -f $HOME/${LOCAL_FOLDR}/dev ]
then then
DEVVERSION="dev" DEVVERSION="dev"
elif [ -f $HOME/${LOCAL_FOLDR}/beta ]
then
DEVVERSION="beta"
else else
DEVVERSION="" DEVVERSION=""
fi fi
@ -1500,8 +1519,6 @@ function show_version {
fi fi
echo_info echo_info
echo -e "========================================================" echo -e "========================================================"
dbclient_warning
} }
function dbclient_warning { function dbclient_warning {
@ -1634,6 +1651,17 @@ function task_devmode {
echo_stat echo_stat
rm -f $HOME/${LOCAL_FOLDR}/dev rm -f $HOME/${LOCAL_FOLDR}/dev
error_validate error_validate
elif [ -f $HOME/${LOCAL_FOLDR}/beta ]
then
MESSAGE="Disabling BETA"
echo_stat
rm -f $HOME/${LOCAL_FOLDR}/beta
error_validate
MESSAGE="Enabling ${TASKTYPE}"
echo_stat
touch $HOME/${LOCAL_FOLDR}/dev
error_validate
else else
MESSAGE="Enabling ${TASKTYPE}" MESSAGE="Enabling ${TASKTYPE}"
echo_stat echo_stat
@ -1647,6 +1675,42 @@ function task_devmode {
exit_withchange exit_withchange
} }
## Devmode Task
function task_betamode {
TASKTYPE='BETA'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
if [ -f $HOME/${LOCAL_FOLDR}/beta ]
then
MESSAGE="Disabling ${TASKTYPE}"
echo_stat
rm -f $HOME/${LOCAL_FOLDR}/beta
error_validate
elif [ -f $HOME/${LOCAL_FOLDR}/dev ]
then
MESSAGE="Disabling DEV"
echo_stat
rm -f $HOME/${LOCAL_FOLDR}/dev
error_validate
MESSAGE="Enabling ${TASKTYPE}"
echo_stat
touch $HOME/${LOCAL_FOLDR}/beta
error_validate
else
MESSAGE="Enabling ${TASKTYPE}"
echo_stat
touch $HOME/${LOCAL_FOLDR}/beta
error_validate
fi
MESSAGE="Run UPDATE to apply changes"
echo_info
exit_withchange
}
## Update Task ## Update Task
function task_update { function task_update {
TASKTYPE='UPDATE' TASKTYPE='UPDATE'
@ -1688,6 +1752,7 @@ function task_compare {
validate_ph_folders validate_ph_folders
validate_os_sshpass validate_os_sshpass
previous_md5
md5_compare md5_compare
} }
@ -1763,7 +1828,7 @@ function backup_remote_custom {
echo_stat echo_stat
CMD_TIMEOUT='15' CMD_TIMEOUT='15'
CMD_REQUESTED="sudo cp ${PIHOLE_DIR}/${CUSTOM_DNS} ${PIHOLE_DIR}/${CUSTOM_DNS}.backup'\"" CMD_REQUESTED="sudo cp ${PIHOLE_DIR}/${CUSTOM_DNS} ${PIHOLE_DIR}/${CUSTOM_DNS}.backup"
create_sshcmd create_sshcmd
fi fi
fi fi
@ -1936,6 +2001,10 @@ case $# in
task_devmode task_devmode
;; ;;
beta)
task_betamode
;;
devmode) devmode)
task_devmode task_devmode
;; ;;