Testing command validation

This commit is contained in:
Michael Stanclift 2020-05-23 17:39:02 -05:00
parent 20963f2f71
commit f2e235c88d

View File

@ -69,6 +69,7 @@ function pull_gs {
TASKTYPE='PULL' TASKTYPE='PULL'
echo -e "[${CYAN}STAT${NC}] Pulling ${GRAVITY_FI} from ${REMOTE_HOST}" echo -e "[${CYAN}STAT${NC}] Pulling ${GRAVITY_FI} from ${REMOTE_HOST}"
rsync -v -e 'ssh -p 22' ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull 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" echo -e "[${CYAN}STAT${NC}] Backing Up Current ${GRAVITY_FI} on $HOSTNAME"
cp -v ${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.backup cp -v ${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.backup
echo -e "[${CYAN}STAT${NC}] Replacing ${GRAVITY_FI} on $HOSTNAME" echo -e "[${CYAN}STAT${NC}] Replacing ${GRAVITY_FI} on $HOSTNAME"
@ -200,6 +201,13 @@ function exit_withchange {
exit exit
} }
function if_validate {
if [ "$?" != "0" ]; then
echo "[${RED}FAIL${NC}] Previous Command Failed"
exit 1
fi
}
# SCRIPT EXECUTION ########################### # SCRIPT EXECUTION ###########################
echo -e "[${CYAN}STAT${NC}] Evaluating Script Arguments" echo -e "[${CYAN}STAT${NC}] Evaluating Script Arguments"