From fa1774a4e69b0237212d9d6f10df236d73842249 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer <mschiffer@universe-factory.net> Date: Tue, 1 Oct 2013 20:16:24 +0200 Subject: [PATCH] Remove batman-adv specific parts of gluon-core --- .../files/lib/gluon/core/sysconfig/.keep | 0 .../files/lib/gluon/functions/sysconfig.sh | 10 +++++ .../gluon/upgrade/core/initial/001-sysconfig | 20 ++++++++++ .../upgrade/core/initial/011-gluon-network | 40 ++----------------- .../gluon-core/files/lib/upgrade/keep.d/gluon | 2 + 5 files changed, 35 insertions(+), 37 deletions(-) create mode 100644 package/gluon-core/files/lib/gluon/core/sysconfig/.keep create mode 100644 package/gluon-core/files/lib/gluon/functions/sysconfig.sh create mode 100644 package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig 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 000000000..e69de29bb 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 000000000..40acf6890 --- /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 000000000..1affcb469 --- /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 c2086228f..28211d710 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 19904ba62..41c6befb7 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/ -- GitLab