From 4a7eefce73a2246e7437119ea2b6904ae7d50503 Mon Sep 17 00:00:00 2001 From: Bin Lu Date: Wed, 23 May 2018 10:33:18 +0800 Subject: enable image building for openwrt demo Change-Id: Id464f064e9a7c4a55244c3cec4b3303a4ed0a889 Signed-off-by: Bin Lu --- .../openwrt_demo/1_buildimage/resources/bin/getips | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/arm/openwrt_demo/1_buildimage/resources/bin/getips (limited to 'src/arm/openwrt_demo/1_buildimage/resources/bin/getips') diff --git a/src/arm/openwrt_demo/1_buildimage/resources/bin/getips b/src/arm/openwrt_demo/1_buildimage/resources/bin/getips new file mode 100644 index 0000000..3c68e95 --- /dev/null +++ b/src/arm/openwrt_demo/1_buildimage/resources/bin/getips @@ -0,0 +1,24 @@ +#!/bin/sh + +nwfn='/etc/config/network' +gwPost=".1" +nwPost=".0" + +ethname='eth0' +ipeth=$(ifconfig $ethname |grep "inet addr" | cut -d: -f2 | awk '{print $1}') +dirtyIp=$(grep ipaddr $nwfn | grep -v "127.0.0.1" | awk '{print $3}' | sed "s/'//g" | awk 'NR==1') +dirtyGw=$(grep gateway $nwfn | grep -v "127.0.0.1" | awk '{print $3}' | sed "s/'//g" | awk 'NR==1') +expNetPrefix=$(echo $ipeth | cut -d. -f 1,2,3) +expGw=$expNetPrefix$gwPost +sed -i "s/$dirtyIp/$ipeth/g" $nwfn +sed -i "s/$dirtyGw/$expGw/g" $nwfn + + +ethname='net0' +ipeth=$(ifconfig $ethname |grep "inet addr" | cut -d: -f2 | awk '{print $1}') +dirtyIp=$(grep ipaddr $nwfn | grep -v "127.0.0.1" | awk '{print $3}' | sed "s/'//g" | awk 'NR==2') +dirtyGw=$(grep gateway $nwfn | grep -v "127.0.0.1" | awk '{print $3}' | sed "s/'//g" | awk 'NR==2') +expNetPrefix=$(echo $ipeth | cut -d. -f 1,2,3) +expGw=$expNetPrefix$gwPost +sed -i "s/$dirtyIp/$ipeth/g" $nwfn +sed -i "s/$dirtyGw/$expGw/g" $nwfn -- cgit 1.2.3-korg