fix missing custom list detection

This commit is contained in:
Michael Stanclift 2020-08-18 09:51:38 -05:00
parent 4aa301f179
commit 8d7a61ca55

View File

@ -215,15 +215,7 @@ function pull_gs_cust {
if [ "$SKIP_CUSTOM" != '1' ] if [ "$SKIP_CUSTOM" != '1' ]
then then
if [ "$REMOTE_CUSTOM_DNS" == "1" ] if [ "$REMOTE_CUSTOM_DNS" == "1" ]
then then
# if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
# then
# MESSAGE="Backing Up ${CUSTOM_DNS} on $HOSTNAME"
# echo_stat
# cp ${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.backup >/dev/null 2>&1
# error_validate
# fi
MESSAGE="Pulling ${CUSTOM_DNS} from ${REMOTE_HOST}" MESSAGE="Pulling ${CUSTOM_DNS} from ${REMOTE_HOST}"
echo_stat echo_stat
RSYNC_REPATH="rsync" RSYNC_REPATH="rsync"
@ -501,40 +493,48 @@ function smart_gs {
SECCLCHANGE="1" SECCLCHANGE="1"
fi fi
if [ "${PRICLCHANGE}" == "${SECCLCHANGE}" ] if [ "$SKIP_CUSTOM" != '1' ]
then then
if [ "${PRICLCHANGE}" != "0" ]
if [ -f "${PIHOLE_DIR}/${CUSTOM_DNS}" ]
then then
MESSAGE="Both ${CUSTOM_DNS} Changed"
echo_warn
PRICLDATE=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "stat -c %Y ${PIHOLE_DIR}/${CUSTOM_DNS}") if [ "${PRICLCHANGE}" == "${SECCLCHANGE}" ]
SECCLDATE=$(stat -c %Y ${PIHOLE_DIR}/${CUSTOM_DNS}) then
if [ "${PRICLCHANGE}" != "0" ]
if [ "${PRICLDATE}" -gt "$SECCLDATE" ]
then then
MESSAGE="Primary ${CUSTOM_DNS} Last Changed" MESSAGE="Both ${CUSTOM_DNS} Changed"
echo_info echo_warn
PRICLDATE=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "stat -c %Y ${PIHOLE_DIR}/${CUSTOM_DNS}")
SECCLDATE=$(stat -c %Y ${PIHOLE_DIR}/${CUSTOM_DNS})
if [ "${PRICLDATE}" -gt "${SECCLDATE}" ]
then
MESSAGE="Primary ${CUSTOM_DNS} Last Changed"
echo_info
pull_gs_cust
PULLRESTART="1"
else
MESSAGE="Secondary ${CUSTOM_DNS} Last Changed"
echo_info
push_gs_cust
PUSHRESTART="1"
fi
fi
else
if [ "${PRICLCHANGE}" != "0" ]
then
pull_gs_cust pull_gs_cust
PULLRESTART="1" PULLRESTART="1"
else elif [ "${SECCLCHANGE}" != "0" ]
MESSAGE="Secondary ${CUSTOM_DNS} Last Changed" then
echo_info
push_gs_cust push_gs_cust
PUSHRESTART="1" PUSHRESTART="1"
fi fi
fi fi
else
if [ "${PRICLCHANGE}" != "0" ]
then
pull_gs_cust
PULLRESTART="1"
elif [ "${SECCLCHANGE}" != "0" ]
then
push_gs_cust
PUSHRESTART="1"
fi fi
fi fi