Rebuilt pull in new style

This commit is contained in:
Michael Stanclift 2020-05-23 18:26:12 -05:00
parent dfc892e77e
commit 75f2e5975b

View File

@ -77,19 +77,35 @@ function pull_gs {
MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}"
echo -e "${STAT} ${MESSAGE}"
rsync -v -e 'ssh -p 22' ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull
if_validate
echo -e "[${CYAN}STAT${NC}] Backing Up Current ${GRAVITY_FI} on $HOSTNAME"
error_validate
MESSAGE="Backing Up ${GRAVITY_FI} on $HOSTNAME"
echo -e "${STAT} ${MESSAGE}"
cp -v ${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.backup
echo -e "[${CYAN}STAT${NC}] Replacing ${GRAVITY_FI} on $HOSTNAME"
error_validate
MESSAGE="Replacing ${GRAVITY_FI} on $HOSTNAME"
echo -e "${STAT} ${MESSAGE}"
sudo cp -v $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI}
error_validate
MESSAGE="Setting Permissions on ${GRAVITY_FI}"
echo -e "${STAT} ${MESSAGE}"
sudo chmod 644 ${PIHOLE_DIR}/${GRAVITY_FI}
error_validate
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo -e "${STAT} ${MESSAGE}"
sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}
echo -e "${GRAVITY_FI} ownership and file permissions reset"
echo -e "[${CYAN}STAT${NC}] Reloading FTLDNS Configuration"
error_validate
MESSAGE="Reloading FTLDNS Configuration"
echo -e "${STAT} ${MESSAGE}"
pihole restartdns reloadlists
pihole restartdns
logs_export
error_validate
logs_export
exit_withchange
}
@ -210,8 +226,8 @@ function exit_withchange {
exit
}
function if_validate {
# Error Validation
function error_validate {
if [ "$?" != "0" ]; then
echo -e "${FAIL} ${MESSAGE}"
exit 1