mirror of
https://github.com/vmstan/gravity-sync.git
synced 2024-08-30 18:22:11 +00:00
Add custom.list bypass to pull function
This commit is contained in:
parent
a6e3fd89a5
commit
810e28aa0e
@ -27,5 +27,5 @@ REMOTE_PASS=''
|
|||||||
# SYNCING_LOG=''
|
# SYNCING_LOG=''
|
||||||
# CRONJOB_LOG=''
|
# CRONJOB_LOG=''
|
||||||
|
|
||||||
# VERIFY_PASS='' # 0=Verify 1=Bypass
|
# VERIFY_PASS='' # 0=Verify 1=Bypass
|
||||||
# SKIP_CUSTOM='' # 0=Syncit 1=Skip
|
# SKIP_CUSTOM='' # 0=Syncit 1=Skip
|
169
gravity-sync.sh
169
gravity-sync.sh
@ -174,63 +174,65 @@ function pull_gs {
|
|||||||
sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
|
sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
|
||||||
error_validate
|
error_validate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $REMOTE_CUSTOM_DNS == "1" ]
|
|
||||||
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
|
|
||||||
|
|
||||||
MESSAGE="Pulling ${CUSTOM_DNS} from ${REMOTE_HOST}"
|
|
||||||
echo_stat
|
|
||||||
${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull >/dev/null 2>&1
|
|
||||||
error_validate
|
|
||||||
|
|
||||||
MESSAGE="Replacing ${CUSTOM_DNS} on $HOSTNAME"
|
|
||||||
echo_stat
|
|
||||||
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
|
||||||
error_validate
|
|
||||||
|
|
||||||
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
|
|
||||||
echo_stat
|
|
||||||
|
|
||||||
CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}')
|
|
||||||
if [ $CUSTOMLS_OWN == "rootroot" ]
|
|
||||||
then
|
|
||||||
echo_good
|
|
||||||
else
|
|
||||||
echo_fail
|
|
||||||
|
|
||||||
MESSAGE="Attempting to Compensate"
|
|
||||||
echo_info
|
|
||||||
|
|
||||||
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
|
|
||||||
echo_stat
|
|
||||||
sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
|
||||||
error_validate
|
|
||||||
fi
|
|
||||||
|
|
||||||
MESSAGE="Validating Permissions on ${CUSTOM_DNS}"
|
|
||||||
echo_stat
|
|
||||||
|
|
||||||
GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}')
|
|
||||||
if [ $CUSTOMLS_RWE = "-rw-r--r--" ]
|
|
||||||
then
|
|
||||||
echo_good
|
|
||||||
else
|
|
||||||
echo_fail
|
|
||||||
|
|
||||||
MESSAGE="Attempting to Compensate"
|
|
||||||
echo_info
|
|
||||||
|
|
||||||
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
|
|
||||||
echo_stat
|
|
||||||
sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
|
||||||
error_validate
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ "$SKIP_CUSTOM" != '1' ]
|
||||||
|
then
|
||||||
|
if [ $REMOTE_CUSTOM_DNS == "1" ]
|
||||||
|
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
|
||||||
|
|
||||||
|
MESSAGE="Pulling ${CUSTOM_DNS} from ${REMOTE_HOST}"
|
||||||
|
echo_stat
|
||||||
|
${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
|
||||||
|
MESSAGE="Replacing ${CUSTOM_DNS} on $HOSTNAME"
|
||||||
|
echo_stat
|
||||||
|
sudo cp $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
|
||||||
|
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
|
||||||
|
echo_stat
|
||||||
|
|
||||||
|
CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}')
|
||||||
|
if [ $CUSTOMLS_OWN == "rootroot" ]
|
||||||
|
then
|
||||||
|
echo_good
|
||||||
|
else
|
||||||
|
echo_fail
|
||||||
|
|
||||||
|
MESSAGE="Attempting to Compensate"
|
||||||
|
echo_info
|
||||||
|
|
||||||
|
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
|
||||||
|
echo_stat
|
||||||
|
sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
|
||||||
|
MESSAGE="Validating Permissions on ${CUSTOM_DNS}"
|
||||||
|
echo_stat
|
||||||
|
|
||||||
|
GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}')
|
||||||
|
if [ $CUSTOMLS_RWE = "-rw-r--r--" ]
|
||||||
|
then
|
||||||
|
echo_good
|
||||||
|
else
|
||||||
|
echo_fail
|
||||||
|
|
||||||
|
MESSAGE="Attempting to Compensate"
|
||||||
|
echo_info
|
||||||
|
|
||||||
|
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
|
||||||
|
echo_stat
|
||||||
|
sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
|
||||||
|
error_validate
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
MESSAGE="Inverting Tachyon Pulse"
|
MESSAGE="Inverting Tachyon Pulse"
|
||||||
echo_info
|
echo_info
|
||||||
@ -538,42 +540,45 @@ function md5_compare {
|
|||||||
HASHMARK=$((HASHMARK+1))
|
HASHMARK=$((HASHMARK+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
|
if [ "$SKIP_CUSTOM" != '1' ]
|
||||||
then
|
then
|
||||||
MESSAGE="Comparing ${CUSTOM_DNS} Changes"
|
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
|
||||||
echo_info
|
|
||||||
|
|
||||||
if ${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} test -e ${PIHOLE_DIR}/${CUSTOM_DNS}
|
|
||||||
then
|
then
|
||||||
REMOTE_CUSTOM_DNS="1"
|
MESSAGE="Comparing ${CUSTOM_DNS} Changes"
|
||||||
MESSAGE="Analyzing Remote ${CUSTOM_DNS}"
|
echo_info
|
||||||
echo_stat
|
|
||||||
|
|
||||||
primaryCLMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${CUSTOM_DNS}")
|
|
||||||
error_validate
|
|
||||||
|
|
||||||
MESSAGE="Analyzing Local ${CUSTOM_DNS}"
|
if ${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} test -e ${PIHOLE_DIR}/${CUSTOM_DNS}
|
||||||
echo_stat
|
|
||||||
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS})
|
|
||||||
error_validate
|
|
||||||
|
|
||||||
if [ "$primaryCLMD5" == "$secondCLMD5" ]
|
|
||||||
then
|
then
|
||||||
MESSAGE="No Differences in ${CUSTOM_DNS}"
|
REMOTE_CUSTOM_DNS="1"
|
||||||
echo_info
|
MESSAGE="Analyzing Remote ${CUSTOM_DNS}"
|
||||||
HASHMARK=$((HASHMARK+0))
|
echo_stat
|
||||||
|
|
||||||
|
primaryCLMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${PIHOLE_DIR}/${CUSTOM_DNS}")
|
||||||
|
error_validate
|
||||||
|
|
||||||
|
MESSAGE="Analyzing Local ${CUSTOM_DNS}"
|
||||||
|
echo_stat
|
||||||
|
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS})
|
||||||
|
error_validate
|
||||||
|
|
||||||
|
if [ "$primaryCLMD5" == "$secondCLMD5" ]
|
||||||
|
then
|
||||||
|
MESSAGE="No Differences in ${CUSTOM_DNS}"
|
||||||
|
echo_info
|
||||||
|
HASHMARK=$((HASHMARK+0))
|
||||||
|
else
|
||||||
|
MESSAGE="Changes Detected in ${CUSTOM_DNS}"
|
||||||
|
echo_info
|
||||||
|
HASHMARK=$((HASHMARK+1))
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
MESSAGE="Changes Detected in ${CUSTOM_DNS}"
|
MESSAGE="No Remote ${CUSTOM_DNS} Detected"
|
||||||
echo_info
|
echo_info
|
||||||
HASHMARK=$((HASHMARK+1))
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
MESSAGE="No Remote ${CUSTOM_DNS} Detected"
|
MESSAGE="No Local ${CUSTOM_DNS} Detected"
|
||||||
echo_info
|
echo_info
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
MESSAGE="No Local ${CUSTOM_DNS} Detected"
|
|
||||||
echo_info
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$HASHMARK" != "0" ]
|
if [ "$HASHMARK" != "0" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user