treewide: replace normal uses of luci.model.uci with simple-uci to reduce LuCI dependencies
We also make use of the boolean support of simple-uci to make scripts clearer.
This commit is contained in:
		
							parent
							
								
									6f48fc428f
								
							
						
					
					
						commit
						6cf03bab37
					
				| @ -1,18 +1,14 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require 'luci.model.uci' | ||||
| local c = uci.cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| c:delete('alfred', 'alfred') | ||||
| c:section('alfred', 'alfred', 'alfred', | ||||
| 	  { | ||||
| uci:delete('alfred', 'alfred') | ||||
| uci:section('alfred', 'alfred', 'alfred', { | ||||
| 	interface = 'local-node', | ||||
| 	mode = 'slave', | ||||
| 	batmanif = 'bat0', | ||||
| 		  start_vis = '1', | ||||
| 		  run_facters = '0', | ||||
| 	  } | ||||
| ) | ||||
| 	start_vis = true, | ||||
| 	run_facters = false, | ||||
| }) | ||||
| 
 | ||||
| c:save('alfred') | ||||
| uci:save('alfred') | ||||
|  | ||||
| @ -1,45 +1,39 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require 'luci.model.uci' | ||||
| 
 | ||||
| local c = uci.cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| for name, config in pairs(site.autoupdater.branches) do | ||||
| 	c:delete('autoupdater', name) | ||||
| 	c:section('autoupdater', 'branch', name, | ||||
| 		  { | ||||
| 	uci:delete('autoupdater', name) | ||||
| 	uci:section('autoupdater', 'branch', name, { | ||||
| 		name = config.name, | ||||
| 		mirror = config.mirrors, | ||||
| 		good_signatures = config.good_signatures, | ||||
| 		pubkey = config.pubkeys, | ||||
| 		  } | ||||
| 	) | ||||
| 	}) | ||||
| end | ||||
| 
 | ||||
| if not c:get('autoupdater', 'settings') then | ||||
| 	local enabled = 0 | ||||
| if not uci:get('autoupdater', 'settings') then | ||||
| 	local enabled = false | ||||
| 	local branch = site.autoupdater.branch | ||||
| 
 | ||||
| 	local f = io.open('/lib/gluon/autoupdater/default_branch') | ||||
| 	if f then | ||||
| 		enabled = 1 | ||||
| 		enabled = true | ||||
| 		branch = f:read('*line') | ||||
| 		f:close() | ||||
| 	end | ||||
| 
 | ||||
| 	c:section('autoupdater', 'autoupdater', 'settings', | ||||
| 		  { | ||||
| 	uci:section('autoupdater', 'autoupdater', 'settings', { | ||||
| 		enabled = enabled, | ||||
| 		branch = branch, | ||||
| 		  } | ||||
| 	) | ||||
| 	}) | ||||
| end | ||||
| 
 | ||||
| c:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release') | ||||
| uci:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release') | ||||
| 
 | ||||
| c:save('autoupdater') | ||||
| uci:save('autoupdater') | ||||
| 
 | ||||
| 
 | ||||
| local autoupdater_util = require 'autoupdater.util' | ||||
|  | ||||
| @ -6,7 +6,7 @@ local util = require 'gluon.util' | ||||
| 
 | ||||
| local ip = require 'luci.ip' | ||||
| local lutil = require 'luci.util' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| local ip4, netmask, ip6 | ||||
| @ -58,15 +58,15 @@ uci:save('network') | ||||
| 
 | ||||
| 
 | ||||
| local dnsmasq = uci:get_first('dhcp', 'dnsmasq') | ||||
| uci:set('dhcp', dnsmasq, 'boguspriv', 0) | ||||
| uci:set('dhcp', dnsmasq, 'localise_queries', 0) | ||||
| uci:set('dhcp', dnsmasq, 'rebind_protection', 0) | ||||
| uci:set('dhcp', dnsmasq, 'boguspriv', false) | ||||
| uci:set('dhcp', dnsmasq, 'localise_queries', false) | ||||
| uci:set('dhcp', dnsmasq, 'rebind_protection', false) | ||||
| 
 | ||||
| uci:delete('dhcp', 'client') | ||||
| uci:section('dhcp', 'dhcp', 'client', | ||||
| 	{ | ||||
| 		interface = 'client', | ||||
| 		ignore = 1, | ||||
| 		ignore = true, | ||||
| 	} | ||||
| ) | ||||
| 
 | ||||
|  | ||||
| @ -3,16 +3,18 @@ | ||||
| local site = require 'gluon.site_config' | ||||
| local util = require 'gluon.util' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| local function is_disabled(config, name) | ||||
|   local disabled = config and config.disabled | ||||
|   local disabled | ||||
|   if uci:get('wireless', name) then | ||||
|     disabled = uci:get_bool('wireless', name, 'disabled') | ||||
|   else | ||||
|     disabled = config and config.disabled | ||||
|   end | ||||
| 
 | ||||
|   return disabled and 1 or 0 | ||||
|   return disabled | ||||
| end | ||||
| 
 | ||||
| local function configure_client(config, radio, index, suffix) | ||||
| @ -38,7 +40,7 @@ local function configure_client(config, radio, index, suffix) | ||||
|       ssid = config.ssid, | ||||
|       macaddr = macaddr, | ||||
|       ifname = suffix and 'client' .. suffix, | ||||
|       disabled = disabled, | ||||
|       disabled = disabled or false, | ||||
|     } | ||||
|   ) | ||||
| end | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| local cbi = require "luci.cbi" | ||||
| local i18n = require "luci.i18n" | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| 
 | ||||
| local M = {} | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| local cbi = require "luci.cbi" | ||||
| local i18n = require "luci.i18n" | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local site = require 'gluon.site_config' | ||||
| 
 | ||||
| local M = {} | ||||
|  | ||||
| @ -4,7 +4,7 @@ local gluon_luci = require 'gluon.luci' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| local pretty_hostname = require 'pretty_hostname' | ||||
| 
 | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| 
 | ||||
| local hostname = pretty_hostname.get(uci) | ||||
| local contact = uci:get_first('gluon-node-info', 'owner', 'contact') | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| local wizard_dir = "/lib/gluon/config-mode/wizard/" | ||||
| local i18n = luci.i18n | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local fs = require "nixio.fs" | ||||
| local util = require "nixio.util" | ||||
| local f, s | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| local cbi = require "luci.cbi" | ||||
| local i18n = require "luci.i18n" | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local site = require 'gluon.site_config' | ||||
| 
 | ||||
| local M = {} | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| local cbi = require "luci.cbi" | ||||
| local i18n = require "luci.i18n" | ||||
| local pretty_hostname = require "pretty_hostname" | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| 
 | ||||
| local M = {} | ||||
| 
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| local uci = luci.model.uci.cursor() | ||||
| local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0") | ||||
| local uci = require("simple-uci").cursor() | ||||
| local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") | ||||
| 
 | ||||
| if meshvpn_enabled ~= "1" then | ||||
| if not meshvpn_enabled then | ||||
|   return nil | ||||
| else | ||||
|   local i18n = require "luci.i18n" | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| local cbi = require "luci.cbi" | ||||
| local i18n = require "luci.i18n" | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| 
 | ||||
| local M = {} | ||||
| 
 | ||||
|  | ||||
| @ -15,7 +15,7 @@ define Package/gluon-core | ||||
|   SECTION:=gluon | ||||
|   CATEGORY:=Gluon | ||||
|   TITLE:=Base files of Gluon | ||||
|   DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname | ||||
|   DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-simple-uci +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname | ||||
| endef | ||||
| 
 | ||||
| define Package/gluon-core/description | ||||
|  | ||||
| @ -4,7 +4,7 @@ local sysconfig = require 'gluon.sysconfig' | ||||
| local gluon_util = require 'gluon.util' | ||||
| local platform = require 'gluon.platform' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| if not (sysconfig.lan_ifname or sysconfig.wan_ifname) then | ||||
|  | ||||
| @ -7,7 +7,7 @@ local sysconfig = require 'gluon.sysconfig' | ||||
| if not sysconfig.gluon_version then | ||||
|   local site = require 'gluon.site_config' | ||||
|   local util = require 'gluon.util' | ||||
|   local uci = require('luci.model.uci').cursor() | ||||
|   local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
|   local system = uci:get_first('system', 'system') | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| local sysctl = require 'gluon.sysctl' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| 
 | ||||
| @ -9,9 +9,9 @@ uci:section('network', 'interface', 'wan', | ||||
| 	    { | ||||
| 	      ifname = sysconfig.wan_ifname, | ||||
| 	      type = 'bridge', | ||||
| 	      multicast_querier = 0, | ||||
| 	      peerdns = 0, | ||||
| 	      auto = 1, | ||||
| 	      multicast_querier = false, | ||||
| 	      peerdns = false, | ||||
| 	      auto = true, | ||||
| 	    } | ||||
| ) | ||||
| uci:delete('network', 'wan', 'igmp_snooping') | ||||
| @ -24,9 +24,9 @@ end | ||||
| uci:section('network', 'interface', 'wan6', | ||||
| 	    { | ||||
| 	      ifname = 'br-wan', | ||||
| 	      peerdns = 0, | ||||
| 	      peerdns = false, | ||||
| 	      ip6table = 1, | ||||
| 	      sourcefilter = 0, | ||||
| 	      sourcefilter = false, | ||||
| 	    } | ||||
| ) | ||||
| 
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require 'luci.model.uci' | ||||
| local uci = require 'simple-uci' | ||||
| 
 | ||||
| if not site.ntp_servers or #site.ntp_servers == 0 then | ||||
| 	os.exit(0) | ||||
|  | ||||
| @ -1,29 +1,25 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require 'luci.model.uci' | ||||
| 
 | ||||
| local c = uci.cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| local function reject_input_on_wan(zone) | ||||
| 	if zone.name == 'wan' then | ||||
| 		c:set('firewall', zone['.name'], 'input', 'REJECT') | ||||
| 		c:set('firewall', zone['.name'], 'conntrack', '1') | ||||
| 		uci:set('firewall', zone['.name'], 'input', 'REJECT') | ||||
| 		uci:set('firewall', zone['.name'], 'conntrack', true) | ||||
| 	end | ||||
| 
 | ||||
| 	return true | ||||
| end | ||||
| c:foreach('firewall', 'zone', reject_input_on_wan) | ||||
| uci:foreach('firewall', 'zone', reject_input_on_wan) | ||||
| 
 | ||||
| c:section('firewall', 'rule', 'wan_ssh', | ||||
| 	  { | ||||
| uci:section('firewall', 'rule', 'wan_ssh', { | ||||
| 	name = 'wan_ssh', | ||||
| 	src = 'wan', | ||||
| 	dest_port = '22', | ||||
| 	proto = 'tcp', | ||||
| 	target = 'ACCEPT', | ||||
| 	  } | ||||
| ) | ||||
| }) | ||||
| 
 | ||||
| c:save('firewall') | ||||
| uci:save('firewall') | ||||
|  | ||||
| @ -3,11 +3,11 @@ | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| local site = require 'gluon.site_config' | ||||
| 
 | ||||
| if (not sysconfig.gluon_version) and (site.poe_passthrough == true) then | ||||
| 	local uci = require('luci.model.uci').cursor() | ||||
| if (not sysconfig.gluon_version) and site.poe_passthrough then | ||||
| 	local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
|   if uci:get('system', 'gpio_switch_poe_passthrough') then | ||||
|     uci:set('system', 'gpio_switch_poe_passthrough', 'value', 1) | ||||
|     uci:set('system', 'gpio_switch_poe_passthrough', 'value', true) | ||||
|     uci:save('system') | ||||
|   end | ||||
| end | ||||
|  | ||||
| @ -4,7 +4,7 @@ local util = require 'gluon.util' | ||||
| local site = require 'gluon.site_config' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| -- Initial | ||||
| if not sysconfig.gluon_version then | ||||
| @ -22,6 +22,8 @@ end | ||||
| local function is_disabled(name) | ||||
|   if uci:get('wireless', name) then | ||||
|     return uci:get_bool('wireless', name, 'disabled') | ||||
|   else | ||||
|     return false | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| @ -82,7 +84,7 @@ local function configure_ibss(config, radio, index, suffix, disabled) | ||||
|       macaddr = macaddr, | ||||
|       mcast_rate = config.mcast_rate, | ||||
|       ifname = suffix and 'ibss' .. suffix, | ||||
|       disabled = disabled and 1 or 0, | ||||
|       disabled = disabled, | ||||
|     } | ||||
|   ) | ||||
| end | ||||
| @ -116,11 +118,11 @@ local function configure_mesh(config, radio, index, suffix, disabled) | ||||
|       network = name, | ||||
|       mode = 'mesh', | ||||
|       mesh_id = config.id, | ||||
|       mesh_fwding = 0, | ||||
|       mesh_fwding = false, | ||||
|       macaddr = macaddr, | ||||
|       mcast_rate = config.mcast_rate, | ||||
|       ifname = suffix and 'mesh' .. suffix, | ||||
|       disabled = disabled and 1 or 0, | ||||
|       disabled = disabled, | ||||
|       macfilter = macfilter, | ||||
|       maclist = maclist, | ||||
|     } | ||||
|  | ||||
| @ -1,15 +1,15 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| if not uci:get('network', 'mesh_wan') then | ||||
|   uci:section('network', 'interface', 'mesh_wan', { | ||||
|     ifname     = 'br-wan', | ||||
|     proto      = 'gluon_mesh', | ||||
|     transitive = 1, | ||||
|     fixed_mtu  = 1, | ||||
|     auto       = site.mesh_on_wan and 1 or 0, | ||||
|     transitive = true, | ||||
|     fixed_mtu  = true, | ||||
|     auto       = site.mesh_on_wan or false, | ||||
|   }) | ||||
| end | ||||
| 
 | ||||
|  | ||||
| @ -4,7 +4,7 @@ local site = require 'gluon.site_config' | ||||
| local util = require 'gluon.util' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| local lutil = require 'luci.util' | ||||
| 
 | ||||
| if not sysconfig.lan_ifname then | ||||
| @ -14,10 +14,10 @@ end | ||||
| uci:section('network', 'interface', 'mesh_lan', { | ||||
|   ifname        = sysconfig.lan_ifname, | ||||
|   type          = 'bridge', | ||||
|   igmp_snooping = 0, | ||||
|   igmp_snooping = false, | ||||
|   proto         = 'gluon_mesh', | ||||
|   transitive    = 1, | ||||
|   fixed_mtu     = 1, | ||||
|   transitive    = true, | ||||
|   fixed_mtu     = true, | ||||
| }) | ||||
| 
 | ||||
| if uci:get('network', 'mesh_lan', 'auto') == nil then | ||||
| @ -36,7 +36,7 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   uci:set('network', 'mesh_lan', 'auto', enable and 1 or 0) | ||||
|   uci:set('network', 'mesh_lan', 'auto', enable or false) | ||||
| end | ||||
| 
 | ||||
| uci:save('network') | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| local function migrate_iface(iface) | ||||
| 	if iface.proto ~= 'batadv' or iface.mesh ~= 'bat0' then | ||||
| @ -10,7 +10,7 @@ local function migrate_iface(iface) | ||||
| 	local s = iface['.name'] | ||||
| 
 | ||||
| 	uci:set('network', s, 'proto', 'gluon_mesh') | ||||
| 	uci:set('network', s, 'fixed_mtu', '1') | ||||
| 	uci:set('network', s, 'fixed_mtu', true) | ||||
| 
 | ||||
| 	if iface.mesh_no_rebroadcast then | ||||
| 		uci:set('network', s, 'transitive', iface.mesh_no_rebroadcast) | ||||
|  | ||||
| @ -1,11 +1,11 @@ | ||||
| #!/usr/bin/lua | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| dnsmasq=uci:get_first("dhcp", "dnsmasq") | ||||
| 
 | ||||
| uci:set('dhcp', dnsmasq, 'localise_queries', '1') | ||||
| uci:set('dhcp', dnsmasq, 'localservice', '0') | ||||
| uci:set('dhcp', dnsmasq, 'localise_queries', true) | ||||
| uci:set('dhcp', dnsmasq, 'localservice', false) | ||||
| 
 | ||||
| if site.dns and site.dns.servers then | ||||
| 	uci:set('dhcp', dnsmasq, 'server', site.dns.servers) | ||||
|  | ||||
| @ -34,7 +34,7 @@ local nixio = require 'nixio' | ||||
| local hash = require 'hash' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| local lutil = require 'luci.util' | ||||
| local fs = require 'nixio.fs' | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| <%- | ||||
|   local fs = require 'nixio.fs' | ||||
|   local uci = require('luci.model.uci').cursor() | ||||
|   local uci = require('simple-uci').cursor() | ||||
|   local util = require 'luci.util' | ||||
|   local i18n = require 'luci.i18n' | ||||
|   local pretty_hostname = require 'pretty_hostname' | ||||
| @ -31,8 +31,8 @@ | ||||
|     pubkey = 'n/a', | ||||
|   } | ||||
| 
 | ||||
|   local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0") | ||||
|   if meshvpn_enabled == "1" then | ||||
|   local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") | ||||
|   if meshvpn_enabled then | ||||
|     local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn')) | ||||
|     if pubkey ~= '' then | ||||
|       values.pubkey = pubkey | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local util = luci.util | ||||
| 
 | ||||
| local f = SimpleForm('mesh_vpn', translate('Mesh VPN')) | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| local f, s, o | ||||
| local site = require 'gluon.site_config' | ||||
| local i18n = require "luci.i18n" | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local config = 'gluon-node-info' | ||||
| 
 | ||||
| -- where to read the configuration from | ||||
|  | ||||
| @ -12,7 +12,7 @@ http://www.apache.org/licenses/LICENSE-2.0 | ||||
| $Id$ | ||||
| ]]-- | ||||
| 
 | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local lutil = require 'luci.util' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| local util = require 'gluon.util' | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local util = require 'gluon.util' | ||||
| 
 | ||||
| local f, s, o, ssid | ||||
| @ -49,12 +49,12 @@ function f.handle(self, state, data) | ||||
|                         ssid       = data.ssid, | ||||
|                         key        = data.key, | ||||
|                         macaddr    = macaddr, | ||||
|                         disabled   = 0, | ||||
|                         disabled   = false, | ||||
|                       } | ||||
|           ) | ||||
|         else | ||||
|           -- disable WAN wifi-iface | ||||
|           uci:set('wireless', name, "disabled", 1) | ||||
|           uci:set('wireless', name, "disabled", true) | ||||
|         end | ||||
|       end | ||||
|     ) | ||||
|  | ||||
| @ -16,7 +16,7 @@ $Id$ | ||||
| 	local sys  = require "luci.sys" | ||||
| 	local http = require "luci.http" | ||||
| 	local disp = require "luci.dispatcher" | ||||
| 	local uci  = require("luci.model.uci").cursor() | ||||
| 	local uci  = require("simple-uci").cursor() | ||||
| 	local fs   = require "nixio.fs" | ||||
| 	local gluon_luci = require "gluon.luci" | ||||
| 	local pretty_hostname = require "pretty_hostname" | ||||
| @ -141,7 +141,7 @@ $Id$ | ||||
| <% | ||||
| if tree.nodes[category] and tree.nodes[category].ucidata then | ||||
| 	local ucic = 0 | ||||
| 	for i, j in pairs(require("luci.model.uci").cursor():changes()) do | ||||
| 	for i, j in pairs(require("simple-uci").cursor():changes()) do | ||||
| 		for k, l in pairs(j) do | ||||
| 			for m, n in pairs(l) do | ||||
| 				ucic = ucic + 1; | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| local uci = luci.model.uci.cursor() | ||||
| local uci = require("simple-uci").cursor() | ||||
| local fs = require 'nixio.fs' | ||||
| local iwinfo = require 'iwinfo' | ||||
| 
 | ||||
|  | ||||
| @ -4,7 +4,7 @@ local sysconfig = require 'gluon.sysconfig' | ||||
| local site = require 'gluon.site_config' | ||||
| local util = require 'gluon.util' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| local gw_sel_class | ||||
| @ -19,7 +19,7 @@ uci:section('batman-adv', 'mesh', 'bat0', | ||||
| 		gw_mode = 'client', | ||||
| 		gw_sel_class = gw_sel_class, | ||||
| 		hop_penalty = 15, | ||||
| 		multicast_mode = 0, | ||||
| 		multicast_mode = false, | ||||
| 	} | ||||
| ) | ||||
| uci:save('batman-adv') | ||||
| @ -31,7 +31,7 @@ uci:section('network', 'interface', 'bat0', | ||||
| 		proto = 'none', | ||||
| 		macaddr = sysconfig.primary_mac, | ||||
| 		multicast_router = 2, | ||||
| 		learning = 0, | ||||
| 		learning = false, | ||||
| 	} | ||||
| ) | ||||
| 
 | ||||
|  | ||||
| @ -3,7 +3,7 @@ | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| local sysctl = require 'gluon.sysctl' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| uci:section('network', 'interface', 'client', | ||||
| 	{ | ||||
| @ -18,7 +18,7 @@ uci:delete('network', 'client_lan') | ||||
| if sysconfig.lan_ifname then | ||||
| 	uci:section('network', 'interface', 'client_lan', | ||||
| 		{ | ||||
| 			unicast_flood = 0, | ||||
| 			unicast_flood = false, | ||||
| 		} | ||||
| 	) | ||||
| 	uci:set('network', 'client_lan', 'ifname', sysconfig.lan_ifname) | ||||
|  | ||||
| @ -4,7 +4,7 @@ local site = require 'gluon.site_config' | ||||
| local sysconfig = require 'gluon.sysconfig' | ||||
| local sysctl = require 'gluon.sysctl' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| uci:delete('network', 'local_node_dev') | ||||
| @ -23,9 +23,9 @@ uci:section('network', 'interface', 'local_node', | ||||
| 		ifname = 'local-node', | ||||
| 		proto = 'dhcpv6', | ||||
| 		reqprefix = 'no', | ||||
| 		peerdns = 1, | ||||
| 		sourcefilter = 0, | ||||
| 		keep_ra_dnslifetime = 1, | ||||
| 		peerdns = true, | ||||
| 		sourcefilter = false, | ||||
| 		keep_ra_dnslifetime = true, | ||||
| 	} | ||||
| ) | ||||
| 
 | ||||
| @ -72,7 +72,7 @@ uci:delete('dhcp', 'local_node') | ||||
| uci:section('dhcp', 'dhcp', 'local_node', | ||||
| 	{ | ||||
| 		interface = 'local_node', | ||||
| 		ignore = 1, | ||||
| 		ignore = true, | ||||
| 	} | ||||
| ) | ||||
| 
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local util = require 'gluon.util' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| -- fix up potentially duplicate MAC addresses (for meshing) | ||||
|  | ||||
| @ -4,7 +4,7 @@ local site = require 'gluon.site_config' | ||||
| local users = require 'gluon.users' | ||||
| local util = require 'gluon.util' | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| local lutil = require 'luci.util' | ||||
| 
 | ||||
| 
 | ||||
| @ -17,7 +17,7 @@ users.add_group('gluon-fastd', 800) | ||||
| 
 | ||||
| local enabled = uci:get('fastd', 'mesh_vpn', 'enabled') | ||||
| if not enabled then | ||||
|   enabled = site.fastd_mesh_vpn.enabled and 1 or 0 | ||||
|   enabled = site.fastd_mesh_vpn.enabled or false | ||||
| end | ||||
| 
 | ||||
| local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose' | ||||
| @ -56,7 +56,7 @@ uci:section('fastd', 'fastd', 'mesh_vpn', | ||||
| 		  interface = 'mesh-vpn', | ||||
| 		  mode = 'tap', | ||||
| 		  mtu = site.fastd_mesh_vpn.mtu, | ||||
| 		  secure_handshakes = 1, | ||||
| 		  secure_handshakes = true, | ||||
| 		  method = methods, | ||||
| 		  packet_mark = 1, | ||||
| 		  status_socket = '/var/run/fastd.mesh_vpn.socket', | ||||
| @ -70,7 +70,7 @@ local add_groups | ||||
| local function add_peer(group, name, config) | ||||
|   uci:section('fastd', 'peer', group .. '_peer_' .. name, | ||||
|     { | ||||
|       enabled = 1, | ||||
|       enabled = true, | ||||
|       net = 'mesh_vpn', | ||||
|       group = group, | ||||
|       key = config.key, | ||||
| @ -90,7 +90,7 @@ local function add_group(name, config, parent) | ||||
| 
 | ||||
|   uci:section('fastd', 'peer_group', name, | ||||
|     { | ||||
|       enabled = 1, | ||||
|       enabled = true, | ||||
|       net = 'mesh_vpn', | ||||
|       parent = parent, | ||||
|       peer_limit = config.limit, | ||||
| @ -125,8 +125,8 @@ uci:section('network', 'interface', 'mesh_vpn', | ||||
|   { | ||||
|     ifname = 'mesh-vpn', | ||||
|     proto = 'gluon_mesh', | ||||
|     transitive = 1, | ||||
|     fixed_mtu = 1, | ||||
|     transitive = true, | ||||
|     fixed_mtu = true, | ||||
|     macaddr = util.generate_mac(7), | ||||
|   } | ||||
| ) | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require 'luci.model.uci' | ||||
| local uci = require 'simple-uci' | ||||
| 
 | ||||
| local c = uci.cursor() | ||||
| 
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| local fs = require 'nixio.fs' | ||||
| 
 | ||||
| 
 | ||||
| @ -13,13 +13,13 @@ end | ||||
| if not uci:get('simple-tc', 'mesh_vpn') then | ||||
|   local config = { | ||||
|     ifname = 'mesh-vpn', | ||||
|     enabled = 0, | ||||
|     enabled = false, | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   if site.fastd_mesh_vpn.bandwidth_limit then | ||||
|     if site.fastd_mesh_vpn.bandwidth_limit.enabled then | ||||
|       config.enabled = 1 | ||||
|       config.enabled = true | ||||
|     end | ||||
| 
 | ||||
|     config.limit_ingress = site.fastd_mesh_vpn.bandwidth_limit.ingress | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| -- Allow incoming respondd replies to queries on WAN | ||||
| -- If the query was via multicast, the response isn't matched by --state RELATED | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| local config = 'gluon-node-info' | ||||
| 
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| local config = 'gluon-node-info' | ||||
| local role = uci:get(config, uci:get_first(config, 'system'), 'role') | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| require 'luci.util' | ||||
| 
 | ||||
| local sname = uci:get_first('gluon-node-info', 'location') | ||||
| if sname then | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| uci:delete('firewall', 'wan_announced') | ||||
| 
 | ||||
|  | ||||
| @ -1,15 +1,14 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local site = require 'gluon.site_config' | ||||
| local uci = require 'luci.model.uci' | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| local c = uci.cursor() | ||||
| 
 | ||||
| if site.setup_mode | ||||
|    and site.setup_mode.skip | ||||
|    and not c:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then | ||||
|      local name = c:get_first("gluon-setup-mode", "setup_mode") | ||||
|      c:set("gluon-setup-mode", name, "configured", 1) | ||||
|      c:save('gluon-setup-mode') | ||||
|    and not uci:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then | ||||
|      local name = uci:get_first("gluon-setup-mode", "setup_mode") | ||||
|      uci:set("gluon-setup-mode", name, "configured", true) | ||||
|      uci:save('gluon-setup-mode') | ||||
| end | ||||
| 
 | ||||
|  | ||||
| @ -1,16 +1,14 @@ | ||||
| #!/usr/bin/lua | ||||
| 
 | ||||
| local uci = require 'luci.model.uci' | ||||
| 
 | ||||
| local c = uci.cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| 
 | ||||
| 
 | ||||
| local old = c:get_first('gluon-config-mode', 'wizard', 'configured') | ||||
| local old = uci:get_first('gluon-config-mode', 'wizard', 'configured') | ||||
| if old == '1' then | ||||
| 	local setup_mode = c:get_first('gluon-setup-mode', 'setup_mode') | ||||
| 	c:set('gluon-setup-mode', setup_mode, 'configured', '1') | ||||
| 	local setup_mode = uci:get_first('gluon-setup-mode', 'setup_mode') | ||||
| 	uci:set('gluon-setup-mode', setup_mode, 'configured', true) | ||||
| 
 | ||||
| 	c:save('gluon-setup-mode') | ||||
| 	uci:save('gluon-setup-mode') | ||||
| end | ||||
| 
 | ||||
| os.remove('/etc/config/gluon-config-mode') | ||||
|  | ||||
| @ -5,7 +5,7 @@ local RESOLV_CONF = RESOLV_CONF_DIR .. '/resolv.conf' | ||||
| 
 | ||||
| 
 | ||||
| local ubus = require('ubus').connect() | ||||
| local uci = require('luci.model.uci').cursor() | ||||
| local uci = require('simple-uci').cursor() | ||||
| local fs = require 'nixio.fs' | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user