check for existing crontab

This commit is contained in:
Michael Stanclift 2020-05-28 11:27:14 -05:00
parent baad802d0d
commit 4c5e7ca220
2 changed files with 22 additions and 12 deletions

View File

@ -43,9 +43,9 @@ Download the latest release from [GitHub](https://github.com/vmstan/gravity-sync
```
cd ~
wget https://github.com/vmstan/gravity-sync/archive/v1.4.4.zip
unzip v1.4.4.zip
mv ~/gravity-sync-1.4.4 ~/gravity-sync
wget https://github.com/vmstan/gravity-sync/archive/v1.5.0zip
unzip v1.5.0.zip
mv ~/gravity-sync-1.5.0 ~/gravity-sync
cd gravity-sync
```

View File

@ -2,7 +2,7 @@
# GRAVITY SYNC BY VMSTAN #####################
PROGRAM='Gravity Sync'
VERSION='1.4.4'
VERSION='1.5.0'
# 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
@ -415,12 +415,12 @@ function config_generate {
cp $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}.example $HOME/${LOCAL_FOLDR}/${CONFIG_FILE}
error_validate
MESSAGE="Enter IP or DNS of primary Pi-hole server"
echo -e "${NEED} ${MESSAGE}"
MESSAGE="Enter IP or DNS of primary Pi-hole server: "
echo -en "${NEED} ${MESSAGE}"
read INPUT_REMOTE_HOST
MESSAGE="Enter SSH user with SUDO rights on primary Pi-hole server"
echo -e "${NEED} ${MESSAGE}"
MESSAGE="Enter SSH user with SUDO rights on primary Pi-hole server: "
echo -en "${NEED} ${MESSAGE}"
read INPUT_REMOTE_USER
MESSAGE="Saving Host to ${CONFIG_FILE}"
@ -442,9 +442,9 @@ function config_generate {
echo -e "${WARN} ${MESSAGE}"
MESSAGE="Your password will be stored clear-text in the ${CONFIG_FILE}!"
echo -e "${WARN} ${MESSAGE}"
MESSAGE="Leave blank to use (preferred) SSH Key-Pair Authentication:"
echo -e "${NEED} ${MESSAGE}"
MESSAGE="Leave blank to use (preferred) SSH Key-Pair Authentication: "
echo -en "${NEED} ${MESSAGE}"
read INPUT_REMOTE_PASS
MESSAGE="Saving Password to ${CONFIG_FILE}"
@ -556,7 +556,8 @@ function exit_nochange {
## Changes Made
function exit_withchange {
SCRIPT_END=$SECONDS
echo -e "${INFO} ${PROGRAM} ${TASKTYPE} Completed in $((SCRIPT_END-SCRIPT_START)) seconds"
MESSAGE="${PROGRAM} ${TASKTYPE} Completed in $((SCRIPT_END-SCRIPT_START)) seconds"
echo -e "${INFO} ${MESSAGE}"
exit 0
}
@ -567,6 +568,7 @@ function list_gs_arguments {
echo -e ""
echo -e "Setup Options:"
echo -e " ${YELLOW}config${NC} Create a new ${CONFIG_FILE} file"
echo -e " ${YELLOW}automate${NC} Add scheduled task to run sync"
echo -e ""
echo -e "Replication Options:"
echo -e " ${YELLOW}pull${NC} Sync the ${GRAVITY_FI} database on primary PH to this server"
@ -598,6 +600,14 @@ function task_automate {
import_gs
CRON_CHECK=$(crontab -l | grep -q "$0" && echo '1' || echo '0')
if [ ${CRON_CHECK} == 1 ]
then
MESSAGE="Automation Task Already Exists"
echo -e "${INFO} ${MESSAGE}"
exit_nochange
fi
MESSAGE="Set Automation Frequency Per Hour"
echo -e "${INFO} ${MESSAGE}"