diff --git a/backup/BACKUP.md b/backup/BACKUP.md index a82e642..d2a627b 100644 --- a/backup/BACKUP.md +++ b/backup/BACKUP.md @@ -1 +1,2 @@ -Your backup files will be stored here. They will be ignored by any git updates. \ No newline at end of file +Your backup files will be stored here. +They will be ignored by any git updates. \ No newline at end of file diff --git a/gravity-sync.conf.example b/gravity-sync.conf.example index b949bf9..62c679e 100644 --- a/gravity-sync.conf.example +++ b/gravity-sync.conf.example @@ -6,7 +6,7 @@ REMOTE_HOST='192.168.1.10' # User account on primary with SUDO rights REMOTE_USER='pi' -# OPTIONAL SETTING ####################### +# OPTIONAL SETTINGS ###################### # Password for REMOTE_USER account # Requires 'SSHPASS' installed on server @@ -14,4 +14,15 @@ REMOTE_USER='pi' # Less secure and possibly less reliable # Leave blank to use (preferred) key-pair -REMOTE_PASS='' \ No newline at end of file +REMOTE_PASS='' + +# ADVANCED SETTINGS ###################### + +# Uncomment and set for auxillary control +# Overrides gravity-sync.sh defaults + +# SSH_PORT='' +# SSH_PKIF='' +# LOG_PATH='' +# SYNCING_LOG='' +# CRONJOB_LOG='' \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index 59d4631..05d34b0 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -2,7 +2,7 @@ # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='1.4.0' +VERSION='1.4.1' # Execute from the home folder of the user who own's it (ex: 'cd ~/gravity-sync') # For documentation or download updates visit https://github.com/vmstan/gravity-sync @@ -15,11 +15,14 @@ VERSION='1.4.0' # GS Folder/File Locations LOCAL_FOLDR='gravity-sync' # must exist in running user home folder -CONFIG_FILE='gravity-sync.conf' # must exist as explained above -SYNCING_LOG='gravity-sync.log' # will be created in above folder -CRONJOB_LOG='gravity-sync.cron' # only used if cron is configured to output to this file +CONFIG_FILE='gravity-sync.conf' # must exist with primary host/user configured BACKUP_FOLD='backup' # must exist as subdirectory in LOCAL_FOLDR +# Logging Folder/File Locations +LOG_PATH="$HOME/${LOCAL_FOLDR}" # replace in gravity-sync.conf to overwrite +SYNCING_LOG='gravity-sync.log' # replace in gravity-sync.conf to overwrite +CRONJOB_LOG='gravity-sync.cron' # replace in gravity-sync.conf to overwrite + # PH Folder/File Locations PIHOLE_DIR='/etc/pihole' # default PH data directory GRAVITY_FI='gravity.db' # default PH database file @@ -249,19 +252,19 @@ function push_gs { ### Write Logs Out function logs_export { echo -e "${INFO} Logging Timestamps to ${SYNCING_LOG}" - # date >> $HOME/${LOCAL_FOLDR}/${SYNCING_LOG} - echo -e $(date) "[${TASKTYPE}]" >> $HOME/${LOCAL_FOLDR}/${SYNCING_LOG} + echo -e $(date) "[${TASKTYPE}]" >> ${LOG_PATH}/${SYNCING_LOG} } ### Output Sync Logs function logs_gs { + import_gs + + echo -e "${INFO} Tailing ${LOG_PATH}/${SYNCING_LOG}" echo -e "========================================================" echo -e "Recent Complete ${YELLOW}PULL${NC} Executions" - tail -n 10 ${SYNCING_LOG} | grep PULL - #echo -e "Recent Complete ${YELLOW}UPDATE${NC} Executions" - # tail -n 10 ${SYNCING_LOG} | grep UPDATE + tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PULL echo -e "Recent Complete ${YELLOW}PUSH${NC} Executions" - tail -n 10 ${SYNCING_LOG} | grep PUSH + tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PUSH echo -e "========================================================" exit_nochange } @@ -269,40 +272,34 @@ function logs_gs { ## Crontab Logs ### Core Crontab Logs function show_crontab { - CRONPATH="$HOME/${LOCAL_FOLDR}/${CRONJOB_LOG}" + import_gs MESSAGE="Replaying Last Cronjob" echo -en "${STAT} ${MESSAGE}" - if [ -f ${CRONPATH} ] + if [ -f ${LOG_PATH}/${CRONJOB_LOG} ] then - if [ -s ${CRONPATH} ] + if [ -s ${LOG_PATH}/${CRONJOB_LOG} ] echo -e "\r${GOOD} ${MESSAGE}" - logs_crontab + + echo -e "${INFO} Tailing ${LOG_PATH}/${CRONJOB_LOG}" + echo -e "========================================================" + date -r ${LOG_PATH}/${CRONJOB_LOG} + cat ${LOG_PATH}/${CRONJOB_LOG} + echo -e "========================================================" exit_nochange then echo -e "\r${FAIL} ${MESSAGE}" - echo -e "${INFO} ${CRONPATH} appears empty" + echo -e "${INFO} ${LOG_PATH}/${CRONJOB_LOG} appears empty" exit_nochange fi else echo -e "\r${FAIL} ${MESSAGE}" - echo -e "${INFO} ${CRONPATH} cannot be located" + echo -e "${INFO} ${LOG_PATH}/${CRONJOB_LOG} cannot be located" exit_nochange fi } -### Output Crontab -function logs_crontab { - echo -e "========================================================" - echo -e "========================================================" - echo -e "" - cat ${CRONJOB_LOG} - echo -e "" - echo -e "========================================================" - echo -e "========================================================" -} - # Validate Functions ## Validate GS Folders function validate_gs_folders {