diff --git a/package/gluon-core/files/lib/gluon/core/sysconfig/.keep b/package/gluon-core/files/lib/gluon/core/sysconfig/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/package/gluon-core/files/lib/gluon/functions/sysconfig.sh b/package/gluon-core/files/lib/gluon/functions/sysconfig.sh new file mode 100644 index 0000000000000000000000000000000000000000..40acf689042450b386d2035c5bd3208c4ccec5ba --- /dev/null +++ b/package/gluon-core/files/lib/gluon/functions/sysconfig.sh @@ -0,0 +1,10 @@ +SYSCONFIGDIR=/lib/gluon/core/sysconfig + + +sysconfig() { + cat "$SYSCONFIGDIR/$1" +} + +sysconfig_set() { + echo -n "$2" > "$SYSCONFIGDIR/$1" +} diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig b/package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig new file mode 100644 index 0000000000000000000000000000000000000000..1affcb46916cb31ebdb03dce32ea69fcef25f9da --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig @@ -0,0 +1,20 @@ +#!/bin/sh + +. /lib/gluon/functions/sysconfig.sh +. /lib/ar71xx.sh + + +get_primary_mac() { + case "$(ar71xx_board_name)" in + tl-wdr3600|tl-wdr4300) + cat /sys/class/ieee80211/phy1/macaddress + ;; + *) + cat /sys/class/ieee80211/phy0/macaddress + ;; + esac +} + + +sysconfig_set lan_ifname "$(uci get network.lan.ifname)" +sysconfig_set primary_mac "$(get_primary_mac)" diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network b/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network index c2086228f73da0a59ab9fa2656d8f30ad02913a0..28211d710c221876c54092a23577b5505daf4906 100755 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network +++ b/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network @@ -1,9 +1,7 @@ #!/bin/sh -. /lib/ar71xx.sh -local lan_ifname="$(uci get network.lan.ifname)" -local board="$(ar71xx_board_name)" +. /lib/gluon/functions/sysconfig.sh uci -q batch <<EOF delete network.lan @@ -11,45 +9,13 @@ delete network.lan set network.wan.type='bridge' set network.wan.proto='dhcp' set network.wan.auto='1' - -set network.client='interface' -set network.client.ifname='$lan_ifname bat0' -set network.client.type='bridge' -set network.client.proto='dhcpv6' -set network.client.reqprefix='no' -set network.client.peerdns='0' - -set network.mesh='interface' -set network.mesh.proto='batadv' -set network.mesh.mtu='1528' -set network.mesh.mesh='bat0' - -set network.mesh_vpn='interface' -set network.mesh_vpn.ifname='mesh-vpn' -set network.mesh_vpn.proto='batadv' -set network.mesh_vpn.mesh='bat0' EOF -get_main_address() { - case "$board" in - tl-wdr3600|tl-wdr4300) - cat /sys/class/ieee80211/phy1/macaddress - ;; - *) - cat /sys/class/ieee80211/phy0/macaddress - ;; - esac -} - -local mainaddr=$(get_main_address) + +local mainaddr=$(sysconfig primary_mac) local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS" local b2mask=0x02 -local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6) - -uci set network.client.macaddr="$mainaddr" -uci set network.mesh_vpn.macaddr="$vpnaddr" - case "$board" in tl-wr1043nd|\ tl-wdr3600|\ diff --git a/package/gluon-core/files/lib/upgrade/keep.d/gluon b/package/gluon-core/files/lib/upgrade/keep.d/gluon index 19904ba620fb39d2ee12df6d9af0f643bdfffe6a..41c6befb7ed505f0202439990f625c0dbe3fd5ac 100644 --- a/package/gluon-core/files/lib/upgrade/keep.d/gluon +++ b/package/gluon-core/files/lib/upgrade/keep.d/gluon @@ -1 +1,3 @@ /lib/gluon/version/ + +/lib/gluon/core/sysconfig/