This commit is contained in:
Michael Stanclift 2020-06-22 10:27:30 -05:00
parent c0e4880467
commit e27a93905a

View File

@ -1174,75 +1174,57 @@ function task_automate {
MESSAGE="Automation Task Already Exists" MESSAGE="Automation Task Already Exists"
echo_info echo_info
CRON_EXIST="1" CRON_EXIST="1"
# MESSAGE="Use 'crontab -e' to manually remove/edit"
# echo_info
# exit_nochange
fi 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="Sync Frequency in Minutes (1-30)" MESSAGE="Sync Frequency in Minutes (0-30)"
echo_need echo_need
read INPUT_AUTO_FREQ read INPUT_AUTO_FREQ
if [ $INPUT_AUTO_FREQ -gt 30 ] 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'
then then
MESSAGE="Invalid Input" MESSAGE="Invalid Input"
echo_fail echo_fail
exit_nochange exit_nochange
elif [ $INPUT_AUTO_FREQ -lt 1 ] elif [ $INPUT_AUTO_FREQ -lt 1 ]
then then
MESSAGE="Invalid Input" if [ $CRON_EXIST == 1 ]
echo_fail then
exit_nochange clear_cron
MESSAGE="Automation Disabled"
echo_info
else
MESSAGE="Invalid Input"
echo_stat
exit_nochange
fi
else else
if [ $CRON_EXIST == 1 ] if [ $CRON_EXIST == 1 ]
then then
MESSAGE="Removing Existing Automation" clear_cron
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
fi fi
MESSAGE="Saving New Automation" MESSAGE="Saving New Automation"
echo_stat echo_stat
(crontab -l 2>/dev/null; echo "*/${INPUT_AUTO_FREQ} * * * * ${BASH_PATH} $HOME/${LOCAL_FOLDR}/${GS_FILENAME} pull > ${LOG_PATH}/${CRONJOB_LOG}") | crontab - (crontab -l 2>/dev/null; echo "*/${INPUT_AUTO_FREQ} * * * * ${BASH_PATH} $HOME/${LOCAL_FOLDR}/${GS_FILENAME} pull > ${LOG_PATH}/${CRONJOB_LOG}") | crontab -
error_validate error_validate
exit_withchange
fi 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 ## Configure Task
function task_configure { function task_configure {
TASKTYPE='CONFIGURE' TASKTYPE='CONFIGURE'