gravity-sync/includes/gs-core.sh

92 lines
1.9 KiB
Bash
Raw Normal View History

# GRAVITY SYNC BY VMSTAN #####################
# gs-core.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!
## Import Settings
function import_gs {
2020-12-31 02:45:47 +00:00
MESSAGE="Importing ${CONFIG_FILE} Settings"
echo -en "${STAT} $MESSAGE"
if [ -f ${LOCAL_FOLDR}/${CONFIG_FILE} ]
then
source ${LOCAL_FOLDR}/${CONFIG_FILE}
2020-12-31 02:49:54 +00:00
error_validate
2020-12-31 02:45:47 +00:00
# MESSAGE="Targeting ${REMOTE_USER}@${REMOTE_HOST}"
# echo_info
2020-12-31 02:49:54 +00:00
2020-12-31 02:45:47 +00:00
# detect_ssh
else
echo_fail
MESSAGE="${CONFIG_FILE} Missing"
echo_info
2020-12-31 02:49:54 +00:00
2020-12-31 02:45:47 +00:00
TASKTYPE='CONFIG'
config_generate
fi
}
## Invalid Tasks
function task_invalid {
2020-12-31 02:45:47 +00:00
echo_fail
list_gs_arguments
}
## Error Validation
function error_validate {
2020-12-31 02:45:47 +00:00
if [ "$?" != "0" ]
then
echo_fail
exit 1
else
echo_good
fi
}
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 18:48:23 +00:00
function ph_type {
2020-12-31 02:45:47 +00:00
if [ "$PH_IN_TYPE" == "default" ]
then
PH_EXEC="${PIHOLE_BIN}"
elif [ "$PH_IN_TYPE" == "docker" ]
then
PH_EXEC="${DOCKER_BIN} exec ${DOCKER_CON} pihole"
fi
if [ "$RH_IN_TYPE" == "default" ]
then
RH_EXEC="${RIHOLE_BIN}"
elif [ "$RH_IN_TYPE" == "docker" ]
then
RH_EXEC="${ROCKER_BIN} exec ${DOCKER_CON} pihole"
fi
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 18:48:23 +00:00
}
# Standard Output
function start_gs {
2020-12-31 02:45:47 +00:00
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
cd ${LOCAL_FOLDR}
import_gs
ph_type
2020-12-31 02:49:54 +00:00
2020-12-31 02:45:47 +00:00
MESSAGE="Evaluating Arguments"
echo_stat
2020-12-31 02:49:54 +00:00
2020-12-31 02:45:47 +00:00
if [ "${ROOT_CHECK_AVOID}" != "1" ]
then
new_root_check
fi
}
# Standard Output No Config
function start_gs_noconfig {
2020-12-31 02:45:47 +00:00
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
cd ${LOCAL_FOLDR}
2020-12-31 02:49:54 +00:00
2020-12-31 02:45:47 +00:00
MESSAGE="Evaluating Arguments"
echo_stat
}