testing-script/ethernet-script/ethernet-script.sh

129 lines
3.9 KiB
Bash

#/bin/bash
RET=0
sleep 2
echo " "
echo " "
echo " "
echo "######################################################################################"
ifconfig eth0 up
ifconfig eth1 up
ifconfig eth2 up
ifconfig br-lan down
ifconfig br-wan down
brctl delbr br-lan
brctl delbr br-wan
sleep 2
echo "########################## Network ethernet Testing Start ##########################"
echo "----------------------------------------------------------------------------------------"
while true
do
read -t20 -s -n1 -p "### Please confirm if all 1G, 2.5G 10G RJ45 cable insert one right position, then enter any key to continue. ###" keypress
if [ $? -eq 0 ]; then
echo " "
break
fi
echo " "
done
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 10G WAN Testing ####"
udhcpc -t 5 -n -i eth1
if [ $? == 0 ]; then
echo "### Ethernet 10G WAN DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 10G WAN DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 10G LAN ETH6 Testing ####"
udhcpc -t 5 -n -i mxl_lan5
if [ $? == 0 ]; then
echo "### Ethernet 10G LAN ETH6 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 10G LAN ETH6 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 2.5G RJ45 LAN ETH1 Testing ####"
udhcpc -t 5 -n -i mxl_lan0
if [ $? == 0 ]; then
echo "### Ethernet 2.5G RJ45 LAN ETH1 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 2.5G RJ45 LAN ETH1 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 2.5G RJ45 LAN ETH2 Testing ####"
udhcpc -t 5 -n -i mxl_lan1
if [ $? == 0 ]; then
echo "### Ethernet 2.%G RJ45 LAN ETH2 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 2.5G RJ45 LAN ETH2 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 2.5G RJ45 LAN ETH3 Testing ####"
udhcpc -t 5 -n -i mxl_lan2
if [ $? == 0 ]; then
echo "### Ethernet 2.5G RJ45 LAN ETH3 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 2.5G RJ45 LAN ETH3 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 2.5G RJ45 LAN ETH4 Testing ####"
udhcpc -t 5 -n -i mxl_lan3
if [ $? == 0 ]; then
echo "### Ethernet 2.5G RJ45 LAN ETH4 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 2.5G RJ45 LAN ETH4 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 LAN0 ETH5 Testing ####"
udhcpc -t 5 -n -i lan0
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 LAN ETH5 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 LAN ETH5 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G FPC LAN3 Testing ####"
udhcpc -t 5 -n -i lan3
if [ $? == 0 ]; then
echo "### Ethernet 1G FPC LAN3 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G FPC LAN3 DHCP can not got ip address failure"
fi
echo "######################################################################################"
echo " "
echo " "
echo " "
sleep 2
return ${RET}