gravity-sync/includes/gs-push.sh
Michael Stanclift 6551ae88c7
3.1.0 (#105)
* Begin work on Docker support

* rewrite permission detection

* wrong else

* Change pihole detection based on sudo results

* Write out to devnull

* nosodo handle

* AND then

* scanning

* nosudo more

* clearer wording on failures

* headers

* handle nosudo on docker detection better

* SUDO sudo

* AND THEN

* status report rewrite

* link

* alert on no local install detected

* yellow headers like the rest of GS

* semi critical issues

* purple instead of red

* clean up output of sudo detection

* give me space

* Auto run config script

* added logo

* center logo

* move intro

* trying dev/tty

* advanced config generate

* !=

* logic is hard

* new logo

* image

* fonts

* svg image

* remove h1

* use rihole variable

* New root check

* better method of checking sudo

* remove messages

* rihole

* attempting realpath

* GS_FILEPATH

* remove $HOME call

* remove config requirement for updates

* no config for updates

* all the variables

* all kinds of variable replacements

* double quotes

* it’s like I’ve forgotten how to write this stuff

* removals

* updated requirements

* variable rearrangement

* validation check for docker

* riholes

* placeholder

* more riholes

* even more riholes

* docker examples

* docker rewrite

* docker docker docker

* docker custom checks

* update from anywhere

* correct validation error

* check for current owner only if local install

* give me space

* stuff

* more stuff

* bash alias creation

* cleanup installer

* fix .sh

* config errors, remove sshpass validation

* skip directories if done

* limit config script

* fix for changes when both targets have changed

* RIHOLE

* cleanup warning messages

* stop sign

* big red

* documenting new variables

* master

Co-authored-by: Michael Stanclift <vmstan@sovereign.vmstan.net>
Co-authored-by: Michael Stanclift <vmstan@sovereign.local>
2020-10-19 13:48:23 -05:00

127 lines
3.0 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}:${RIHOLE_DIR}/${GRAVITY_FI}.backup"
RSYNC_TARGET="${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push"
create_rsynccmd
MESSAGE="Pushing ${GRAVITY_FI} to ${REMOTE_HOST}"
echo_stat
RSYNC_REPATH="sudo rsync"
RSYNC_SOURCE="${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${GRAVITY_FI}.backup"
RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/${GRAVITY_FI}"
create_rsynccmd
MESSAGE="Setting Permissions on ${GRAVITY_FI}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo chmod 664 ${RIHOLE_DIR}/${GRAVITY_FI}"
create_sshcmd
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo chown ${RILE_OWNER} ${RIHOLE_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}:${RIHOLE_DIR}/${CUSTOM_DNS}.backup"
RSYNC_TARGET="${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.push"
create_rsynccmd
MESSAGE="Pushing ${CUSTOM_DNS} to ${REMOTE_HOST}"
echo_stat
RSYNC_REPATH="sudo rsync"
RSYNC_SOURCE="${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${CUSTOM_DNS}.backup"
RSYNC_TARGET="${REMOTE_USER}@${REMOTE_HOST}:${RIHOLE_DIR}/${CUSTOM_DNS}"
create_rsynccmd
MESSAGE="Setting Permissions on ${CUSTOM_DNS}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo chmod 644 ${RIHOLE_DIR}/${CUSTOM_DNS}"
create_sshcmd
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo chown root:root ${RIHOLE_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="${RH_EXEC} restartdns reloadlists"
create_sshcmd
MESSAGE="Reloading Remote FTLDNS Services"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="${RH_EXEC} 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
}