mirror of
https://github.com/vmstan/gravity-sync.git
synced 2024-08-30 18:22:11 +00:00
9dae851a9c
* first! * folders * break out colors * home * seperate update * breakout pull * move file * breakout push * breakout smart * restore breakout * include restore * breakout logs validate ssh * breakout config exit intent * source exit * breakout backup automation and purge * breakout root * file headers * create push pull restore smart functions * consolidate options * include root check * includes * includes 2 * automate * rearrange imports * header * ssh rsync * new install steps * ticks * yellow * host check * check for git * ticks * check for pihole * check sudo powers * create sudo file * write output * pihole directory * install sudo file * purge error message * comment cleanup * installer * header * instructions * l * read p * header * skip prompts * sudo no longer in config * compare exit code * exit with change * 3.0 Co-authored-by: Michael Stanclift <vmstan@Sovereign.vmstan.net> Co-authored-by: Michael Stanclift <vmstan@Sovereign.local>
95 lines
2.4 KiB
Bash
95 lines
2.4 KiB
Bash
# GRAVITY SYNC BY VMSTAN #####################
|
|
# gs-logging.sh ##############################
|
|
|
|
# For documentation or downloading updates visit https://github.com/vmstan/gravity-sync
|
|
# This code is called from the main gravity-sync.sh file and should not execute directly!
|
|
|
|
## Logs Task
|
|
function task_logs {
|
|
TASKTYPE='LOGS'
|
|
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
|
|
echo_good
|
|
|
|
logs_gs
|
|
}
|
|
|
|
## Core Logging
|
|
### Write Logs Out
|
|
function logs_export {
|
|
if [ "${TASKTYPE}" != "BACKUP" ]
|
|
then
|
|
MESSAGE="Saving File Hashes"
|
|
echo_stat
|
|
rm -f ${LOG_PATH}/${HISTORY_MD5}
|
|
echo -e ${primaryDBMD5} >> ${LOG_PATH}/${HISTORY_MD5}
|
|
echo -e ${secondDBMD5} >> ${LOG_PATH}/${HISTORY_MD5}
|
|
echo -e ${primaryCLMD5} >> ${LOG_PATH}/${HISTORY_MD5}
|
|
echo -e ${secondCLMD5} >> ${LOG_PATH}/${HISTORY_MD5}
|
|
error_validate
|
|
fi
|
|
|
|
MESSAGE="Logging Successful ${TASKTYPE}"
|
|
echo_stat
|
|
echo -e $(date) "[${TASKTYPE}]" >> ${LOG_PATH}/${SYNCING_LOG}
|
|
error_validate
|
|
}
|
|
|
|
### Output Sync Logs
|
|
function logs_gs {
|
|
MESSAGE="Tailing ${LOG_PATH}/${SYNCING_LOG}"
|
|
echo_info
|
|
|
|
echo -e "========================================================"
|
|
echo -e "Recent Complete ${YELLOW}SMART${NC} Executions"
|
|
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep SMART
|
|
echo -e "Recent Complete ${YELLOW}PULL${NC} Executions"
|
|
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PULL
|
|
echo -e "Recent Complete ${YELLOW}PUSH${NC} Executions"
|
|
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PUSH
|
|
echo -e "Recent Complete ${YELLOW}BACKUP${NC} Executions"
|
|
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep BACKUP
|
|
echo -e "Recent Complete ${YELLOW}RESTORE${NC} Executions"
|
|
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep RESTORE
|
|
echo -e "========================================================"
|
|
|
|
exit_nochange
|
|
}
|
|
|
|
## Crontab Logs
|
|
### Core Crontab Logs
|
|
function show_crontab {
|
|
MESSAGE="Replaying Last Cronjob"
|
|
echo_stat
|
|
|
|
if [ -f ${LOG_PATH}/${CRONJOB_LOG} ]
|
|
then
|
|
if [ -s ${LOG_PATH}/${CRONJOB_LOG} ]
|
|
echo_good
|
|
|
|
MESSAGE="Tailing ${LOG_PATH}/${CRONJOB_LOG}"
|
|
echo_info
|
|
|
|
echo -e "========================================================"
|
|
date -r ${LOG_PATH}/${CRONJOB_LOG}
|
|
cat ${LOG_PATH}/${CRONJOB_LOG}
|
|
echo -e "========================================================"
|
|
|
|
exit_nochange
|
|
then
|
|
echo_fail
|
|
|
|
MESSAGE="${LOG_PATH}/${CRONJOB_LOG} is Empty"
|
|
echo_info
|
|
|
|
exit_nochange
|
|
fi
|
|
else
|
|
echo_fail
|
|
|
|
MESSAGE="${LOG_PATH}/${CRONJOB_LOG} is Missing"
|
|
echo_info
|
|
|
|
exit_nochange
|
|
fi
|
|
}
|