2015-01-16 22:38:38 +00:00
|
|
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
2015-01-16 22:46:42 +00:00
|
|
|
-- Copyright 2008-2013 Jo-Philipp Wich <jow@openwrt.org>
|
2015-01-16 22:38:38 +00:00
|
|
|
-- Licensed to the public under the Apache License 2.0.
|
2009-07-19 00:24:58 +00:00
|
|
|
|
|
|
|
local fs = require "nixio.fs"
|
2008-08-17 13:49:19 +00:00
|
|
|
local cronfile = "/etc/crontabs/root"
|
|
|
|
|
2009-10-31 15:54:11 +00:00
|
|
|
f = SimpleForm("crontab", translate("Scheduled Tasks"), translate("This is the system crontab in which scheduled tasks can be defined."))
|
2008-08-17 13:49:19 +00:00
|
|
|
|
|
|
|
t = f:field(TextValue, "crons")
|
|
|
|
t.rmempty = true
|
|
|
|
t.rows = 10
|
|
|
|
function t.cfgvalue()
|
2009-07-19 00:24:58 +00:00
|
|
|
return fs.readfile(cronfile) or ""
|
2008-08-17 13:49:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function f.handle(self, state, data)
|
|
|
|
if state == FORM_VALID then
|
|
|
|
if data.crons then
|
2009-07-19 00:24:58 +00:00
|
|
|
fs.writefile(cronfile, data.crons:gsub("\r\n", "\n"))
|
2013-03-22 12:42:48 +00:00
|
|
|
luci.sys.call("/usr/bin/crontab %q" % cronfile)
|
2008-08-17 13:49:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2009-01-20 10:56:07 +00:00
|
|
|
return f
|