Skip to content
Snippets Groups Projects
Commit f73d727a authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

Remove all remaining uses of sysconfig.sh

parent 7773afdc
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ include $(GLUONDIR)/include/package.mk ...@@ -11,7 +11,7 @@ include $(GLUONDIR)/include/package.mk
define Package/gluon-autoupdater define Package/gluon-autoupdater
SECTION:=gluon SECTION:=gluon
CATEGORY:=Gluon CATEGORY:=Gluon
DEPENDS:=+gluon-core +gluon-cron +lua-platform-info +opkg +ecdsautils +!BUSYBOX_CONFIG_SHA512SUM:coreutils-sha512sum DEPENDS:=+gluon-core +gluon-cron +opkg +ecdsautils +!BUSYBOX_CONFIG_SHA512SUM:coreutils-sha512sum
TITLE:=Automatically update firmware TITLE:=Automatically update firmware
endef endef
......
...@@ -12,7 +12,7 @@ define Package/gluon-core ...@@ -12,7 +12,7 @@ define Package/gluon-core
SECTION:=gluon SECTION:=gluon
CATEGORY:=Gluon CATEGORY:=Gluon
TITLE:=Base files of Gluon TITLE:=Base files of Gluon
DEPENDS:=+gluon-config +luci-lib-core +odhcp6c DEPENDS:=+gluon-config +lua-platform-info +luci-lib-core +odhcp6c
endef endef
define Package/gluon-core/description define Package/gluon-core/description
......
#!/bin/sh #!/usr/bin/lua
. /lib/gluon/functions/sysconfig.sh local sysconfig = require 'gluon.sysconfig'
. /lib/ar71xx.sh local gluon_util = require 'gluon.util'
local fs = require 'luci.fs'
get_primary_mac() { local uci = require('luci.model.uci').cursor()
case "$(ar71xx_board_name)" in local util = require 'luci.util'
tl-wdr3600|tl-wdr4300)
cat /sys/class/ieee80211/phy1/macaddress local platform_info = require 'platform_info'
;;
*)
cat /sys/class/ieee80211/phy0/macaddress local board_name = platform_info.get_board_name()
;;
esac
} if board_name == 'tl-wdr3600' or board_name == 'tl-wdr4300' then
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
iface_exists() {
local name="$1"
ip link show dev "${name//.*/}" >/dev/null 2>&1
}
case "$(ar71xx_board_name)" in
nanostation-m)
# It's more convenient to swap the ports for these devices so WAN is the PoE port
lan_ifname="$(uci get network.wan.ifname)"
wan_ifname="$(uci get network.lan.ifname)"
;;
*)
lan_ifname="$(uci get network.lan.ifname)"
wan_ifname="$(uci get network.wan.ifname)"
;;
esac
if [ -n "$wan_ifname" ] && iface_exists "$wan_ifname"; then
[ -z "$lan_ifname" ] || sysconfig_set lan_ifname "$lan_ifname"
sysconfig_set wan_ifname "$wan_ifname"
else else
sysconfig_set wan_ifname "$lan_ifname" sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
fi end
sysconfig_set primary_mac "$(get_primary_mac)" local function iface_exists(name)
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
end
local lan_ifname = uci:get('network', 'lan', 'ifname')
local wan_ifname = uci:get('network', 'wan', 'ifname')
if board_name == 'nanostation-m' then
lan_ifname, wan_ifname = wan_ifname, lan_ifname
end
if wan_ifname and iface_exists(wan_ifname) then
sysconfig.wan_ifname = wan_ifname
sysconfig.lan_ifname = lan_ifname
else
sysconfig.wan_ifname = lan_ifname
end
#!/bin/sh #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig'
. /lib/functions.sh local uci = require('luci.model.uci').cursor()
. /lib/gluon/functions/sysconfig.sh local util = require 'luci.util'
. /lib/ar71xx.sh
local nixio = require 'nixio'
local platform_info = require 'platform_info'
uci_remove network lan
uci_remove network wan
uci_add network interface wan uci:delete('network', 'lan')
uci_set network wan ifname "$(sysconfig wan_ifname)" uci:delete('network', 'wan')
uci_set network wan type 'bridge'
uci_set network wan proto 'dhcp'
uci:section('network', 'interface', 'wan',
{
ifname = sysconfig.wan_ifname,
type = 'bridge',
proto = 'dhcp',
}
)
case "$(ar71xx_board_name)" in
tl-wr1043nd|\
tl-wdr3600|\
tl-wdr4300) # fix up duplicate mac addresses
local mainaddr=$(sysconfig primary_mac)
local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
local b2mask=0x02
local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) ) if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then
-- fix up duplicate mac addresses
local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)')
m1 = nixio.bit.bor(tonumber(m1, 16), 0x02)
m4 = (tonumber(m4, 16)+1) % 0x100
m6 = (tonumber(m6, 16)+1) % 0x100
local wanaddr = string.format('%02x:%s:%s:%02x:%s:%02x', m1, m2, m3, m4, m5, m6)
uci_set network wan macaddr "$wanaddr" uci:set('network', 'wan', 'macaddr', wanaddr)
;; end
esac
uci_commit network uci:save('network')
uci:commit('network')
#!/bin/sh #!/usr/bin/lua
. /lib/gluon/functions/sysconfig.sh local sysconfig = require 'gluon.sysconfig'
. /lib/ar71xx.sh local gluon_util = require 'gluon.util'
local site = require 'gluon.site_config'
local fs = require 'luci.fs'
local uci = require('luci.model.uci').cursor()
local util = require 'luci.util'
get_primary_mac() { local platform_info = require 'platform_info'
case "$(ar71xx_board_name)" in
tl-wdr3600|tl-wdr4300)
cat /sys/class/ieee80211/phy1/macaddress
;;
*)
cat /sys/class/ieee80211/phy0/macaddress
;;
esac
}
iface_exists() {
local name="$1"
ip link show dev "${name//.*/}" >/dev/null 2>&1
}
remove_bat0() { local board_name = platform_info.get_board_name()
sed -r -e 's/(^| )bat0( |$)/ /g' -e 's/^ | $//g'
}
mesh_section="$(lua -e 'print(require("gluon.site_config").legacy.mesh_ifname)')" if board_name == 'tl-wdr3600' or board_name == 'tl-wdr4300' then
mesh_ifname="$(uci get "network.${mesh_section}.ifname" | remove_bat0)" sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
wan_ifname="$(uci get network.wan.ifname)"
if [ -n "$wan_ifname" ] && iface_exists "$wan_ifname"; then
[ -z "$mesh_ifname" ] || sysconfig_set lan_ifname "$mesh_ifname"
sysconfig_set wan_ifname "$wan_ifname"
else else
sysconfig_set wan_ifname "$mesh_ifname" sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
fi end
local function iface_exists(name)
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
end
local function remove_bat0(iface)
return util.trim(string.gsub(' ' .. iface .. ' ', ' bat0 ', ' '))
end
sysconfig_set primary_mac "$(get_primary_mac)"
local lan_ifname = remove_bat0(uci:get('network', site.legacy.mesh_ifname, 'ifname'))
local wan_ifname = uci:get('network', 'wan', 'ifname')
if wan_ifname and iface_exists(wan_ifname) then
sysconfig.wan_ifname = wan_ifname
sysconfig.lan_ifname = lan_ifname
else
sysconfig.wan_ifname = lan_ifname
end
#!/bin/sh #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig'
. /lib/functions.sh local uci = require('luci.model.uci').cursor()
. /lib/gluon/functions/sysconfig.sh local util = require 'luci.util'
local nixio = require 'nixio'
local platform_info = require 'platform_info'
case "$(ar71xx_board_name)" in
tl-wr1043nd|\
tl-wdr3600|\
tl-wdr4300) # fix up duplicate mac addresses
local mainaddr=$(sysconfig primary_mac)
local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
local b2mask=0x02
local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) ) if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then
-- fix up duplicate mac addresses
local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)')
m1 = nixio.bit.bor(tonumber(m1, 16), 0x02)
m4 = (tonumber(m4, 16)+1) % 0x100
m6 = (tonumber(m6, 16)+1) % 0x100
local wanaddr = string.format('%02x:%s:%s:%02x:%s:%02x', m1, m2, m3, m4, m5, m6)
uci_set network wan macaddr "$wanaddr" uci:set('network', 'wan', 'macaddr', wanaddr)
;; end
esac
uci_commit network uci:save('network')
uci:commit('network')
#!/bin/sh #!/usr/bin/lua
. /lib/functions.sh local sysconfig = require 'gluon.sysconfig'
. /lib/gluon/functions/sysconfig.sh local uci = require('luci.model.uci').cursor()
lan_ifname="$(sysconfig lan_ifname)"
uci_add network interface client local ifname
if [ -n "$lan_ifname" ]; then if sysconfig.lan_ifname then
uci_set network client ifname "$lan_ifname bat0" ifname = sysconfig.lan_ifname .. ' bat0'
else else
uci_set network client ifname "bat0" ifname = 'bat0'
fi end
uci_set network client type 'bridge'
uci_set network client proto 'dhcpv6' uci:section('network', 'interface', 'client',
uci_set network client reqprefix 'no' {
ifname = ifname,
type = 'bridge',
proto = 'dhcpv6',
reqprefix = 'no',
}
)
uci:save('network')
uci:commit('network')
...@@ -14,7 +14,7 @@ define Package/gluon-setup-mode ...@@ -14,7 +14,7 @@ define Package/gluon-setup-mode
SECTION:=gluon SECTION:=gluon
CATEGORY:=Gluon CATEGORY:=Gluon
TITLE:=Setup mode TITLE:=Setup mode
DEPENDS:=+gluon-core +lua-platform-info +uhttpd +dnsmasq +ip DEPENDS:=+gluon-core +uhttpd +dnsmasq +ip
endef endef
define Package/gluon-setup-mode/description define Package/gluon-setup-mode/description
......
...@@ -35,7 +35,7 @@ setup_network() { ...@@ -35,7 +35,7 @@ setup_network() {
config_foreach delete_interface interface config_foreach delete_interface interface
uci_add network interface setup uci_add network interface setup
uci_set network setup ifname "$(sysconfig setup_ifname)" uci_set network setup ifname "$(lua -e 'print(require("gluon.sysconfig").setup_ifname)')"
uci_set network setup type 'bridge' uci_set network setup type 'bridge'
uci_set network setup proto 'static' uci_set network setup proto 'static'
uci_set network setup ipaddr "$SETUP_MODE_ADDR" uci_set network setup ipaddr "$SETUP_MODE_ADDR"
...@@ -55,8 +55,6 @@ setup_network() { ...@@ -55,8 +55,6 @@ setup_network() {
} }
start() { start() {
. /lib/gluon/functions/sysconfig.sh
enable=0 enable=0
config_load gluon-setup-mode config_load gluon-setup-mode
config_foreach check_enable setup_mode config_foreach check_enable setup_mode
......
...@@ -12,7 +12,7 @@ define Package/gluon-status-page ...@@ -12,7 +12,7 @@ define Package/gluon-status-page
SECTION:=gluon SECTION:=gluon
CATEGORY:=Gluon CATEGORY:=Gluon
TITLE:=Adds a status page showing information about the node. TITLE:=Adds a status page showing information about the node.
DEPENDS:=+gluon-core +lua-platform-info +uhttpd DEPENDS:=+gluon-core +uhttpd
endef endef
define Package/gluon-status-page/description define Package/gluon-status-page/description
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment