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>
127 lines
3.1 KiB
Bash
127 lines
3.1 KiB
Bash
# GRAVITY SYNC BY VMSTAN #####################
|
|
# gs-push.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!
|
|
|
|
## Push Task
|
|
function task_push {
|
|
TASKTYPE='PUSH'
|
|
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
|
|
echo_good
|
|
|
|
show_target
|
|
validate_gs_folders
|
|
validate_ph_folders
|
|
validate_sqlite3
|
|
validate_os_sshpass
|
|
|
|
push_gs
|
|
exit
|
|
}
|
|
|
|
## Push Gravity
|
|
function push_gs_grav {
|
|
backup_remote_gravity
|
|
backup_local_gravity
|
|
|
|
MESSAGE="Copying ${GRAVITY_FI} from ${REMOTE_HOST}"
|
|
echo_stat
|
|
RSYNC_REPATH="rsync"
|
|
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}.backup"
|
|
RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push"
|
|
create_rsynccmd
|
|
|
|
MESSAGE="Pushing ${GRAVITY_FI} to ${REMOTE_HOST}"
|
|
echo_stat
|
|
RSYNC_REPATH="sudo rsync"
|
|
RSYNC_SOURCE="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${GRAVITY_FI}.backup"
|
|
RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI}"
|
|
create_rsynccmd
|
|
|
|
MESSAGE="Setting Permissions on ${GRAVITY_FI}"
|
|
echo_stat
|
|
CMD_TIMEOUT='15'
|
|
CMD_REQUESTED="sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}"
|
|
create_sshcmd
|
|
|
|
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
|
|
echo_stat
|
|
CMD_TIMEOUT='15'
|
|
CMD_REQUESTED="sudo chown ${RFILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI}"
|
|
create_sshcmd
|
|
}
|
|
|
|
## Push Custom
|
|
function push_gs_cust {
|
|
if [ "$SKIP_CUSTOM" != '1' ]
|
|
then
|
|
if [ "$REMOTE_CUSTOM_DNS" == "1" ]
|
|
then
|
|
backup_remote_custom
|
|
backup_local_custom
|
|
|
|
MESSAGE="Copying ${CUSTOM_DNS} from ${REMOTE_HOST}"
|
|
echo_stat
|
|
RSYNC_REPATH="rsync"
|
|
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}.backup"
|
|
RSYNC_TARGET="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push"
|
|
create_rsynccmd
|
|
|
|
MESSAGE="Pushing ${CUSTOM_DNS} to ${REMOTE_HOST}"
|
|
echo_stat
|
|
RSYNC_REPATH="sudo rsync"
|
|
RSYNC_SOURCE="$HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${CUSTOM_DNS}.backup"
|
|
RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${CUSTOM_DNS}"
|
|
create_rsynccmd
|
|
|
|
MESSAGE="Setting Permissions on ${CUSTOM_DNS}"
|
|
echo_stat
|
|
CMD_TIMEOUT='15'
|
|
CMD_REQUESTED="sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS}"
|
|
create_sshcmd
|
|
|
|
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
|
|
echo_stat
|
|
CMD_TIMEOUT='15'
|
|
CMD_REQUESTED="sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS}"
|
|
create_sshcmd
|
|
fi
|
|
fi
|
|
}
|
|
|
|
## Push Reload
|
|
function push_gs_reload {
|
|
MESSAGE="Inverting Tachyon Pulses"
|
|
echo_info
|
|
sleep 1
|
|
|
|
MESSAGE="Updating Remote FTLDNS Configuration"
|
|
echo_stat
|
|
CMD_TIMEOUT='15'
|
|
CMD_REQUESTED="${RIHOLE_BIN} restartdns reloadlists"
|
|
create_sshcmd
|
|
|
|
MESSAGE="Reloading Remote FTLDNS Services"
|
|
echo_stat
|
|
CMD_TIMEOUT='15'
|
|
CMD_REQUESTED="${RIHOLE_BIN} restartdns"
|
|
create_sshcmd
|
|
}
|
|
|
|
## Push Function
|
|
function push_gs {
|
|
previous_md5
|
|
md5_compare
|
|
backup_settime
|
|
|
|
intent_validate
|
|
|
|
push_gs_grav
|
|
push_gs_cust
|
|
push_gs_reload
|
|
|
|
md5_recheck
|
|
logs_export
|
|
exit_withchange
|
|
} |