Commit 2b74e006 authored by sokai's avatar sokai

better cron modularisation (+CRONTABPATH +CRONTABUSER)

parent 2cde884d
......@@ -20,7 +20,8 @@ EXTRA_COMMANDS="status update upgrade"
## script
SCRIPTVERSION='160201-1'
SCRIPT=${SCRIPTPATH}${SCRIPTNAME}
CRONTAB='/var/spool/cron/crontabs/root'
CRONTABPATH='/var/spool/cron/crontabs/' # _with_ trailing / !
CRONTABUSER='root'
CRONINTERVAL=$(awk 'BEGIN{srand();print int(rand()*60)}') # run cron hourly at a random minute
WIF=$(ifconfig | awk '/10\.22\.[0-9]{1,3}\.[0-9]{1,3}/ {print $1}' RS="\n\n" | grep -m 1 wlan) # http://stackoverflow.com/a/18344694/338049
......@@ -47,10 +48,10 @@ SYSTEMTYPE=$(grep 'system type' /proc/cpuinfo|awk '{$1=$2=""; print}'| sed 's/
start() {
if ! $(grep -q ${SCRIPT} ${CRONTAB}); then
CRONJOB="${CRONINTERVAL} * * * * ${SCRIPT} update # FFP Access Points DataBase"
echo "${CRONJOB}" >> ${CRONTAB}
echo "root" > /var/spool/cron/crontabs/cron.update # reload crontab
logger -t ${SCRIPTNAME} "cron job added (${SCRIPT} start)"
CRONJOB="${CRONINTERVAL} * * * * ${SCRIPT} update # FFP-AccessPointsDataBase"
echo "${CRONJOB}" >> ${CRONTABPATH}${CRONTABUSER}
echo "${CRONTABUSER}" > /var/spool/cron/crontabs/cron.update # reload crontab
logger -t ${SCRIPTNAME} "cron job for user ${CRONTABUSER} added (${SCRIPT} start)"
update
fi
}
......@@ -160,4 +161,4 @@ status() {
# else [ $CRONTABENTRY -gt 1 ]
# echo "WARN found more then one entry for freifunkmap in crontab, but the update should work anyway"
# fi
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment