Updated the cronjob to be ignored if needed.

This commit is contained in:
Llewellyn van der Merwe 2020-03-07 18:17:36 +02:00
parent 21e3811d9e
commit fba123002f
No known key found for this signature in database
GPG Key ID: 8A8F406BA7238C4E
1 changed files with 39 additions and 32 deletions

17
sync.sh
View File

@ -142,11 +142,11 @@ function echoTweak () {
# Set cronjob without removing existing
function setCron () {
if [ -f "${CRONPATH}" ]; then
echoTweak "Crontab already configured for updates..."
echo "Skipping"
else
echo "Adding crontab entry for continued updates..."
if [ ! -f "${CRONPATH}" ]; then
echo ""
echo -ne "\n Would you like set the cronjob now? [y/N]: "
read -r answer
if [[ $answer == "y" ]]; then
# check if user crontab is set
currentCron=$(crontab -u $CLIENTUSER -l 2>/dev/null)
if [[ -z "${currentCron// }" ]]; then
@ -174,6 +174,13 @@ function setCron () {
crontab -u $ACTIVEUSER "${CRONPATH}"
# close the block
echo -e "\n ################################################################################################"
else
# to avoid asking again
echo "See ${CRONPATH} for more details!"
echo '# Do not remove this file!' > "${CRONPATH}"
echo '# Please set your cronjob manually, with the following details' >> "${CRONPATH}"
echo "# 0 4 * * * curl -s $SCRIPTURL | bash" >> "${CRONPATH}"
fi
fi
}