From d94e7c711b008b8bafd196dd7782c1789889d121 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Thu, 8 Oct 2020 20:39:30 -0500 Subject: [PATCH] 3.0.1 (#101) * 3.0.1 start * words * fix remote file owner setting * fi * fix missing sudo directory * ALL * 301 Co-authored-by: Michael Stanclift --- README.md | 13 +++------ VERSION | 2 +- docs/ADVANCED.md | 8 ++++-- docs/CHANGELOG.md | 8 ++++++ gravity-sync.sh | 67 ++++++++++++++++++++++--------------------- includes/gs-push.sh | 2 +- includes/gs-root.sh | 2 +- includes/gs-update.sh | 8 ++++-- prep/gs-install.sh | 2 +- 9 files changed, 62 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 84fe5cf..5f0f852 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,8 @@ Gravity Sync is not developed by or affiliated with the Pi-hole project. This is - Pi-hole 5.0 (or higher) must already be installed on at least two systems, using any of the Linux distribution that Pi-hole is [certified to run on](https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems). - While it is possible to leverage container/Docker deployments of Pi-hole and Gravity Sync, this configuration is currently not officially supported. Instructions here assume a "native" installation of Pi-hole. -- You will need to make sure that you have a Linux user account designated on both Pi-hole systems with `sudo` abilities on both the primary and secondary Pi-hole. Most of the pre-built images available for the Raspberry Pi already have this configured. During configuration you will be prompted to enable this for your Gravity Sync user. -- Make sure OpenSSH `ssh` and `rsync` commands are available on both the primary and secondary Pi-hole prior to installation. These two binaries are what do the heavy lifting between your Pi-hole nodes. If you're using a ultra-lightweight Pi distribution (such as DietPi) that uses Dropbear by default, you will need to convert to OpenSSH. -- You will need to make sure that `SQLite3` is installed on both Pi-hole systems, in order for the backup and restore functions against the databases to completely successfully. This should be covered by the installation of Pi-hole or already installed on most Linux distros. +- You will need to make sure that you have a Linux user account on both Pi-hole systems with `sudo` abilities on both the primary and secondary Pi-hole. Use of the `root` account is not permitted. Most of the pre-built images available for the Raspberry Pi already have this configured. During installation this user will be given passwordless sudo permissions to the `/etc/pihole` directory. +- The installer will perform checks to make sure the OpenSSH `ssh` and `rsync` commands are available on both the primary and secondary Pi-hole during installation, as well as `SQLite3` and `git` -- all four of these binaries are should be installed by default on most Linux distrobutions, including Raspberry Pi OS. If they are missing you will have an oppertunity to use whatever package manager is available on your system to correct the missing dependencies. These binaries are what do the heavy lifting between your Pi-hole nodes. (Note: If you're using a ultra-lightweight Pi distribution, such as DietPi, that uses Dropbear by default - you may need to convert it to use OpenSSH.) ### Pi-hole Architecture @@ -66,7 +65,7 @@ Login to your *primary* Pi-hole, and run the following command: export GS_INSTALL=primary && 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. It will also add a passwordless sudo configuration file for the current user to run commands in `/etc/pihole` -- The installer will then exit, and direct you to proceed to the secondary Pi-hole. +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. @@ -209,8 +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. - -## Troubleshooting - -If you get the error `sudo: a terminal is required to read the password` or `sudo: no tty present and no askpass program specified` during your execution, make sure you have [implemented passwordless sudo](https://linuxize.com/post/how-to-run-sudo-command-without-password/), as defined in the system requirements, for the user accounts on both the local and remote systems. +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 diff --git a/VERSION b/VERSION index 56fea8a..13d683c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0 \ No newline at end of file +3.0.1 \ No newline at end of file diff --git a/docs/ADVANCED.md b/docs/ADVANCED.md index 9b70644..2c16818 100644 --- a/docs/ADVANCED.md +++ b/docs/ADVANCED.md @@ -18,8 +18,8 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync ```bash cd ~ -wget https://github.com/vmstan/gravity-sync/archive/v3.0.0.zip -unzip v3.0.0.zip -d gravity-sync +wget https://github.com/vmstan/gravity-sync/archive/v3.x.x.zip +unzip v3.x.x.zip -d gravity-sync cd gravity-sync ``` @@ -306,3 +306,7 @@ For those who really love Pi-hole and Gravity Sync. Combining the best of both w Here we use `./gravity-sync pull` on the secondary Pi-hole at each side, and off-set the update intervals from the main sync. (I call this crazy, but this is what I use at home.) + +## Troubleshooting + +If you get the error `sudo: a terminal is required to read the password` or `sudo: no tty present and no askpass program specified` during your execution, make sure you have [implemented passwordless sudo](https://linuxize.com/post/how-to-run-sudo-command-without-password/), as defined in the system requirements, for the user accounts on both the local and remote systems. \ No newline at end of file diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e0de4ac..b2e61f1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,14 @@ Lastly, we adopts Pi-hole style iconography such as `✓ ✗ e ! ?` instead of ` Enjoy! +#### 3.0.1 + +- `dev` function now automatically updates Gravity Sync after application. +- `dev` function pulls new branches down before prompting to select which one to update against. +- Minor shuffle of `gravity-sync.sh` contents. +- Clarify installation requirements in `README.md`. +- Fixes issues with permissions on `gravity.db` after push operations. + ## 2.2 ### The Purged Release diff --git a/gravity-sync.sh b/gravity-sync.sh index 6c3ab02..188d52f 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.0' +VERSION='3.0.1' # 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 @@ -90,6 +90,39 @@ function import_gs { 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 @@ -119,40 +152,8 @@ source includes/gs-purge.sh # Exit Codes source includes/gs-exit.sh -# 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 -} - # SCRIPT EXECUTION ########################### -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 -} - case $# in 0) start_gs diff --git a/includes/gs-push.sh b/includes/gs-push.sh index 7210b09..dd64617 100644 --- a/includes/gs-push.sh +++ b/includes/gs-push.sh @@ -48,7 +48,7 @@ function push_gs_grav { MESSAGE="Setting Ownership on ${GRAVITY_FI}" echo_stat CMD_TIMEOUT='15' - CMD_REQUESTED="sudo chown ${RFILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI}" + CMD_REQUESTED="sudo chown ${REMOTE_FILE_OWNER} ${PIHOLE_DIR}/${GRAVITY_FI}" create_sshcmd } diff --git a/includes/gs-root.sh b/includes/gs-root.sh index 7d17238..1809165 100644 --- a/includes/gs-root.sh +++ b/includes/gs-root.sh @@ -14,7 +14,7 @@ function task_sudo { echo_stat NEW_SUDO_USER=$(whoami) - echo -e "${NEW_SUDO_USER} ALL=(ALL) NOPASSWD: ${PIHOLE_DIR}" > $HOME/${LOCAL_FOLDR}/templates/gs-nopasswd.sudo + echo -e "${NEW_SUDO_USER} ALL=(ALL) NOPASSWD: ALL" > $HOME/${LOCAL_FOLDR}/templates/gs-nopasswd.sudo error_validate MESSAGE="Installing Sudoer.d File" diff --git a/includes/gs-update.sh b/includes/gs-update.sh index 66875bf..f6ae97e 100644 --- a/includes/gs-update.sh +++ b/includes/gs-update.sh @@ -103,6 +103,11 @@ function task_devmode { echo_stat touch $HOME/${LOCAL_FOLDR}/dev error_validate + + MESSAGE="Updating Cache" + echo_stat + git fetch --all >/dev/null 2>&1 + error_validate git branch -r @@ -113,8 +118,7 @@ function task_devmode { echo -e "BRANCH='${INPUT_BRANCH}'" >> $HOME/${LOCAL_FOLDR}/dev fi - MESSAGE="Run UPDATE to apply changes" - echo_info + update_gs exit_withchange } diff --git a/prep/gs-install.sh b/prep/gs-install.sh index ce1549e..389c3eb 100644 --- a/prep/gs-install.sh +++ b/prep/gs-install.sh @@ -96,7 +96,7 @@ then else echo -e "[${CYAN}>${NC}] Creating Sudoers.d File" touch /tmp/gs-nopasswd.sudo - echo -e "${CURRENTUSER} ALL=(ALL) NOPASSWD: /etc/pihole" > /tmp/gs-nopasswd.sudo + echo -e "${CURRENTUSER} ALL=(ALL) NOPASSWD: ALL" > /tmp/gs-nopasswd.sudo sudo install -m 0440 /tmp/gs-nopasswd.sudo /etc/sudoers.d/gs-nopasswd if [ "$GS_INSTALL" != "secondary" ]