luci-mod-system: prevent clearing rc.local on unrelated submit actions
Fixes: #2760
Fixes: 1c09ee5e4
("luci-mod-system: fix SimpleForm usage on file editing pages")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
1818499243
commit
1aa13ed51e
1 changed files with 5 additions and 1 deletions
|
@ -7,6 +7,7 @@ local fs = require "nixio.fs"
|
||||||
local sys = require "luci.sys"
|
local sys = require "luci.sys"
|
||||||
|
|
||||||
local inits = { }
|
local inits = { }
|
||||||
|
local handled = false
|
||||||
|
|
||||||
for _, name in ipairs(sys.init.names()) do
|
for _, name in ipairs(sys.init.names()) do
|
||||||
local index = sys.init.index(name)
|
local index = sys.init.index(name)
|
||||||
|
@ -49,9 +50,11 @@ end
|
||||||
|
|
||||||
e.write = function(self, section)
|
e.write = function(self, section)
|
||||||
if inits[section].enabled then
|
if inits[section].enabled then
|
||||||
|
handled = true
|
||||||
inits[section].enabled = false
|
inits[section].enabled = false
|
||||||
return sys.init.disable(inits[section].name)
|
return sys.init.disable(inits[section].name)
|
||||||
else
|
else
|
||||||
|
handled = true
|
||||||
inits[section].enabled = true
|
inits[section].enabled = true
|
||||||
return sys.init.enable(inits[section].name)
|
return sys.init.enable(inits[section].name)
|
||||||
end
|
end
|
||||||
|
@ -61,6 +64,7 @@ end
|
||||||
start = s:option(Button, "start", translate("Start"))
|
start = s:option(Button, "start", translate("Start"))
|
||||||
start.inputstyle = "apply"
|
start.inputstyle = "apply"
|
||||||
start.write = function(self, section)
|
start.write = function(self, section)
|
||||||
|
handled = true
|
||||||
sys.call("/etc/init.d/%s %s >/dev/null" %{ inits[section].name, self.option })
|
sys.call("/etc/init.d/%s %s >/dev/null" %{ inits[section].name, self.option })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -87,7 +91,7 @@ function t.cfgvalue()
|
||||||
end
|
end
|
||||||
|
|
||||||
function f.handle(self, state, data)
|
function f.handle(self, state, data)
|
||||||
if state == FORM_VALID then
|
if not handled and state == FORM_VALID then
|
||||||
if data.rcs then
|
if data.rcs then
|
||||||
fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n"))
|
fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n"))
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue