convert luci.fs users to nixio.fs api
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_services / crontab.lua
index 7a9750f3e4962104204b2ec647e5323e35cda25c..05442dd55f2f83a3187c2f1af72275a5919d5b6a 100644 (file)
@@ -12,6 +12,8 @@ You may obtain a copy of the License at
 
 $Id$
 ]]--
+
+local fs = require "nixio.fs"
 local cronfile = "/etc/crontabs/root" 
 
 f = SimpleForm("crontab", translate("a_s_crontab"), translate("a_s_crontab1"))
@@ -20,16 +22,16 @@ t = f:field(TextValue, "crons")
 t.rmempty = true
 t.rows = 10
 function t.cfgvalue()
-       return luci.fs.readfile(cronfile) or ""
+       return fs.readfile(cronfile) or ""
 end
 
 function f.handle(self, state, data)
        if state == FORM_VALID then
                if data.crons then
-                       luci.fs.writefile(cronfile, data.crons)
+                       fs.writefile(cronfile, data.crons:gsub("\r\n", "\n"))
                end
        end
        return true
 end
 
-return f
\ No newline at end of file
+return f