summaryrefslogtreecommitdiffstats
path: root/cron-model.lua
blob: 1f39296facdde85ffa63f953f5a1632a98d4d29e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module (..., package.seeall)
require "format"
require "fs"

get = function (self)
	f = io.open("/etc/crontabs/root")
	crontab = f:read("*a")
	
	f:close()	
	return (cfe{value=crontab, name="crontab",type="longtext"})
end

set = function(self, cron)
	checksum1 = fs.md5sum_file("/etc/crontabs/root")
	newcron = format.dostounix(cron)
	file.write_file("/etc/crontabs/root", newcron)	
	checksum2 = fs.md5sum_file("/etc/crontabs/root")
	if checksum1 == checksum2 then
	status = "Crontab file unchanged."
	else
	status = "Crontab file changed successfully"
	end
	
	return(cfe{value=status, name="status"})
end