Remove all remaining uses of sysconfig.sh
This commit is contained in:
parent
7773afdc18
commit
f73d727ae6
@ -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
|
|||||||
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
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
#!/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'
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
local util = require 'luci.util'
|
||||||
|
|
||||||
|
local platform_info = require 'platform_info'
|
||||||
|
|
||||||
|
|
||||||
get_primary_mac() {
|
local board_name = platform_info.get_board_name()
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$(ar71xx_board_name)" in
|
if board_name == 'tl-wdr3600' or board_name == 'tl-wdr4300' then
|
||||||
nanostation-m)
|
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
||||||
# 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
|
||||||
|
@ -1,32 +1,36 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
local util = require 'luci.util'
|
||||||
|
|
||||||
|
local nixio = require 'nixio'
|
||||||
|
local platform_info = require 'platform_info'
|
||||||
|
|
||||||
|
|
||||||
. /lib/functions.sh
|
uci:delete('network', 'lan')
|
||||||
. /lib/gluon/functions/sysconfig.sh
|
uci:delete('network', 'wan')
|
||||||
. /lib/ar71xx.sh
|
|
||||||
|
uci:section('network', 'interface', 'wan',
|
||||||
|
{
|
||||||
|
ifname = sysconfig.wan_ifname,
|
||||||
|
type = 'bridge',
|
||||||
|
proto = 'dhcp',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
uci_remove network lan
|
if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then
|
||||||
uci_remove network wan
|
-- 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_add network interface wan
|
uci:set('network', 'wan', 'macaddr', wanaddr)
|
||||||
uci_set network wan ifname "$(sysconfig wan_ifname)"
|
end
|
||||||
uci_set network wan type 'bridge'
|
|
||||||
uci_set network wan proto 'dhcp'
|
|
||||||
|
|
||||||
|
uci:save('network')
|
||||||
case "$(ar71xx_board_name)" in
|
uci:commit('network')
|
||||||
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 )) )
|
|
||||||
|
|
||||||
uci_set network wan macaddr "$wanaddr"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
uci_commit network
|
|
||||||
|
@ -1,39 +1,42 @@
|
|||||||
#!/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'
|
||||||
|
|
||||||
|
local platform_info = require 'platform_info'
|
||||||
|
|
||||||
|
|
||||||
get_primary_mac() {
|
local board_name = platform_info.get_board_name()
|
||||||
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() {
|
|
||||||
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
|
||||||
|
|
||||||
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 function remove_bat0(iface)
|
||||||
|
return util.trim(string.gsub(' ' .. iface .. ' ', ' bat0 ', ' '))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
local util = require 'luci.util'
|
||||||
|
|
||||||
|
local nixio = require 'nixio'
|
||||||
|
local platform_info = require 'platform_info'
|
||||||
|
|
||||||
|
|
||||||
. /lib/functions.sh
|
if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then
|
||||||
. /lib/gluon/functions/sysconfig.sh
|
-- 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)
|
||||||
|
end
|
||||||
|
|
||||||
case "$(ar71xx_board_name)" in
|
uci:save('network')
|
||||||
tl-wr1043nd|\
|
uci:commit('network')
|
||||||
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 )) )
|
|
||||||
|
|
||||||
uci_set network wan macaddr "$wanaddr"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
uci_commit network
|
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
#!/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
|
|||||||
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() {
|
|||||||
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() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user