gravity-sync/includes/gs-pull.sh

134 lines
3.4 KiB
Bash
Raw Normal View History

# GRAVITY SYNC BY VMSTAN #####################
# gs-pull.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!
## Pull Task
function task_pull {
TASKTYPE='PULL'
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${MESSAGE}: ${TASKTYPE}"
echo_good
2020-12-31 02:49:54 +00:00
show_target
validate_gs_folders
validate_ph_folders
if [ "${INCLUDE_CNAME}" == "1" ]
then
validate_dns_folders
fi
validate_sqlite3
validate_os_sshpass
2020-12-31 02:49:54 +00:00
pull_gs
exit
}
## Pull Gravity
function pull_gs_grav {
2020-12-31 02:49:54 +00:00
2020-12-31 02:45:47 +00:00
backup_local_gravity
backup_remote_gravity
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_PULL_PRIMARY} ${UI_GRAVITY_NAME}"
2020-12-31 02:45:47 +00:00
echo_stat
2020-12-31 02:49:54 +00:00
RSYNC_REPATH="rsync"
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/${GRAVITY_FI}.backup"
RSYNC_TARGET="${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull"
create_rsynccmd
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_REPLACE_SECONDARY} ${UI_GRAVITY_NAME}"
2020-12-31 02:49:54 +00:00
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
2020-12-31 02:45:47 +00:00
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
validate_gravity_permissions
}
## Pull Custom
function pull_gs_cust {
2020-12-31 02:45:47 +00:00
if [ "$SKIP_CUSTOM" != '1' ]
2020-12-31 02:49:54 +00:00
then
2020-12-31 02:45:47 +00:00
if [ "$REMOTE_CUSTOM_DNS" == "1" ]
then
backup_local_custom
backup_remote_custom
2020-12-31 02:49:54 +00:00
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_PULL_PRIMARY} ${UI_CUSTOM_NAME}"
2020-12-31 02:45:47 +00:00
echo_stat
2020-12-31 02:49:54 +00:00
RSYNC_REPATH="rsync"
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/${CUSTOM_DNS}.backup"
RSYNC_TARGET="${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull"
create_rsynccmd
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_REPLACE_SECONDARY} ${UI_CUSTOM_NAME}"
2020-12-31 02:49:54 +00:00
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
2020-12-31 02:45:47 +00:00
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
validate_custom_permissions
2020-12-31 02:45:47 +00:00
fi
fi
}
## Pull CNAME
function pull_gs_cname {
if [ "${INCLUDE_CNAME}" == '1' ]
then
if [ "$REMOTE_CNAME_DNS" == "1" ]
then
backup_local_cname
backup_remote_cname
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_PULL_PRIMARY} ${UI_CNAME_NAME}"
echo_stat
RSYNC_REPATH="rsync"
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/dnsmasq.d-${CNAME_CONF}.backup"
RSYNC_TARGET="${LOCAL_FOLDR}/${BACKUP_FOLD}/${CNAME_CONF}.pull"
create_rsynccmd
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_REPLACE_SECONDARY} ${UI_CNAME_NAME}"
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${CNAME_CONF}.pull ${DNSMAQ_DIR}/${CNAME_CONF} >/dev/null 2>&1
error_validate
validate_cname_permissions
fi
fi
}
## Pull Reload
function pull_gs_reload {
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_PULL_RELOAD_WAIT}"
2020-12-31 02:45:47 +00:00
echo_info
2020-12-31 02:49:54 +00:00
sleep 1
2020-12-31 02:45:47 +00:00
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_FTLDNS_CONFIG_UPDATE}"
2020-12-31 02:45:47 +00:00
echo_stat
2020-12-31 02:49:54 +00:00
${PH_EXEC} restartdns reloadlists >/dev/null 2>&1
error_validate
2020-12-31 02:45:47 +00:00
3.3.3 is 3.4.0 (#185) * new first line of script * no requested * Abort! * Test silent folder validation * sameline * echo newline * echo_sameline * what happened? * sameline for ssh * sqlite sameline * Lower case * Reset line * clear line * Flip the line * version update * Backup lowercase * More lowercase * Remove file names from standard messages * Breakout backup message * Output backup folder size * Just H * Invalid replication settings * Compare updated * Colors and updates * Lower case for version output * For Pihole * Cron cleanup * Sudo, or no sudo. * Branch! * Silent error validate * Silent error validate * Clearing up status messages * Records * Primary and secondary * Gravity database * Domain Database * Backup output cleanup * Move file permission validation into new functions * Change restart * UI variables test * Breakout UI variables into new file * Unified validation functions * Replace text strings with variables * Replace text strings with variables * Replace logging with variables * Convert backup to UI variables * Switch restore to UI variables * Fix bug where gravity database did not restore * App validation checks * Rev to 3.4.0 * Convert Push functions to new strings * Completing push UI changes * remove added line * Move purge to UI strings * Move automation to UI strings * Move core strings into UI * Exit strings * First pass at hashing UI * Escape the remote system query (#179) * hashing committed Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local> Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 20:16:20 +00:00
MESSAGE="${UI_FTLDNS_CONFIG_RELOAD}"
2020-12-31 02:45:47 +00:00
echo_stat
2020-12-31 02:49:54 +00:00
${PH_EXEC} restartdns >/dev/null 2>&1
error_validate
}
## Pull Function
function pull_gs {
2020-12-31 02:45:47 +00:00
previous_md5
md5_compare
backup_settime
pull_gs_grav
pull_gs_cust
pull_gs_cname
2020-12-31 02:45:47 +00:00
pull_gs_reload
md5_recheck
backup_cleanup
2020-12-31 02:45:47 +00:00
logs_export
exit_withchange
}