summaryrefslogtreecommitdiffstats
path: root/src/arm/openwrt_demo/1_buildimage/resources/bin/getips
blob: 3c68e952a84d3067d3cb3db5c2cbf5fecbcd3cc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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