Changeset 8333

Show
Ignore:
Timestamp:
03/07/12 14:06:17 (16 months ago)
Author:
jow
Message:

applications/luci-multiwan: use new uci disable option instead of disabling the init script

Location:
luci/trunk/applications/luci-multiwan/luasrc/model/cbi/multiwan
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua

    r6211 r8333  
    55 
    66s = m:section(NamedSection, "config", "multiwan", "") 
     7 
    78e = s:option(Flag, "enabled", translate("Enable")) 
    89e.rmempty = false 
     10e.default = e.enabled 
    911 
    1012function e.write(self, section, value) 
    11         local cmd = (value == "1") and "enable" or "disable" 
    12         if value ~= "1" then 
    13                 os.execute("/etc/init.d/multiwan stop") 
    14         end 
    15         os.execute("/etc/init.d/multiwan " .. cmd) 
    16 end 
    17  
    18 function e.cfgvalue(self, section) 
    19         return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0" 
     13    if value == "0" then 
     14        os.execute("/etc/init.d/multiwan stop") 
     15    else 
     16        os.execute("/etc/init.d/multiwan enable") 
     17    end 
     18    Flag.write(self, section, value) 
    2019end 
    2120 
  • luci/trunk/applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwanmini.lua

    r6211 r8333  
    55 
    66s = m:section(NamedSection, "config", "multiwan", "") 
     7 
    78e = s:option(Flag, "enabled", translate("Enable")) 
    89e.rmempty = false 
     10e.default = "1" 
    911 
    1012function e.write(self, section, value) 
    11         local cmd = (value == "1") and "enable" or "disable" 
    12         if value ~= "1" then 
    13                 os.execute("/etc/init.d/multiwan stop") 
    14         end 
    15         os.execute("/etc/init.d/multiwan " .. cmd) 
    16 end 
    17  
    18 function e.cfgvalue(self, section) 
    19         return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0" 
     13    if value == "0" then 
     14        os.execute("/etc/init.d/multiwan stop") 
     15    else 
     16        os.execute("/etc/init.d/multiwan enable") 
     17    end 
     18    Flag.write(self, section, value) 
    2019end 
    2120