cleanup indentions

This commit is contained in:
Michael Stanclift 2020-12-31 02:49:54 +00:00
parent 9313200b94
commit 42118e9b98
20 changed files with 562 additions and 826 deletions

View File

@ -109,82 +109,82 @@ source ${LOCAL_FOLDR}/includes/gs-exit.sh
case $# in
0)
start_gs
task_smart ;;
task_smart ;;
1)
case $1 in
smart|sync)
start_gs
task_smart ;;
task_smart ;;
pull)
start_gs
task_pull ;;
task_pull ;;
push)
start_gs
task_push ;;
task_push ;;
restore)
start_gs
task_restore ;;
task_restore ;;
version)
start_gs_noconfig
task_version ;;
task_version ;;
update|upgrade)
start_gs_noconfig
task_update ;;
task_update ;;
dev|devmode|development|develop)
start_gs_noconfig
task_devmode ;;
task_devmode ;;
logs|log)
start_gs
task_logs ;;
task_logs ;;
compare)
start_gs
task_compare ;;
task_compare ;;
cron)
start_gs
task_cron ;;
task_cron ;;
config|configure)
start_gs_noconfig
task_configure ;;
task_configure ;;
auto|automate)
start_gs
task_automate ;;
task_automate ;;
backup)
start_gs
task_backup ;;
task_backup ;;
purge)
start_gs
task_purge ;;
task_purge ;;
sudo)
start_gs
task_sudo ;;
task_sudo ;;
info)
start_gs
task_info ;;
task_info ;;
*)
start_gs
task_invalid ;;
task_invalid ;;
esac
;;
2)
case $1 in
auto|automate)
start_gs
task_automate ;;
task_automate ;;
esac
;;
3)
case $1 in
auto|automate)
start_gs
task_automate $2 $3 ;;
task_automate $2 $3 ;;
esac
;;
*)
start_gs
task_invalid ;;
task_invalid ;;
esac
# END OF SCRIPT ##############################

View File

@ -9,7 +9,7 @@ function task_automate {
TASKTYPE='AUTOMATE'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
CRON_EXIST='0'
CRON_CHECK=$(crontab -l | grep -q "${GS_FILENAME}" && echo '1' || echo '0')
if [ ${CRON_CHECK} == 1 ]
@ -21,7 +21,7 @@ function task_automate {
MESSAGE="Configuring Hourly Smart Sync"
echo_info
if [[ $1 =~ ^[0-9][0-9]?$ ]]
then
INPUT_AUTO_FREQ=$1
@ -30,7 +30,7 @@ function task_automate {
echo_need
read INPUT_AUTO_FREQ
fi
if [ $INPUT_AUTO_FREQ -gt 30 ]
then
MESSAGE="Invalid Frequency Range"
@ -41,7 +41,7 @@ function task_automate {
if [ $CRON_EXIST == 1 ]
then
clear_cron
MESSAGE="Sync Automation Disabled"
echo_warn
else
@ -53,16 +53,16 @@ function task_automate {
then
clear_cron
fi
MESSAGE="Saving New Sync Automation"
echo_stat
(crontab -l 2>/dev/null; echo "*/${INPUT_AUTO_FREQ} * * * * ${BASH_PATH} ${LOCAL_FOLDR}/${GS_FILENAME} smart > ${LOG_PATH}/${CRONJOB_LOG}") | crontab -
error_validate
error_validate
fi
MESSAGE="Configuring Daily Backup Frequency"
echo_info
if [[ $2 =~ ^[0-9][0-9]?$ ]]
then
INPUT_AUTO_BACKUP=$2
@ -71,7 +71,7 @@ function task_automate {
echo_need
read INPUT_AUTO_BACKUP
fi
if [ $INPUT_AUTO_BACKUP -gt 24 ]
then
MESSAGE="Invalid Frequency Range"
@ -85,9 +85,9 @@ function task_automate {
MESSAGE="Saving New Backup Automation"
echo_stat
(crontab -l 2>/dev/null; echo "0 ${INPUT_AUTO_BACKUP} * * * ${BASH_PATH} ${LOCAL_FOLDR}/${GS_FILENAME} backup >/dev/null 2>&1") | crontab -
error_validate
error_validate
fi
exit_withchange
}
@ -95,11 +95,11 @@ function task_automate {
function clear_cron {
MESSAGE="Removing Existing Automation"
echo_stat
crontab -l > cronjob-old.tmp
sed "/${GS_FILENAME}/d" cronjob-old.tmp > cronjob-new.tmp
crontab cronjob-new.tmp 2>/dev/null
error_validate
error_validate
rm cronjob-old.tmp
rm cronjob-new.tmp
}

View File

@ -9,7 +9,7 @@ function task_backup {
TASKTYPE='BACKUP'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
backup_settime
backup_local_gravity
backup_local_custom
@ -28,17 +28,17 @@ function backup_local_gravity {
echo_stat
sqlite3 ${PIHOLE_DIR}/${GRAVITY_FI} ".backup '${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${GRAVITY_FI}.backup'"
error_validate
error_validate
}
function backup_local_custom {
if [ "$SKIP_CUSTOM" != '1' ]
then
then
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
then
MESSAGE="Performing Backup Up Local ${CUSTOM_DNS}"
echo_stat
cp ${PIHOLE_DIR}/${CUSTOM_DNS} ${LOCAL_FOLDR}/${BACKUP_FOLD}/${BACKUPTIMESTAMP}-${CUSTOM_DNS}.backup
error_validate
fi
@ -51,25 +51,25 @@ function backup_remote_gravity {
CMD_TIMEOUT='60'
CMD_REQUESTED="sudo sqlite3 ${RIHOLE_DIR}/${GRAVITY_FI} \".backup '${RIHOLE_DIR}/${GRAVITY_FI}.backup'\""
create_sshcmd
create_sshcmd
}
function backup_remote_custom {
if [ "$SKIP_CUSTOM" != '1' ]
then
MESSAGE="Performing Backup of Remote ${CUSTOM_DNS}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo cp ${RIHOLE_DIR}/${CUSTOM_DNS} ${RIHOLE_DIR}/${CUSTOM_DNS}.backup"
create_sshcmd
then
MESSAGE="Performing Backup of Remote ${CUSTOM_DNS}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo cp ${RIHOLE_DIR}/${CUSTOM_DNS} ${RIHOLE_DIR}/${CUSTOM_DNS}.backup"
create_sshcmd
fi
}
function backup_cleanup {
MESSAGE="Cleaning Up Old Backups"
echo_stat
find ${LOCAL_FOLDR}/${BACKUP_FOLD}/$(date +%Y)*.backup -mtime +${BACKUP_RETAIN} -type f -delete
error_validate
find ${LOCAL_FOLDR}/${BACKUP_FOLD}/$(date +%Y)*.backup -mtime +${BACKUP_RETAIN} -type f -delete
error_validate
}

View File

@ -36,7 +36,7 @@ function echo_warn {
### Executing
function echo_stat {
echo -en "${STAT} ${MESSAGE}"
}
}
### Success
function echo_good {

View File

@ -3,7 +3,7 @@ function task_compare {
TASKTYPE='COMPARE'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
show_target
validate_gs_folders
validate_ph_folders

View File

@ -1,276 +1,12 @@
# GRAVITY SYNC BY VMSTAN #####################
# gs-config.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!
## Configure Task
function task_configure {
TASKTYPE='CONFIGURE'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
if [ -f ${LOCAL_FOLDR}/${CONFIG_FILE} ]
then
config_delete
else
config_generate
fi
# backup_settime
# backup_local_gravity
# backup_local_custom
# backup_cleanup
create_alias
exit_withchange
}
## Generate New Configuration
function config_generate {
# detect_ssh
MESSAGE="Creating New ${CONFIG_FILE} from Template"
echo_stat
cp ${LOCAL_FOLDR}/${CONFIG_FILE}.example ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
docker_detect
if [ "${DOCKERREADY}" == "1" ]
then
MESSAGE="Advanced Configuration Required"
echo_info
advanced_config_generate
else
MESSAGE="Use Advanced Installation Options? (Leave blank for default 'No')"
echo_need
read INPUT_ADVANCED_INSTALL
INPUT_ADVANCED_INSTALL="${INPUT_ADVANCED_INSTALL:-N}"
if [ "${INPUT_ADVANCED_INSTALL}" != "N" ]
then
MESSAGE="Advanced Configuration Selected"
echo_info
advanced_config_generate
fi
fi
MESSAGE="Standard Settings"
echo_info
MESSAGE="Primary Pi-hole Address (IP or DNS)"
echo_need
read INPUT_REMOTE_HOST
if [ "${PING_AVOID}" != "1" ]
then
MESSAGE="Testing Network Connection (ICMP)"
echo_stat
ping -c 3 ${INPUT_REMOTE_HOST} >/dev/null 2>&1
error_validate
else
MESSAGE="Bypassing Network Testing (ICMP)"
echo_warn
fi
MESSAGE="SSH User for ${INPUT_REMOTE_HOST}"
echo_need
read INPUT_REMOTE_USER
MESSAGE="Saving Host to ${CONFIG_FILE}"
echo_stat
sed -i "/REMOTE_HOST='192.168.1.10'/c\REMOTE_HOST='${INPUT_REMOTE_HOST}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
MESSAGE="Saving User to ${CONFIG_FILE}"
echo_stat
sed -i "/REMOTE_USER='pi'/c\REMOTE_USER='${INPUT_REMOTE_USER}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
generate_sshkey
MESSAGE="Importing New ${CONFIG_FILE}"
echo_stat
source ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
export_sshkey
# MESSAGE="Testing Configuration"
# echo_info
# validate_os_sshpass
# validate_sqlite3
# detect_remotersync
}
## Advanced Configuration Options
function advanced_config_generate {
MESSAGE="Local Pi-hole in Docker Container? (Leave blank for default 'No')"
echo_need
read INPUT_PH_IN_TYPE
INPUT_PH_IN_TYPE="${INPUT_PH_IN_TYPE:-N}"
if [ "${INPUT_PH_IN_TYPE}" != "N" ]
then
MESSAGE="Saving Local Docker Setting to ${CONFIG_FILE}"
echo_stat
sed -i "/# PH_IN_TYPE=''/c\PH_IN_TYPE='docker'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
MESSAGE="Local Docker Container Name? (Leave blank for default 'pihole')"
echo_need
read INPUT_DOCKER_CON
INPUT_DOCKER_CON="${INPUT_DOCKER_CON:-pihole}"
if [ "${INPUT_DOCKER_CON}" != "pihole" ]
then
MESSAGE="Saving Local Container Name to ${CONFIG_FILE}"
echo_stat
sed -i "/# DOCKER_CON=''/c\DOCKER_CON='${INPUT_DOCKER_CON}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
MESSAGE="Local Pi-hole 'etc' Volume Path? (Required, no trailing slash)"
echo_need
read INPUT_PIHOLE_DIR
if [ "${INPUT_PIHOLE_DIR}" != "" ]
then
MESSAGE="Saving Local Pi-hole Volume to ${CONFIG_FILE}"
echo_stat
sed -i "/# PIHOLE_DIR=''/c\PIHOLE_DIR='${INPUT_PIHOLE_DIR}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
SKIP_PIHOLE_DIR="1"
else
MESSAGE="This setting is required!"
echo_warn
exit_withchanges
fi
MESSAGE="Saving Local Volume Ownership to ${CONFIG_FILE}"
echo_stat
sed -i "/# FILE_OWNER=''/c\FILE_OWNER='named:docker'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
MESSAGE="Remote Pi-hole in Docker Container? (Leave blank for default 'No')"
echo_need
read INPUT_RH_IN_TYPE
INPUT_RH_IN_TYPE="${INPUT_RH_IN_TYPE:-N}"
if [ "${INPUT_RH_IN_TYPE}" != "N" ]
then
MESSAGE="Saving Remote Docker Setting to ${CONFIG_FILE}"
echo_stat
sed -i "/# RH_IN_TYPE=''/c\RH_IN_TYPE='docker'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
MESSAGE="Remote Docker Container Name? (Leave blank for default 'pihole')"
echo_need
read INPUT_ROCKER_CON
INPUT_ROCKER_CON="${INPUT_ROCKER_CON:-pihole}"
if [ "${INPUT_ROCKER_CON}" != "pihole" ]
then
MESSAGE="Saving Remote Container Name to ${CONFIG_FILE}"
echo_stat
sed -i "/# ROCKER_CON=''/c\ROCKER_CON='${INPUT_ROCKER_CON}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
MESSAGE="Remote Pi-hole 'etc' Volume Path? (Required, no trailing slash)"
echo_need
read INPUT_RIHOLE_DIR
if [ "${INPUT_RIHOLE_DIR}" != "" ]
then
MESSAGE="Saving Remote Pi-hole Volume to ${CONFIG_FILE}"
echo_stat
sed -i "/# RIHOLE_DIR=''/c\RIHOLE_DIR='${INPUT_RIHOLE_DIR}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
SKIP_RIHOLE_DIR="1"
else
MESSAGE="This setting is required!"
echo_warn
exit_withchanges
fi
MESSAGE="Saving Remote Volume Ownership to ${CONFIG_FILE}"
echo_stat
sed -i "/# RILE_OWNER=''/c\RILE_OWNER='named:docker'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
if [ $SKIP_PIHOLE_DIR != "1" ]
then
MESSAGE="Local Pi-hole Settings Directory Path? (Leave blank for default '/etc/pihole')"
echo_need
read INPUT_PIHOLE_DIR
INPUT_PIHOLE_DIR="${INPUT_PIHOLE_DIR:-/etc/pihole}"
if [ "${INPUT_PIHOLE_DIR}" != "/etc/pihole" ]
then
MESSAGE="Saving Local Pi-hole Settings Directory Path to ${CONFIG_FILE}"
echo_stat
sed -i "/# PIHOLE_DIR=''/c\PIHOLE_DIR='${INPUT_PIHOLE_DIR}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
fi
if [ "$SKIP_RIHOLE_DIR" != "1" ]
then
MESSAGE="Remote Pi-hole Settings Directory Path? (Leave blank for default '/etc/pihole')"
echo_need
read INPUT_RIHOLE_DIR
INPUT_RIHOLE_DIR="${INPUT_RIHOLE_DIR:-/etc/pihole}"
if [ "${INPUT_RIHOLE_DIR}" != "/etc/pihole" ]
then
MESSAGE="Saving Remote Pi-hole Settings Directory Path to ${CONFIG_FILE}"
echo_stat
sed -i "/# RIHOLE_DIR=''/c\RIHOLE_DIR='${INPUT_RIHOLE_DIR}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
fi
MESSAGE="Use Custom SSH Port? (Leave blank for default '22')"
echo_need
read INPUT_SSH_PORT
INPUT_SSH_PORT="${INPUT_SSH_PORT:-22}"
SSH_PORT="${INPUT_SSH_PORT}"
if [ "${INPUT_SSH_PORT}" != "22" ]
then
MESSAGE="Saving Custom SSH Port to ${CONFIG_FILE}"
echo_stat
sed -i "/# SSH_PORT=''/c\SSH_PORT='${INPUT_SSH_PORT}'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
fi
MESSAGE="Enable ICMP Check? (Leave blank for default 'Yes')"
echo_need
read INPUT_PING_AVOID
INPUT_PING_AVOID="${INPUT_PING_AVOID:-Y}"
if [ "${INPUT_PING_AVOID}" != "Y" ]
then
MESSAGE="Saving ICMP Avoidance to ${CONFIG_FILE}"
echo_stat
sed -i "/# PING_AVOID=''/c\PING_AVOID='1'" ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
error_validate
PING_AVOID=1
fi
MESSAGE="Use Custom SSH PKIF Location? (Leave blank for default '.ssh/id_rsa')"
echo_need
read INPUT_CUSTOM_PKIF
INPUT_CUSTOM_PKIF="${INPUT_CUSTOM_PKIF:-.ssh/id_rsa}"
if [ "${INPUT_CUSTOM_PKIF}" != ".ssh/id_rsa" ]
then
MESSAGE="Saving Custom PKIF to ${CONFIG_FILE}"
@ -318,14 +54,14 @@ function config_delete {
MESSAGE="Are you sure you want to erase this configuration?"
echo_warn
intent_validate
MESSAGE="Erasing Existing Configuration"
echo_stat
rm -f ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
error_validate
config_generate
}
@ -347,5 +83,5 @@ function create_alias {
echo_stat
echo -e "alias gravity-sync='${GS_FILEPATH}'" | sudo tee -a /etc/bash.bashrc > /dev/null
error_validate
error_validate
}

View File

@ -11,18 +11,18 @@ function import_gs {
if [ -f ${LOCAL_FOLDR}/${CONFIG_FILE} ]
then
source ${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
error_validate
# MESSAGE="Targeting ${REMOTE_USER}@${REMOTE_HOST}"
# echo_info
# detect_ssh
else
echo_fail
MESSAGE="${CONFIG_FILE} Missing"
echo_info
TASKTYPE='CONFIG'
config_generate
fi
@ -71,10 +71,10 @@ function start_gs {
import_gs
ph_type
MESSAGE="Evaluating Arguments"
echo_stat
if [ "${ROOT_CHECK_AVOID}" != "1" ]
then
new_root_check
@ -86,7 +86,7 @@ function start_gs_noconfig {
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
cd ${LOCAL_FOLDR}
MESSAGE="Evaluating Arguments"
echo_stat
}

View File

@ -7,16 +7,16 @@
## Validate Sync Required
function md5_compare {
HASHMARK='0'
MESSAGE="Analyzing ${GRAVITY_FI} on ${REMOTE_HOST}"
echo_stat
primaryDBMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${GRAVITY_FI}" | sed 's/\s.*$//')
error_validate
primaryDBMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${GRAVITY_FI}" | sed 's/\s.*$//')
error_validate
MESSAGE="Analyzing ${GRAVITY_FI} on $HOSTNAME"
echo_stat
secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//')
error_validate
error_validate
if [ "$primaryDBMD5" == "$last_primaryDBMD5" ] && [ "$secondDBMD5" == "$last_secondDBMD5" ]
then
@ -26,7 +26,7 @@ function md5_compare {
echo_warn
HASHMARK=$((HASHMARK+1))
fi
if [ "$SKIP_CUSTOM" != '1' ]
then
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
@ -36,14 +36,14 @@ function md5_compare {
REMOTE_CUSTOM_DNS="1"
MESSAGE="Analyzing ${CUSTOM_DNS} on ${REMOTE_HOST}"
echo_stat
primaryCLMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//'")
error_validate
primaryCLMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//'")
error_validate
MESSAGE="Analyzing ${CUSTOM_DNS} on $HOSTNAME"
echo_stat
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//')
error_validate
error_validate
if [ "$primaryCLMD5" == "$last_primaryCLMD5" ] && [ "$secondCLMD5" == "$last_secondCLMD5" ]
then
@ -64,12 +64,12 @@ function md5_compare {
MESSAGE="${REMOTE_HOST} has ${CUSTOM_DNS}"
HASHMARK=$((HASHMARK+1))
echo_info
fi
fi
MESSAGE="No ${CUSTOM_DNS} Detected on $HOSTNAME"
echo_info
fi
fi
if [ "$HASHMARK" != "0" ]
then
MESSAGE="Replication Required"
@ -78,7 +78,7 @@ function md5_compare {
else
MESSAGE="No Replication Required"
echo_info
exit_nochange
exit_nochange
fi
}
@ -102,17 +102,17 @@ function md5_recheck {
echo_info
HASHMARK='0'
MESSAGE="Reanalyzing ${GRAVITY_FI} on ${REMOTE_HOST}"
echo_stat
primaryDBMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${GRAVITY_FI}" | sed 's/\s.*$//')
error_validate
primaryDBMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${GRAVITY_FI}" | sed 's/\s.*$//')
error_validate
MESSAGE="Reanalyzing ${GRAVITY_FI} on $HOSTNAME"
echo_stat
secondDBMD5=$(md5sum ${PIHOLE_DIR}/${GRAVITY_FI} | sed 's/\s.*$//')
error_validate
error_validate
if [ "$SKIP_CUSTOM" != '1' ]
then
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
@ -122,14 +122,14 @@ function md5_recheck {
REMOTE_CUSTOM_DNS="1"
MESSAGE="Reanalyzing ${CUSTOM_DNS} on ${REMOTE_HOST}"
echo_stat
primaryCLMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//'")
error_validate
primaryCLMD5=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "md5sum ${RIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//'")
error_validate
MESSAGE="Reanalyzing ${CUSTOM_DNS} on $HOSTNAME"
echo_stat
secondCLMD5=$(md5sum ${PIHOLE_DIR}/${CUSTOM_DNS} | sed 's/\s.*$//')
error_validate
error_validate
else
MESSAGE="No ${CUSTOM_DNS} Detected on ${REMOTE_HOST}"
echo_info
@ -140,7 +140,7 @@ function md5_recheck {
REMOTE_CUSTOM_DNS="1"
MESSAGE="${REMOTE_HOST} has ${CUSTOM_DNS}"
echo_info
fi
fi
MESSAGE="No ${CUSTOM_DNS} Detected on $HOSTNAME"
echo_info
fi

View File

@ -25,9 +25,9 @@ function intent_validate {
MESSAGE="Type ${INTENT} to Confirm"
echo_need
read INPUT_INTENT
if [ "${INPUT_INTENT}" != "${INTENT}" ]
then
MESSAGE="${TASKTYPE} Aborted"

View File

@ -9,7 +9,7 @@ function task_logs {
TASKTYPE='LOGS'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
logs_gs
}
@ -18,40 +18,40 @@ function task_logs {
function logs_export {
if [ "${TASKTYPE}" != "BACKUP" ]
then
MESSAGE="Saving File Hashes"
echo_stat
MESSAGE="Saving File Hashes"
echo_stat
rm -f ${LOG_PATH}/${HISTORY_MD5}
echo -e ${primaryDBMD5} >> ${LOG_PATH}/${HISTORY_MD5}
echo -e ${secondDBMD5} >> ${LOG_PATH}/${HISTORY_MD5}
echo -e ${primaryCLMD5} >> ${LOG_PATH}/${HISTORY_MD5}
echo -e ${secondCLMD5} >> ${LOG_PATH}/${HISTORY_MD5}
error_validate
error_validate
fi
MESSAGE="Logging Successful ${TASKTYPE}"
echo_stat
echo -e $(date) "[${TASKTYPE}]" >> ${LOG_PATH}/${SYNCING_LOG}
error_validate
echo -e $(date) "[${TASKTYPE}]" >> ${LOG_PATH}/${SYNCING_LOG}
error_validate
}
### Output Sync Logs
function logs_gs {
MESSAGE="Tailing ${LOG_PATH}/${SYNCING_LOG}"
echo_info
echo -e "========================================================"
echo -e "Recent Complete ${YELLOW}SMART${NC} Executions"
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep SMART
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep SMART
echo -e "Recent Complete ${YELLOW}PULL${NC} Executions"
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PULL
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PULL
echo -e "Recent Complete ${YELLOW}PUSH${NC} Executions"
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PUSH
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep PUSH
echo -e "Recent Complete ${YELLOW}BACKUP${NC} Executions"
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep BACKUP
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep BACKUP
echo -e "Recent Complete ${YELLOW}RESTORE${NC} Executions"
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep RESTORE
tail -n 7 "${LOG_PATH}/${SYNCING_LOG}" | grep RESTORE
echo -e "========================================================"
exit_nochange
}
@ -64,31 +64,31 @@ function show_crontab {
if [ -f ${LOG_PATH}/${CRONJOB_LOG} ]
then
if [ -s ${LOG_PATH}/${CRONJOB_LOG} ]
echo_good
MESSAGE="Tailing ${LOG_PATH}/${CRONJOB_LOG}"
echo_info
echo -e "========================================================"
date -r ${LOG_PATH}/${CRONJOB_LOG}
cat ${LOG_PATH}/${CRONJOB_LOG}
echo -e "========================================================"
exit_nochange
echo_good
MESSAGE="Tailing ${LOG_PATH}/${CRONJOB_LOG}"
echo_info
echo -e "========================================================"
date -r ${LOG_PATH}/${CRONJOB_LOG}
cat ${LOG_PATH}/${CRONJOB_LOG}
echo -e "========================================================"
exit_nochange
then
echo_fail
MESSAGE="${LOG_PATH}/${CRONJOB_LOG} is Empty"
echo_info
exit_nochange
fi
else
echo_fail
MESSAGE="${LOG_PATH}/${CRONJOB_LOG} is Missing"
echo_info
exit_nochange
fi
}

View File

@ -9,146 +9,146 @@ function task_pull {
TASKTYPE='PULL'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
show_target
validate_gs_folders
validate_ph_folders
validate_sqlite3
validate_os_sshpass
pull_gs
exit
}
## Pull Gravity
function pull_gs_grav {
backup_local_gravity
backup_remote_gravity
MESSAGE="Pulling ${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}.pull"
create_rsynccmd
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
MESSAGE="Replacing ${GRAVITY_FI} on $HOSTNAME"
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
if [ "$FILE_OWNER" != "named:docker" ]
then
MESSAGE="Validating Settings of ${GRAVITY_FI}"
echo_stat
GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk 'OFS=":" {print $3,$4}')
if [ "$GRAVDB_OWN" != "$FILE_OWNER" ]
then
MESSAGE="Validating Ownership on ${GRAVITY_FI}"
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chown ${FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
else
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chown ${FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi
GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}')
if [ "$GRAVDB_RWE" != "-rw-rw-r--" ]
GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk 'OFS=":" {print $3,$4}')
if [ "$GRAVDB_OWN" != "$FILE_OWNER" ]
then
MESSAGE="Validating Permissions on ${GRAVITY_FI}"
MESSAGE="Validating Ownership on ${GRAVITY_FI}"
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Permissions on ${GRAVITY_FI}"
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
sudo chown ${FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
else
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chown ${FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi
GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}')
if [ "$GRAVDB_RWE" != "-rw-rw-r--" ]
then
MESSAGE="Validating Permissions on ${GRAVITY_FI}"
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Permissions on ${GRAVITY_FI}"
echo_stat
sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
echo_good
}
## Pull Custom
function pull_gs_cust {
if [ "$SKIP_CUSTOM" != '1' ]
then
then
if [ "$REMOTE_CUSTOM_DNS" == "1" ]
then
backup_local_custom
backup_remote_custom
MESSAGE="Pulling ${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}.pull"
create_rsynccmd
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
MESSAGE="Replacing ${CUSTOM_DNS} on $HOSTNAME"
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${CUSTOM_DNS}.pull ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Validating Settings on ${CUSTOM_DNS}"
echo_stat
CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}')
if [ "$CUSTOMLS_OWN" != "rootroot" ]
then
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}')
if [ "$CUSTOMLS_RWE" != "-rw-r--r--" ]
then
MESSAGE="Validating Permissions on ${CUSTOM_DNS}"
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}')
if [ "$CUSTOMLS_OWN" != "rootroot" ]
then
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
echo_fail
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}')
if [ "$CUSTOMLS_RWE" != "-rw-r--r--" ]
then
MESSAGE="Validating Permissions on ${CUSTOM_DNS}"
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Continuing Validation of ${GRAVITY_FI}"
echo_stat
fi
echo_good
fi
fi
@ -158,17 +158,17 @@ function pull_gs_cust {
function pull_gs_reload {
MESSAGE="Isolating Regeneration Pathways"
echo_info
sleep 1
sleep 1
MESSAGE="Updating FTLDNS Configuration"
echo_stat
${PH_EXEC} restartdns reloadlists >/dev/null 2>&1
error_validate
${PH_EXEC} restartdns reloadlists >/dev/null 2>&1
error_validate
MESSAGE="Reloading FTLDNS Services"
echo_stat
${PH_EXEC} restartdns >/dev/null 2>&1
error_validate
${PH_EXEC} restartdns >/dev/null 2>&1
error_validate
}
## Pull Function

View File

@ -9,7 +9,7 @@ function task_purge {
TASKTYPE="THE-PURGE"
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
MESSAGE="THIS WILL RESET YOUR ENTIRE GRAVITY SYNC INSTALLATION"
echo_warn
MESSAGE="This will remove:"
@ -18,7 +18,7 @@ function task_purge {
echo_warn
MESSAGE="- Your ${CONFIG_FILE} file."
echo_warn
if [ -f "${LOCAL_FOLDR}/dev" ]
then
MESSAGE="- Your development branch updater."
@ -27,7 +27,7 @@ function task_purge {
MESSAGE="- Your beta branch updater."
fi
echo_warn
MESSAGE="- All cronjob/automation tasks."
echo_warn
MESSAGE="- All job history/logs."
@ -36,10 +36,10 @@ function task_purge {
echo_warn
MESSAGE="This function cannot be undone!"
echo_warn
MESSAGE="YOU WILL NEED TO REBUILD GRAVITY SYNC AFTER EXECUTION"
echo_warn
MESSAGE="Pi-hole binaries, configuration and services ARE NOT impacted!"
echo_info
MESSAGE="Your device will continue to resolve and block DNS requests,"
@ -48,31 +48,31 @@ function task_purge {
echo_info
MESSAGE="until you reconfigure Gravity Sync on this device."
echo_info
intent_validate
MESSAGE="Cleaning Gravity Sync Directory"
echo_stat
git clean -f -X -d >/dev/null 2>&1
error_validate
error_validate
clear_cron
MESSAGE="Deleting SSH Key-files"
echo_stat
echo_stat
rm -f $HOME/${SSH_PKIF} >/dev/null 2>&1
rm -f $HOME/${SSH_PKIF}.pub >/dev/null 2>&1
error_validate
error_validate
MESSAGE="Realigning Dilithium Matrix"
echo_stat
echo_stat
sleep 1
MESSAGE="Realigning Dilithium Matrix"
echo_good
echo_good
update_gs
}

View File

@ -9,13 +9,13 @@ 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
}
@ -27,66 +27,66 @@ function push_gs_grav {
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
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
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
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
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
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
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
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
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
CMD_TIMEOUT='15'
CMD_REQUESTED="sudo chown root:root ${RIHOLE_DIR}/${CUSTOM_DNS}"
create_sshcmd
fi
fi
}
@ -94,19 +94,19 @@ function push_gs_cust {
function push_gs_reload {
MESSAGE="Inverting Tachyon Pulses"
echo_info
sleep 1
sleep 1
MESSAGE="Updating Remote FTLDNS Configuration"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="${RH_EXEC} restartdns reloadlists"
create_sshcmd
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
CMD_TIMEOUT='15'
CMD_REQUESTED="${RH_EXEC} restartdns"
create_sshcmd
}
## Push Function
@ -116,11 +116,11 @@ function push_gs {
backup_settime
intent_validate
push_gs_grav
push_gs_cust
push_gs_reload
md5_recheck
logs_export
exit_withchange

View File

@ -9,12 +9,12 @@ function task_restore {
TASKTYPE='RESTORE'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
show_target
validate_gs_folders
validate_ph_folders
validate_sqlite3
restore_gs
exit
}
@ -23,162 +23,162 @@ function task_restore {
function restore_gs {
MESSAGE="This will restore your settings on $HOSTNAME with a previous version!"
echo_warn
MESSAGE="PREVIOUS BACKUPS AVAILABLE FOR RESTORATION"
echo_info
ls ${LOCAL_FOLDR}/${BACKUP_FOLD} | grep $(date +%Y) | grep ${GRAVITY_FI} | colrm 18
MESSAGE="Select backup date to restore ${GRAVITY_FI} from"
echo_need
read INPUT_BACKUP_DATE
if [ -f ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${GRAVITY_FI}.backup ]
then
MESSAGE="Backup File Selected"
else
MESSAGE="Invalid Request"
echo_info
exit_nochange
fi
if [ "$SKIP_CUSTOM" != '1' ]
then
if [ -f ${PIHOLE_DIR}/${CUSTOM_DNS} ]
then
ls ${LOCAL_FOLDR}/${BACKUP_FOLD} | grep $(date +%Y) | grep ${CUSTOM_DNS} | colrm 18
MESSAGE="Select backup date to restore ${CUSTOM_DNS} from"
echo_need
read INPUT_DNSBACKUP_DATE
if [ -f ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_DNSBACKUP_DATE}-${CUSTOM_DNS}.backup ]
then
MESSAGE="Backup File Selected"
else
MESSAGE="Invalid Request"
echo_info
exit_nochange
fi
fi
fi
MESSAGE="${GRAVITY_FI} from ${INPUT_BACKUP_DATE} Selected"
echo_info
echo_info
MESSAGE="${CUSTOM_DNS} from ${INPUT_DNSBACKUP_DATE} Selected"
echo_info
echo_info
intent_validate
MESSAGE="Making Time Warp Calculations"
echo_info
MESSAGE="Stopping Pi-hole Services"
echo_stat
sudo service pihole-FTL stop >/dev/null 2>&1
error_validate
error_validate
MESSAGE="Restoring ${GRAVITY_FI} on $HOSTNAME"
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${GRAVITY_FI}.backup ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_BACKUP_DATE}-${GRAVITY_FI}.backup ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
MESSAGE="Validating Ownership on ${GRAVITY_FI}"
echo_stat
GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk 'OFS=":" {print $3,$4}')
if [ "$GRAVDB_OWN" == "$FILE_OWNER" ]
then
echo_good
else
echo_fail
GRAVDB_OWN=$(ls -ld ${PIHOLE_DIR}/${GRAVITY_FI} | awk 'OFS=":" {print $3,$4}')
if [ "$GRAVDB_OWN" == "$FILE_OWNER" ]
then
echo_good
else
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chown ${FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chown ${FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi
MESSAGE="Validating Permissions on ${GRAVITY_FI}"
echo_stat
GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}')
if [ "$GRAVDB_RWE" = "-rw-rw-r--" ]
then
echo_good
else
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
GRAVDB_RWE=$(namei -m ${PIHOLE_DIR}/${GRAVITY_FI} | grep -v f: | grep ${GRAVITY_FI} | awk '{print $1}')
if [ "$GRAVDB_RWE" = "-rw-rw-r--" ]
then
echo_good
else
echo_fail
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${GRAVITY_FI}"
echo_stat
sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1
error_validate
fi
if [ "$SKIP_CUSTOM" != '1' ]
then
then
if [ -f ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_DNSBACKUP_DATE}-${CUSTOM_DNS}.backup ]
then
MESSAGE="Restoring ${CUSTOM_DNS} on $HOSTNAME"
echo_stat
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_DNSBACKUP_DATE}-${CUSTOM_DNS}.backup ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
sudo cp ${LOCAL_FOLDR}/${BACKUP_FOLD}/${INPUT_DNSBACKUP_DATE}-${CUSTOM_DNS}.backup ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
MESSAGE="Validating Ownership on ${CUSTOM_DNS}"
echo_stat
CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}')
if [ "$CUSTOMLS_OWN" == "rootroot" ]
then
echo_good
else
echo_fail
CUSTOMLS_OWN=$(ls -ld ${PIHOLE_DIR}/${CUSTOM_DNS} | awk '{print $3 $4}')
if [ "$CUSTOMLS_OWN" == "rootroot" ]
then
echo_good
else
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
fi
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chown root:root ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
fi
MESSAGE="Validating Permissions on ${CUSTOM_DNS}"
echo_stat
CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}')
if [ "$CUSTOMLS_RWE" == "-rw-r--r--" ]
then
echo_good
else
echo_fail
MESSAGE="Attempting to Compensate"
echo_warn
CUSTOMLS_RWE=$(namei -m ${PIHOLE_DIR}/${CUSTOM_DNS} | grep -v f: | grep ${CUSTOM_DNS} | awk '{print $1}')
if [ "$CUSTOMLS_RWE" == "-rw-r--r--" ]
then
echo_good
else
echo_fail
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
fi
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Setting Ownership on ${CUSTOM_DNS}"
echo_stat
sudo chmod 644 ${PIHOLE_DIR}/${CUSTOM_DNS} >/dev/null 2>&1
error_validate
fi
fi
fi
pull_gs_reload
MESSAGE="Do you want to push the restored configuration to the primary Pi-hole? (yes/no)"
echo_need
read PUSH_TO_PRIMARY
if [ "${PUSH_TO_PRIMARY}" == "Yes" ] || [ "${PUSH_TO_PRIMARY}" == "yes" ] || [ "${PUSH_TO_PRIMARY}" == "Y" ] || [ "${PUSH_TO_PRIMARY}" == "y" ]
then
push_gs
@ -189,7 +189,7 @@ function restore_gs {
else
MESSAGE="Invalid Selection - Defaulting No"
echo_warn
logs_export
exit_withchange
fi

View File

@ -9,19 +9,19 @@ function task_sudo {
TASKTYPE='SUDO'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
MESSAGE="Creating Sudoer.d Template"
echo_stat
NEW_SUDO_USER=$(whoami)
echo -e "${NEW_SUDO_USER} ALL=(ALL) NOPASSWD: ALL" > ${LOCAL_FOLDR}/templates/gs-nopasswd.sudo
error_validate
error_validate
MESSAGE="Installing Sudoer.d File"
echo_stat
sudo install -m 0440 ${LOCAL_FOLDR}/templates/gs-nopasswd.sudo /etc/sudoers.d/gs-nopasswd
error_validate
error_validate
exit_withchange
}
@ -29,11 +29,11 @@ function task_sudo {
## Root Check
function root_check {
if [ ! "$EUID" -ne 0 ]
then
then
TASKTYPE='ROOT'
MESSAGE="${MESSAGE} ${TASKTYPE}"
echo_fail
MESSAGE="${PROGRAM} Should Not Run As 'root'"
echo_warn
@ -56,16 +56,16 @@ function new_root_check {
LOCALADMIN="sudo"
fi
fi
if [ "$LOCALADMIN" == "nosudo" ]
then
TASKTYPE='ROOT'
MESSAGE="${MESSAGE} ${TASKTYPE}"
echo_fail
MESSAGE="Insufficent User Rights"
echo_warn
exit_nochange
fi
}

View File

@ -9,13 +9,13 @@ function task_smart {
TASKTYPE='SMART'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
show_target
validate_gs_folders
validate_ph_folders
validate_sqlite3
validate_os_sshpass
smart_gs
exit
}
@ -28,7 +28,7 @@ function smart_gs {
previous_md5
md5_compare
backup_settime
PRIDBCHANGE="0"
SECDBCHANGE="0"
PRICLCHANGE="0"
@ -43,31 +43,31 @@ function smart_gs {
then
SECDBCHANGE="1"
fi
if [ "${PRIDBCHANGE}" == "${SECDBCHANGE}" ]
then
if [ "${PRIDBCHANGE}" != "0" ]
then
MESSAGE="Both ${GRAVITY_FI} Have Changed"
echo_warn
PRIDBDATE=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "stat -c %Y ${RIHOLE_DIR}/${GRAVITY_FI}")
SECDBDATE=$(stat -c %Y ${PIHOLE_DIR}/${GRAVITY_FI})
if (( "$PRIDBDATE" >= "$SECDBDATE" ))
then
MESSAGE="Primary ${GRAVITY_FI} Last Changed"
echo_warn
pull_gs_grav
PULLRESTART="1"
else
MESSAGE="Secondary ${GRAVITY_FI} Last Changed"
echo_warn
push_gs_grav
PUSHRESTART="1"
fi
if (( "$PRIDBDATE" >= "$SECDBDATE" ))
then
MESSAGE="Primary ${GRAVITY_FI} Last Changed"
echo_warn
pull_gs_grav
PULLRESTART="1"
else
MESSAGE="Secondary ${GRAVITY_FI} Last Changed"
echo_warn
push_gs_grav
PUSHRESTART="1"
fi
fi
else
if [ "${PRIDBCHANGE}" != "0" ]
@ -80,7 +80,7 @@ function smart_gs {
PUSHRESTART="1"
fi
fi
if [ "${primaryCLMD5}" != "${last_primaryCLMD5}" ]
then
PRICLCHANGE="1"
@ -90,37 +90,37 @@ function smart_gs {
then
SECCLCHANGE="1"
fi
if [ "$SKIP_CUSTOM" != '1' ]
then
if [ -f "${PIHOLE_DIR}/${CUSTOM_DNS}" ]
then
if [ "${PRICLCHANGE}" == "${SECCLCHANGE}" ]
then
if [ "${PRICLCHANGE}" != "0" ]
then
MESSAGE="Both ${CUSTOM_DNS} Have Changed"
echo_warn
PRICLDATE=$(${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} "stat -c %Y ${RIHOLE_DIR}/${CUSTOM_DNS}")
SECCLDATE=$(stat -c %Y ${PIHOLE_DIR}/${CUSTOM_DNS})
if (( "$PRICLDATE" >= "$SECCLDATE" ))
then
MESSAGE="Primary ${CUSTOM_DNS} Last Changed"
echo_warn
pull_gs_cust
PULLRESTART="1"
else
MESSAGE="Secondary ${CUSTOM_DNS} Last Changed"
echo_warn
push_gs_cust
PUSHRESTART="1"
fi
if (( "$PRICLDATE" >= "$SECCLDATE" ))
then
MESSAGE="Primary ${CUSTOM_DNS} Last Changed"
echo_warn
pull_gs_cust
PULLRESTART="1"
else
MESSAGE="Secondary ${CUSTOM_DNS} Last Changed"
echo_warn
push_gs_cust
PUSHRESTART="1"
fi
fi
else
if [ "${PRICLCHANGE}" != "0" ]
@ -138,19 +138,19 @@ function smart_gs {
PULLRESTART="1"
fi
fi
if [ "$PULLRESTART" == "1" ]
then
pull_gs_reload
fi
if [ "$PUSHRESTART" == "1" ]
then
push_gs_reload
fi
md5_recheck
logs_export
exit_withchange
}

View File

@ -10,8 +10,8 @@ function create_sshcmd {
# then
# if [ -z "$SSHPASSWORD" ]
# then
timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} "${CMD_REQUESTED}"
error_validate
timeout --preserve-status ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} "${CMD_REQUESTED}"
error_validate
# else
# timeout --preserve-status ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} "${CMD_REQUESTED}"
# error_validate
@ -25,8 +25,8 @@ function create_rsynccmd {
# then
# if [ -z "$SSHPASSWORD" ]
# then
rsync --rsync-path="${RSYNC_REPATH}" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1
error_validate
rsync --rsync-path="${RSYNC_REPATH}" -e "${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1
error_validate
# else
# rsync --rsync-path="${RSYNC_REPATH}" -e "${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i $HOME/${SSH_PKIF}" ${RSYNC_SOURCE} ${RSYNC_TARGET} >/dev/null 2>&1
# error_validate
@ -37,7 +37,7 @@ function create_rsynccmd {
## Detect SSH-KEYGEN
function detect_sshkeygen {
MESSAGE="Validating SSH-KEYGEN install on $HOSTNAME"
echo_stat
echo_stat
if hash ssh-keygen >/dev/null 2>&1
then
@ -47,7 +47,7 @@ function detect_sshkeygen {
MESSAGE="SSH-KEYGEN is Required"
echo_info
exit_nochange
exit_nochange
fi
}
@ -65,12 +65,12 @@ function generate_sshkey {
echo_stat
ssh-keygen -q -P "" -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1
error_validate
error_validate
else
MESSAGE="No SSH Key Generator Located"
echo_warn
exit_nochange
fi
exit_nochange
fi
fi
fi
}
@ -85,8 +85,8 @@ function export_sshkey {
ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST}
else
MESSAGE="Error Registering Key-Pair"
echo_warn
MESSAGE="Error Registering Key-Pair"
echo_warn
fi
fi
}
@ -95,7 +95,7 @@ function export_sshkey {
function detect_ssh {
MESSAGE="Validating SSH Client on $HOSTNAME"
echo_stat
if hash ssh 2>/dev/null
then
MESSAGE="${MESSAGE} (OpenSSH)"
@ -105,10 +105,10 @@ function detect_ssh {
then
MESSAGE="${MESSAGE} (Dropbear)"
echo_fail
MESSAGE="Dropbear not supported in GS ${VERSION}"
echo_info
exit_nochange
exit_nochange
else
echo_fail
@ -118,12 +118,12 @@ function detect_ssh {
echo_stat
${PKG_INSTALL} ssh-client >/dev/null 2>&1
error_validate
error_validate
fi
MESSAGE="Validating RSYNC Installed on $HOSTNAME"
echo_stat
if hash rsync 2>/dev/null
then
echo_good
@ -131,55 +131,55 @@ function detect_ssh {
echo_fail
MESSAGE="RSYNC is Required"
echo_warn
distro_check
MESSAGE="Attempting to Compensate"
echo_warn
MESSAGE="Installing RSYNC with ${PKG_MANAGER}"
echo_stat
${PKG_INSTALL} rsync >/dev/null 2>&1
error_validate
error_validate
fi
}
function detect_remotersync {
MESSAGE="Creating Test File on ${REMOTE_HOST}"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="touch ~/gs.test"
create_sshcmd
CMD_TIMEOUT='15'
CMD_REQUESTED="touch ~/gs.test"
create_sshcmd
MESSAGE="If pull test fails ensure RSYNC is installed on ${REMOTE_HOST}"
echo_warn
MESSAGE="Pulling Test File to $HOSTNAME"
echo_stat
RSYNC_REPATH="rsync"
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:~/gs.test"
RSYNC_TARGET="${LOCAL_FOLDR}/gs.test"
create_rsynccmd
RSYNC_REPATH="rsync"
RSYNC_SOURCE="${REMOTE_USER}@${REMOTE_HOST}:~/gs.test"
RSYNC_TARGET="${LOCAL_FOLDR}/gs.test"
create_rsynccmd
MESSAGE="Cleaning Up Local Test File"
echo_stat
rm ${LOCAL_FOLDR}/gs.test
error_validate
error_validate
MESSAGE="Cleaning Up Remote Test File"
echo_stat
CMD_TIMEOUT='15'
CMD_REQUESTED="rm ~/gs.test"
create_sshcmd
create_sshcmd
}
function show_target {
MESSAGE="Targeting ${REMOTE_USER}@${REMOTE_HOST}"
echo_info
detect_ssh
}

View File

@ -12,28 +12,28 @@ function update_gs {
else
BRANCH='origin/master'
fi
if [ "$BRANCH" != "origin/master" ]
then
MESSAGE="Pulling from ${BRANCH}"
echo_info
fi
GIT_CHECK=$(git status | awk '{print $1}')
if [ "$GIT_CHECK" == "fatal:" ]
then
MESSAGE="Requires GitHub Installation"
MESSAGE="Requires GitHub Installation"
echo_warn
exit_nochange
else
MESSAGE="Updating Cache"
echo_stat
git fetch --all >/dev/null 2>&1
error_validate
error_validate
MESSAGE="Applying Update"
echo_stat
git reset --hard ${BRANCH} >/dev/null 2>&1
error_validate
error_validate
fi
}
@ -42,15 +42,15 @@ function show_version {
echo -e "========================================================"
MESSAGE="${BOLD}${PROGRAM}${NC} by ${CYAN}@vmstan${NC}"
echo_info
MESSAGE="${BLUE}https://github.com/vmstan/gravity-sync${NC}"
echo_info
if [ -f ${LOCAL_FOLDR}/dev ]
then
DEVVERSION="dev"
elif [ -f ${LOCAL_FOLDR}/beta ]
then
then
DEVVERSION="beta"
else
DEVVERSION=""
@ -58,7 +58,7 @@ function show_version {
MESSAGE="Running Version: ${GREEN}${VERSION}${NC} ${DEVVERSION}"
echo_info
GITVERSION=$(curl -sf https://raw.githubusercontent.com/vmstan/gravity-sync/master/VERSION)
if [ -z "$GITVERSION" ]
then
@ -66,9 +66,9 @@ function show_version {
else
if [ "$GITVERSION" != "$VERSION" ]
then
MESSAGE="Update Available: ${PURPLE}${GITVERSION}${NC}"
MESSAGE="Update Available: ${PURPLE}${GITVERSION}${NC}"
else
MESSAGE="Latest Version: ${GREEN}${GITVERSION}${NC}"
MESSAGE="Latest Version: ${GREEN}${GITVERSION}${NC}"
fi
fi
echo_info
@ -106,35 +106,35 @@ function task_devmode {
MESSAGE="Disabling ${TASKTYPE}"
echo_stat
rm -f ${LOCAL_FOLDR}/dev
error_validate
error_validate
elif [ -f ${LOCAL_FOLDR}/beta ]
then
MESSAGE="Disabling BETA"
echo_stat
rm -f ${LOCAL_FOLDR}/beta
error_validate
error_validate
MESSAGE="Enabling ${TASKTYPE}"
echo_stat
touch ${LOCAL_FOLDR}/dev
error_validate
error_validate
else
MESSAGE="Enabling ${TASKTYPE}"
echo_stat
touch ${LOCAL_FOLDR}/dev
error_validate
error_validate
MESSAGE="Updating Cache"
echo_stat
git fetch --all >/dev/null 2>&1
error_validate
error_validate
git branch -r
MESSAGE="Select Branch to Update Against"
echo_need
read INPUT_BRANCH
echo -e "BRANCH='${INPUT_BRANCH}'" >> ${LOCAL_FOLDR}/dev
fi
@ -148,11 +148,11 @@ function task_update {
TASKTYPE='UPDATE'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
dbclient_warning
update_gs
exit_withchange
}
@ -161,7 +161,7 @@ function task_version {
TASKTYPE='VERSION'
MESSAGE="${MESSAGE}: ${TASKTYPE} Requested"
echo_good
show_version
exit_nochange
}

View File

@ -8,19 +8,19 @@
function validate_gs_folders {
MESSAGE="Validating ${PROGRAM} Folders on $HOSTNAME"
echo_stat
if [ ! -d ${LOCAL_FOLDR} ]
then
MESSAGE="Unable to Validate ${PROGRAM} Folders on $HOSTNAME"
echo_fail
exit_nochange
fi
if [ ! -d ${LOCAL_FOLDR} ]
then
MESSAGE="Unable to Validate ${PROGRAM} Folders on $HOSTNAME"
echo_fail
exit_nochange
fi
if [ ! -d ${LOCAL_FOLDR}/${BACKUP_FOLD} ]
then
MESSAGE="Unable to Validate ${PROGRAM} Backup Folder on $HOSTNAME"
echo_fail
exit_nochange
fi
if [ ! -d ${LOCAL_FOLDR}/${BACKUP_FOLD} ]
then
MESSAGE="Unable to Validate ${PROGRAM} Backup Folder on $HOSTNAME"
echo_fail
exit_nochange
fi
echo_good
}
@ -29,31 +29,31 @@ function validate_ph_folders {
MESSAGE="Validating Pi-hole Configuration"
echo_stat
if [ "$PH_IN_TYPE" == "default" ]
if [ "$PH_IN_TYPE" == "default" ]
then
if [ ! -f ${PIHOLE_BIN} ]
then
if [ ! -f ${PIHOLE_BIN} ]
then
MESSAGE="Unable to Validate that Pi-Hole is Installed"
echo_fail
exit_nochange
fi
elif [ "$PH_IN_TYPE" == "docker" ]
then
FTLCHECK=$(sudo docker container ls | grep 'pihole/pihole')
if [ "$FTLCHECK" == "" ]
then
MESSAGE="Unable to Validate that Pi-Hole is Installed"
echo_fail
exit_nochange
fi
fi
if [ ! -d ${PIHOLE_DIR} ]
then
MESSAGE="Unable to Validate Pi-Hole Configuration Directory"
MESSAGE="Unable to Validate that Pi-Hole is Installed"
echo_fail
exit_nochange
fi
elif [ "$PH_IN_TYPE" == "docker" ]
then
FTLCHECK=$(sudo docker container ls | grep 'pihole/pihole')
if [ "$FTLCHECK" == "" ]
then
MESSAGE="Unable to Validate that Pi-Hole is Installed"
echo_fail
exit_nochange
fi
fi
if [ ! -d ${PIHOLE_DIR} ]
then
MESSAGE="Unable to Validate Pi-Hole Configuration Directory"
echo_fail
exit_nochange
fi
echo_good
}
@ -61,26 +61,26 @@ function validate_ph_folders {
function validate_sqlite3 {
MESSAGE="Validating SQLITE Installed on $HOSTNAME"
echo_stat
if hash sqlite3 2>/dev/null
then
# MESSAGE="SQLITE3 Utility Detected"
echo_good
else
MESSAGE="Unable to Validate SQLITE Install on $HOSTNAME"
echo_warn
MESSAGE="Installing SQLLITE3 with ${PKG_MANAGER}"
echo_stat
${PKG_INSTALL} sqllite3 >/dev/null 2>&1
error_validate
fi
if hash sqlite3 2>/dev/null
then
# MESSAGE="SQLITE3 Utility Detected"
echo_good
else
MESSAGE="Unable to Validate SQLITE Install on $HOSTNAME"
echo_warn
MESSAGE="Installing SQLLITE3 with ${PKG_MANAGER}"
echo_stat
${PKG_INSTALL} sqllite3 >/dev/null 2>&1
error_validate
fi
}
## Validate SSHPASS
function validate_os_sshpass {
# SSHPASSWORD=''
# if hash sshpass 2>/dev/null
# then
# MESSAGE="SSHPASS Utility Detected"
@ -92,7 +92,7 @@ function validate_os_sshpass {
# else
# MESSAGE="Testing Authentication Options"
# echo_stat
# timeout 5 ssh -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1
# if [ "$?" != "0" ]
# then
@ -112,15 +112,15 @@ function validate_os_sshpass {
MESSAGE="Validating Connection to ${REMOTE_HOST}"
echo_stat
CMD_TIMEOUT='5'
CMD_REQUESTED="exit"
create_sshcmd
create_sshcmd
}
## Detect Package Manager
function distro_check {
function distro_check {
if hash apt-get 2>/dev/null
then
PKG_MANAGER="apt-get"

View File

@ -33,7 +33,7 @@ echo -e "========================================================"
# Check Root
echo -e "[${YELLOW}i${NC}] ${YELLOW}Validating System Authorization${NC}"
if [ ! "$EUID" -ne 0 ]
then
then
echo -e "[${GREEN}${NC}] Current User (${CURRENTUSER}) is ROOT"
LOCALADMIN="root"
else
@ -208,24 +208,24 @@ else
echo -e "${CURRENTUSER} ALL=(ALL) NOPASSWD: ALL" > /tmp/gs-nopasswd.sudo
sudo install -m 0440 /tmp/gs-nopasswd.sudo /etc/sudoers.d/gs-nopasswd
fi
if [ "$GS_INSTALL" != "secondary" ]
then
echo -e "[${YELLOW}i${NC}] Gravity Sync Preperation Complete"
echo -e "[${YELLOW}i${NC}] Execute on Installer on Secondary"
echo -e "[${YELLOW}i${NC}] Check Documentation for Instructions"
echo -e "[${YELLOW}i${NC}] Installation Exiting (without changes)"
else
echo -e "[${BLUE}>${NC}] Creating Gravity Sync Directories"
git clone https://github.com/vmstan/gravity-sync.git
echo -e "[${BLUE}>${NC}] Starting Gravity Sync Configuration"
echo -e "========================================================"
./gravity-sync/gravity-sync.sh configure <&1
# echo -e "[${YELLOW}i${NC}] This host is now prepared to configure Gravity Sync!"
# echo -e "[${YELLOW}i${NC}] Please run './gravity-sync configure' from $HOME/gravity-sync"
# echo -e "[${YELLOW}i${NC}] Visit https://github.com/vmstan/gravity-sync for more instructions."
fi
if [ "$GS_INSTALL" != "secondary" ]
then
echo -e "[${YELLOW}i${NC}] Gravity Sync Preperation Complete"
echo -e "[${YELLOW}i${NC}] Execute on Installer on Secondary"
echo -e "[${YELLOW}i${NC}] Check Documentation for Instructions"
echo -e "[${YELLOW}i${NC}] Installation Exiting (without changes)"
else
echo -e "[${BLUE}>${NC}] Creating Gravity Sync Directories"
git clone https://github.com/vmstan/gravity-sync.git
echo -e "[${BLUE}>${NC}] Starting Gravity Sync Configuration"
echo -e "========================================================"
./gravity-sync/gravity-sync.sh configure <&1
# echo -e "[${YELLOW}i${NC}] This host is now prepared to configure Gravity Sync!"
# echo -e "[${YELLOW}i${NC}] Please run './gravity-sync configure' from $HOME/gravity-sync"
# echo -e "[${YELLOW}i${NC}] Visit https://github.com/vmstan/gravity-sync for more instructions."
fi
fi
exit