From 7d09218524610beb6ac52646155c41bd5d70be62 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Sat, 10 Oct 2020 11:30:40 -0500 Subject: [PATCH] 3.0.2 (#104) * version change * Nova * No-config function * Markdown cleanup * Create gs-core file * correct missing includes via cron Co-authored-by: Michael Stanclift Co-authored-by: Michael Stanclift --- .nova/Configuration.json | 4 ++ README.md | 18 +++--- VERSION | 2 +- docs/CHANGELOG.md | 8 ++- gravity-sync.sh | 118 ++++++++++----------------------------- includes/gs-core.sh | 71 +++++++++++++++++++++++ includes/gs-root.sh | 4 +- 7 files changed, 123 insertions(+), 102 deletions(-) create mode 100644 .nova/Configuration.json create mode 100644 includes/gs-core.sh diff --git a/.nova/Configuration.json b/.nova/Configuration.json new file mode 100644 index 0000000..0eb1735 --- /dev/null +++ b/.nova/Configuration.json @@ -0,0 +1,4 @@ +{ + "editor.default_syntax" : "shell", + "workspace.name" : "Gravity Sync" +} diff --git a/README.md b/README.md index 5f0f852..6eff972 100644 --- a/README.md +++ b/README.md @@ -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,25 +67,25 @@ 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 ``` -This will verify you have everything necessary to use Gravity Sync. The installer will then use Git to make a copy of the Gravity Sync executables in your home directory, and direct you to proceed to Configuration step below. Once this has completed, you will now have a folder called `gravity-sync` in your home directory. Everything Gravity Sync runs from there. +This will verify you have everything necessary to use Gravity Sync. The installer will then use Git to make a copy of the Gravity Sync executables in your home directory, and direct you to proceed to Configuration step below. Once this has completed, you will now have a folder called `gravity-sync` in your home directory. Everything Gravity Sync runs from there. 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 @@ -166,9 +166,9 @@ You can verify your existing automation entry by running `crontab -l` and see it If you'd like to know what version of the script you have running, check the built in version checker. It will notify you if there are updates available. - ```bash - ./gravity-sync.sh version - ``` +```bash +./gravity-sync.sh version +``` You can then run the built-in updater to get the latest version of all the files. Both the `version` and `update` commands reach out to GitHub, so outbound access to GitHub.com is required. @@ -208,4 +208,4 @@ If you are completely uninstalling Gravity Sync, the last step would be to remov ## Advanced Installation -Please review the [Advanced Installation](https://github.com/vmstan/gravity-sync/blob/master/docs/ADVANCED.md) guide for more assistance. \ No newline at end of file +Please review the [Advanced Installation](https://github.com/vmstan/gravity-sync/blob/master/docs/ADVANCED.md) guide for more assistance. diff --git a/VERSION b/VERSION index 13d683c..d9c62ed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.1 \ No newline at end of file +3.0.2 \ No newline at end of file diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b2e61f1..aaf07c7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 @@ -49,7 +55,7 @@ This release also adds the `./gravity-sync.sh purge` function that will totally - Adds variable to easily override Pi-hole binary directory for remote host, seperate from local host. (Thanks @dpraul) - Rewritten `dev` option now lets you select the branch to pull code against, allowing for more flexibility in updating against test versions of the code. The `beta` function introduced in 2.1.5 has now been removed. - Validates existance of SQLite installation on local Pi-hole. -- Adds Gravity Sync permissions for running user to local `/etc/sudoer.d` file during `config` operation. +- Adds Gravity Sync permissions for running user to local `/etc/sudoer.d` file during `config` operation. - Adds `./gravity-sync.sh sudo` function to create above file for existing setups, or to configure the remote Pi-hole by placing the installer files on that system. This is not required for existing functional installs, but this should also negate the need to give the Gravity Sync user NOPASSWD permissions to the entire system. ## 2.1 diff --git a/gravity-sync.sh b/gravity-sync.sh index 1c9fa40..674e9cc 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -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 - - # MESSAGE="Targeting ${REMOTE_USER}@${REMOTE_HOST}" - # echo_info +# Core Functions +source $HOME/${LOCAL_FOLDR}/includes/gs-core.sh - # 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 ########################### @@ -159,11 +105,11 @@ case $# in start_gs task_smart ;; 1) - case $1 in + case $1 in smart|sync) start_gs task_smart ;; - pull) + pull) start_gs task_pull ;; push) @@ -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 ;; @@ -220,7 +158,7 @@ case $# in ;; 2) - case $1 in + case $1 in auto|automate) start_gs task_automate ;; @@ -228,7 +166,7 @@ case $# in ;; 3) - case $1 in + case $1 in auto|automate) start_gs task_automate $2 $3 ;; diff --git a/includes/gs-core.sh b/includes/gs-core.sh new file mode 100644 index 0000000..b4bd81e --- /dev/null +++ b/includes/gs-core.sh @@ -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 +} \ No newline at end of file diff --git a/includes/gs-root.sh b/includes/gs-root.sh index 1809165..4ae6f98 100644 --- a/includes/gs-root.sh +++ b/includes/gs-root.sh @@ -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