diff --git a/ADVANCED.md b/ADVANCED.md index 4ac0662..62dd9cd 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -14,8 +14,8 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync ```bash cd ~ -wget https://github.com/vmstan/gravity-sync/archive/v1.8.2.zip -unzip v1.8.2.zip -d gravity-sync +wget https://github.com/vmstan/gravity-sync/archive/v1.8.3.zip +unzip v1.8.3.zip -d gravity-sync cd gravity-sync ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f3b3b3..4db75da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,12 @@ There is nothing really sexy here, but a lot of changes under the covers to impr - Adds custom port specification to ssh-copy-id and dropbearkey commands during configuration generation. - Generally better error handling of configuration options. +#### 1.8.3 +- Simplified method for input of automation frequency when running `./gravity-sync.sh automate` function. +- Now removes existing automation task from crontab, if it exists, when re-running `automate` function. +- Automation can be disabled by setting frequency to `0` when prompted. +- Adds `dev` tag to `./gravity-sync.sh version` output for users running off the development branch. + #### 1.8.2 - Corrects issue where `custom.list` file would not replicate if the file didn't exist locally, and there were no other changes to replicate. [#39](https://github.com/vmstan/gravity-sync/issues/39) diff --git a/README.md b/README.md index 4078711..df7245a 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ Automation of sync is accomplished by adding an execution of the script to the u ./gravity-sync.sh automate ``` -Select the frequency per hour that you'd like to sync (once, twice, quadrice, etc) and that's it. +Select the frequency per hour (in minutes) that you'd like to sync and that's it. Now, make another small adjustment to your primary settings and wait until annointed time to see if your changes have been synchronized. If so, profit! If not, start from the beginning. From this point forward any blocklist changes you make to the primary will reflect on the secondary within the frequency you select. @@ -135,7 +135,7 @@ If you'd like to see the log of what was run the last crontab, you can view that Keep in mind if your cron task has never run, you will not see any valid output from this command. ### Adjusting Automation -You can verify your cron entry by running `crontab -l` and see it listed at the bottom of the file. If you decide to remove or change your frequency, you'll need to run `crontab -e` and adjust this by hand. If you're unsure of how to adjust the timers by hand, just delete the entire line in the crontab file and then re-run the `./gravity-sync automate` function. +You can verify your existing automation entry by running `crontab -l` and see it listed at the bottom of the crontab file. If you decide to remove or change your frequency (as of version 1.8.3) you can run `./gravity-sync.sh automate` again and pick a new timing, including setting it to 0 to disable automation. ## Advanced Installation Please review the [Advanced Installation](https://github.com/vmstan/gravity-sync/blob/master/ADVANCED.md) guide for assistance. diff --git a/VERSION b/VERSION index 0bfbd57..fe4e75f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.2 \ No newline at end of file +1.8.3 \ No newline at end of file diff --git a/gravity-sync.sh b/gravity-sync.sh index 20e5789..17ef29d 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -3,7 +3,7 @@ SCRIPT_START=$SECONDS # GRAVITY SYNC BY VMSTAN ##################### PROGRAM='Gravity Sync' -VERSION='1.8.2' +VERSION='1.8.3' # 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 @@ -1132,8 +1132,15 @@ function show_version { MESSAGE="${BLUE}https://github.com/vmstan/gravity-sync${NC}" echo_info + + if [ -f $HOME/${LOCAL_FOLDR}/dev ] + then + DEVVERSION="dev" + else + DEVVERSION="" + fi - MESSAGE="Running Version: ${GREEN}${VERSION}${NC}" + MESSAGE="Running Version: ${GREEN}${VERSION}${NC} ${DEVVERSION}" echo_info GITVERSION=$(curl -sf https://raw.githubusercontent.com/vmstan/gravity-sync/master/VERSION) @@ -1161,63 +1168,64 @@ function task_automate { import_gs + CRON_EXIST='0' CRON_CHECK=$(crontab -l | grep -q "${GS_FILENAME}" && echo '1' || echo '0') if [ ${CRON_CHECK} == 1 ] then MESSAGE="Automation Task Already Exists" echo_info - MESSAGE="Use 'crontab -e' to manually remove/edit" - echo_info - exit_nochange + CRON_EXIST='1' fi - - MESSAGE="Set Automation Frequency Per Hour" - echo_info - - MESSAGE="1 = Every 60 Minutes" - echo -e "++++++ ${MESSAGE}" - MESSAGE="2 = Every 30 Minutes" - echo -e "++++++ ${MESSAGE}" - MESSAGE="4 = Every 15 Minutes" - echo -e "++++++ ${MESSAGE}" - MESSAGE="6 = Every 10 Minutes" - echo -e "++++++ ${MESSAGE}" - MESSAGE="12 = Every 05 Minutes" - echo -e "++++++ ${MESSAGE}" - MESSAGE="Input Automation Frequency" + MESSAGE="Sync Frequency in Minutes (1-30) or 0 to Disable" echo_need read INPUT_AUTO_FREQ - if [ $INPUT_AUTO_FREQ == 1 ] + if [ $INPUT_AUTO_FREQ -gt 30 ] then - AUTO_FREQ='60' - elif [ $INPUT_AUTO_FREQ == 2 ] - then - AUTO_FREQ='30' - elif [ $INPUT_AUTO_FREQ == 4 ] - then - AUTO_FREQ='15' - elif [ $INPUT_AUTO_FREQ == 6 ] - then - AUTO_FREQ='10' - elif [ $INPUT_AUTO_FREQ == 12 ] - then - AUTO_FREQ='5' - else - MESSAGE="Invalid Input" - echo -e "${FAIL} ${MESSAGE}" + MESSAGE="Invalid Frequency Range" + echo_fail exit_nochange - fi + elif [ $INPUT_AUTO_FREQ -lt 1 ] + then + if [ $CRON_EXIST == 1 ] + then + clear_cron - MESSAGE="Saving to Crontab" - echo_stat - (crontab -l 2>/dev/null; echo "*/${AUTO_FREQ} * * * * ${BASH_PATH} $HOME/${LOCAL_FOLDR}/${GS_FILENAME} pull > ${LOG_PATH}/${CRONJOB_LOG}") | crontab - + MESSAGE="Automation Disabled" + echo_info + else + MESSAGE="No Automation Scheduled" + echo_info + exit_nochange + fi + else + if [ $CRON_EXIST == 1 ] + then + clear_cron + fi + + MESSAGE="Saving New Automation" + echo_stat + (crontab -l 2>/dev/null; echo "*/${INPUT_AUTO_FREQ} * * * * ${BASH_PATH} $HOME/${LOCAL_FOLDR}/${GS_FILENAME} pull > ${LOG_PATH}/${CRONJOB_LOG}") | crontab - error_validate - + fi exit_withchange } +## Clear Existing Automation Settings +function clear_cron { + MESSAGE="Removing Existing Automation" + echo_stat + + crontab -l > cronjob-old.tmp + sed '/.sh pull/d' cronjob-old.tmp > cronjob-new.tmp + crontab cronjob-new.tmp 2>/dev/null + error_validate + rm cronjob-old.tmp + rm cronjob-new.tmp +} + ## Configure Task function task_configure { TASKTYPE='CONFIGURE'