summaryrefstree
path: root/recovery/ramdisk/pcba/ethernet.sh
blob: ef0d8efb01d60b88b33b1ec0c0e808141d09d17a (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/sbin/busybox sh

result_file=/data/ether_result.txt
interface_up=true
jmax=3

echo "touch $result_file"
busybox touch $result_file

j=0

echo "Get ping results"
while [ $j -lt $jmax ]; 
do
    if busybox ifconfig eth0; then
        if [ $interface_up = "true" ]; then
            busybox ifconfig eth0 up
        fi

		#use ping type
		if [ "$3" = "1" ]; then
	    	busybox ifconfig eth0 $1

		echo "sleep 2s"
	    	busybox sleep 2
	    	
	    	#busybox ping -c 5 -W 5 $2 | busybox grep seq > $result_file
	    	busybox ping -c 5 -W 5 $2 | busybox grep "packet loss" > $result_file
	        echo "success local $1 ping $2"
	        busybox cat $result_file
	        exit 1
	        
	    #use view local address
	    else
	    	echo "sleep 2s"
	    	busybox sleep 2

	    	busybox ifconfig eth0 | busybox grep inet > $result_file
	    	
			#Check result
			if [ -s $result_file ]; then
				echo "the local ip address from dhcp assign"
	    		busybox cat $result_file
	    		exit 1
		    	else
		    	echo "the local ip address is Null"
		    fi
	    	
	    fi
	    
        
    fi

	#Clear ethernet address
	if [ "$3" = "1" ]; then
	    echo "Clear eth0 addr"
	    busybox ifconfig eth0 0.0.0.0
	fi
	
    busybox sleep 2
    
    j=$((j+1))
done

echo "lan test failed"
exit 0