diff options
Diffstat (limited to 'modules/luci-mod-system/luasrc/model/cbi')
3 files changed, 15 insertions, 4 deletions
diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/backupfiles.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/backupfiles.lua index ee2401e93d..c81466c874 100644 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/backupfiles.lua +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/backupfiles.lua @@ -20,7 +20,8 @@ if luci.http.formvalue("display") ~= "list" then l.inputstyle = "apply" c = f:option(TextValue, "_custom") - c.rmempty = false + c.forcewrite = true + c.rmempty = true c.cols = 70 c.rows = 30 @@ -28,9 +29,15 @@ if luci.http.formvalue("display") ~= "list" then return nixio.fs.readfile("/etc/sysupgrade.conf") end - c.write = function(self, section, value) - value = value:gsub("\r\n?", "\n") - return nixio.fs.writefile("/etc/sysupgrade.conf", value) + m.handle = function(self, state, data) + if state == FORM_VALID then + if data._custom then + nixio.fs.writefile("/etc/sysupgrade.conf", data._custom:gsub("\r\n", "\n")) + else + nixio.fs.writefile("/etc/sysupgrade.conf", "") + end + end + return true end else m.submit = false diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/crontab.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/crontab.lua index 016a6199aa..beb24e7cae 100644 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/crontab.lua +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/crontab.lua @@ -11,6 +11,7 @@ f = SimpleForm("crontab", translate("Scheduled Tasks"), "crontab file was empty before editing.")) t = f:field(TextValue, "crons") +f.forcewrite = true t.rmempty = true t.rows = 10 function t.cfgvalue() diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua index 9e19ac50a2..c3f14540e3 100644 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/startup.lua @@ -78,6 +78,7 @@ f = SimpleForm("rc", translate("Local Startup"), translate("This is the content of /etc/rc.local. Insert your own commands here (in front of 'exit 0') to execute them at the end of the boot process.")) t = f:field(TextValue, "rcs") +t.forcewrite = true t.rmempty = true t.rows = 20 @@ -89,6 +90,8 @@ function f.handle(self, state, data) if state == FORM_VALID then if data.rcs then fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n")) + else + fs.writefile("/etc/rc.local", "") end end return true |