* version change

* Nova

* No-config function

* Markdown cleanup

* Create gs-core file

* correct missing includes via cron

Co-authored-by: Michael Stanclift <vmstan@Sovereign.vmstan.net>
Co-authored-by: Michael Stanclift <vmstan@sovereign.local>
This commit is contained in:
Michael Stanclift 2020-10-10 11:30:40 -05:00 committed by GitHub
parent c1b71ec996
commit 7d09218524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 123 additions and 102 deletions

4
.nova/Configuration.json Normal file
View File

@ -0,0 +1,4 @@
{
"editor.default_syntax" : "shell",
"workspace.name" : "Gravity Sync"
}

View File

@ -59,7 +59,7 @@ Starting with version 2.0, Gravity Sync will attempt to sync the Adlist database
Minimal preperation is required (as of version 2.2.3) on your primary Pi-hole.
Login to your *primary* Pi-hole, and run the following command:
Login to your _primary_ Pi-hole, and run the following command:
```bash
export GS_INSTALL=primary && curl -sSL https://raw.githubusercontent.com/vmstan/gravity-sync/master/prep/gs-install.sh | bash
@ -67,13 +67,13 @@ export GS_INSTALL=primary && curl -sSL https://raw.githubusercontent.com/vmstan/
This will verify you have everything necessary to use Gravity Sync. It will also add a passwordless sudo configuration file for the current user. The installer will then exit, and direct you to proceed to the secondary Pi-hole.
After you have completed this step, log out of the *primary* Pi-hole.
After you have completed this step, log out of the _primary_ Pi-hole.
### Secondary Pi-Hole
From this point forward, all operations will take place on your secondary Pi-hole.
Login to your *secondary* Pi-hole, and run the following command:
Login to your _secondary_ Pi-hole, and run the following command:
```bash
export GS_INSTALL=secondary && curl -sSL https://raw.githubusercontent.com/vmstan/gravity-sync/master/prep/gs-install.sh | bash
@ -85,7 +85,7 @@ Proceed to the Configuration section.
## Configuration
After you install Gravity Sync to your *secondary Pi-hole* you will need to create a configuration file.
After you install Gravity Sync to your _secondary Pi-hole_ you will need to create a configuration file.
```bash
cd $HOME/gravity-sync

View File

@ -1 +1 @@
3.0.1
3.0.2

View File

@ -19,6 +19,12 @@ Enjoy!
- Minor shuffle of `gravity-sync.sh` contents.
- Clarify installation requirements in `README.md`.
- Fixes issues with permissions on `gravity.db` after push operations.
- Fixes missing script startup output during `dev` operation.
#### 3.0.2
- Realigned EPS conduits, they overheat if you leave them pointed the same way for too long.
- Corrected error when running via crontab where includes directory was not properly sourced.
## 2.2

View File

@ -3,7 +3,7 @@ SCRIPT_START=$SECONDS
# GRAVITY SYNC BY VMSTAN #####################
PROGRAM='Gravity Sync'
VERSION='3.0.1'
VERSION='3.0.2'
# Execute from the home folder of the user who owns it (ex: 'cd ~/gravity-sync')
# For documentation or downloading updates visit https://github.com/vmstan/gravity-sync
@ -62,95 +62,41 @@ SSH_PKIF='.ssh/id_rsa' # default local SSH key
##############################################
# Import Color/Message Includes
source includes/gs-colors.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-colors.sh
# FUNCTION DEFINITIONS #######################
# Import Settings
function import_gs {
MESSAGE="Importing ${CONFIG_FILE} Settings"
echo -en "${STAT} $MESSAGE"
if [ -f $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} ]
then
source $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
# Core Functions
source $HOME/${LOCAL_FOLDR}/includes/gs-core.sh
# MESSAGE="Targeting ${REMOTE_USER}@${REMOTE_HOST}"
# echo_info
# detect_ssh
else
echo_fail
MESSAGE="${CONFIG_FILE} Missing"
echo_info
TASKTYPE='CONFIG'
config_generate
fi
}
# Invalid Tasks
function task_invalid {
echo_fail
list_gs_arguments
}
# Error Validation
function error_validate {
if [ "$?" != "0" ]
then
echo_fail
exit 1
else
echo_good
fi
}
# Standard Output
function start_gs {
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
import_gs
MESSAGE="Evaluating Arguments"
echo_stat
if [ "${ROOT_CHECK_AVOID}" != "1" ]
then
root_check
fi
}
# Gravity Core Functions
source includes/gs-compare.sh
source includes/gs-pull.sh
source includes/gs-push.sh
source includes/gs-smart.sh
source includes/gs-restore.sh
source includes/gs-backup.sh
# Gravity Replication Functions
source $HOME/${LOCAL_FOLDR}/includes/gs-compare.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-pull.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-push.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-smart.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-restore.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-backup.sh
# Hashing & SSH Functions
source includes/gs-hashing.sh
source includes/gs-ssh.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-hashing.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-ssh.sh
# Logging Functions
source includes/gs-logging.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-logging.sh
# Validation Functions
source includes/gs-validate.sh
source includes/gs-intent.sh
source includes/gs-root.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-validate.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-intent.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-root.sh
# Configuration Management
source includes/gs-config.sh
source includes/gs-update.sh
source includes/gs-automate.sh
source includes/gs-purge.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-config.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-update.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-automate.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-purge.sh
# Exit Codes
source includes/gs-exit.sh
source $HOME/${LOCAL_FOLDR}/includes/gs-exit.sh
# SCRIPT EXECUTION ###########################
@ -191,12 +137,7 @@ case $# in
start_gs
task_cron ;;
config|configure)
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
MESSAGE="Evaluating Arguments"
echo_stat
start_gs_noconfig
task_configure ;;
auto|automate)
start_gs
@ -209,10 +150,7 @@ case $# in
task_purge ;;
sudo)
start_gs
task_sudo
exit_withchange
;;
task_sudo ;;
*)
start_gs
task_invalid ;;

71
includes/gs-core.sh Normal file
View File

@ -0,0 +1,71 @@
# 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 {
MESSAGE="Importing ${CONFIG_FILE} Settings"
echo -en "${STAT} $MESSAGE"
if [ -f $HOME/${LOCAL_FOLDR}/${CONFIG_FILE} ]
then
source $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
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
}
## Invalid Tasks
function task_invalid {
echo_fail
list_gs_arguments
}
## Error Validation
function error_validate {
if [ "$?" != "0" ]
then
echo_fail
exit 1
else
echo_good
fi
}
# Standard Output
function start_gs {
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
import_gs
MESSAGE="Evaluating Arguments"
echo_stat
if [ "${ROOT_CHECK_AVOID}" != "1" ]
then
root_check
fi
}
# Standard Output No Config
function start_gs_noconfig {
MESSAGE="${PROGRAM} ${VERSION} Executing"
echo_info
MESSAGE="Evaluating Arguments"
echo_stat
}

View File

@ -22,6 +22,8 @@ function task_sudo {
sudo install -m 0440 $HOME/${LOCAL_FOLDR}/templates/gs-nopasswd.sudo /etc/sudoers.d/gs-nopasswd
error_validate
exit_withchange
}
## Root Check
@ -32,7 +34,7 @@ function root_check {
MESSAGE="${MESSAGE} ${TASKTYPE}"
echo_fail
MESSAGE="${PROGRAM} Must Not Run as Root"
MESSAGE="${PROGRAM} Should Not Run As 'root'"
echo_warn
exit_nochange