File: //etc.defaults/init/synoscheduler.conf
description "synoscheduler"
author "System Integration Team"
task
console log
script
SCHED_DB=/usr/syno/etc/sched_status.sqlite
SCHED_SETTING=/usr/syno/etc/esynoscheduler/esynoscheduler-conf.json
SCHED_TASK_CONFIG=/usr/syno/etc/scheduled_tasks
ret=0
if [ -f "$SCHED_TASK_CONFIG" ]; then
if ! /bin/chmod 644 "$SCHED_TASK_CONFIG"; then
echo "$(/bin/date -u): failed to chmod $SCHED_TASK_CONFIG"
fi
if ! /bin/chown root:root "$SCHED_TASK_CONFIG"; then
echo "$(/bin/date -u): failed to chown $SCHED_TASK_CONFIG"
fi
fi
CONFIG_CHECK_FAILED_BACKUP=/usr/syno/etc/scheduled_tasks_config_check_failed_backup
if ( ! /usr/syno/bin/synoschedtask "--check-task-config-integrity" ) && [ ! -d "$CONFIG_CHECK_FAILED_BACKUP" ]; then
/bin/cp -rf /usr/syno/etc/scheduled_tasks_backup "$CONFIG_CHECK_FAILED_BACKUP"
/bin/cp -af /usr/syno/etc/scheduled_tasks "$CONFIG_CHECK_FAILED_BACKUP"
echo "$(/bin/date -u): /usr/syno/etc/scheduled_tasks may be invalid"
fi
CHECK_DB_RESULT=$(/bin/sqlite3 $SCHED_DB "PRAGMA integrity_check")
if [ "$CHECK_DB_RESULT" != "ok" ]; then
echo "${SCHED_DB} is corrupted, rename it to ${SCHED_DB}.corrupt."
mv $SCHED_DB $SCHED_DB.corrupt
ret=1
fi
if ! /usr/sbin/initctl start synoscheduler-vmtouch; then
echo "`/bin/date -u`: failed to run synoscheduler-vmtouch"
ret=1
fi
if [ -f $SCHED_SETTING ]; then
if ! chmod 644 $SCHED_SETTING; then
echo "`/bin/date -u`: failed to chmod $SCHED_SETTING"
ret=1
fi
if ! /bin/cp $SCHED_SETTING /tmp; then
echo "`/bin/date -u`: failed to copy $SCHED_SETTING to /tmp"
ret=1
fi
fi
echo "`/bin/date -u`: Copy files to /tmp, exit value: $ret"
exit $ret
end script