From 17fe31bfb901b6debd76d6e97d1eaa5361baad9a Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Wed, 5 Jul 2017 23:47:08 +0100 Subject: [PATCH] fixed no cron set for user error --- setip.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/setip.sh b/setip.sh index 5a968a6..d96d038 100755 --- a/setip.sh +++ b/setip.sh @@ -7,8 +7,8 @@ function getKey () { # Variables TRUE=1 -VDMUSER="vdm" -VDMHOME="/home/vdm" +VDMUSER="llewellyn" +VDMHOME="/home/llewellyn" VDMSCRIPT="https://raw.githubusercontent.com/vdm-io/dynamic-ip/$BRANCH/setip.sh" VDMIPSERVER="https://www.vdm.io/setip" @@ -24,8 +24,14 @@ if [ -f $VDMHOME/vdmip.cron ]; then echo "Crontab already configured for updates...Skipping" else echo -n "Adding crontab entry for continued updates..." - currentCron=$(crontab -u $VDMUSER -l) - echo "$currentCron" > $VDMHOME/vdmip.cron + # check if user crontab is set + currentCron=$(crontab -u $VDMUSER -l 2>/dev/null) + if [[ -z "${currentCron// }" ]]; then + currentCron="# VDM crontab settings" + echo "$currentCron" > $VDMHOME/vdmip.cron + else + echo "$currentCron" > $VDMHOME/vdmip.cron + fi # check if the MAILTO is already set if [[ $currentCron != *"MAILTO"* ]]; then echo "MAILTO=\"\"" >> $VDMHOME/vdmip.cron