testing-script/ethernet-script/ethernet-script.sh
2025-04-07 17:28:13 +08:00

109 lines
3.1 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 and 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 SFP+ WAN Testing ####"
udhcpc -t 5 -n -i eth2
if [ $? == 0 ]; then
echo "### Ethernet 10G SFP+ WAN DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 10G SFP+ WAN DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 10G SFP+ LAN Testing ####"
udhcpc -t 5 -n -i eth1
if [ $? == 0 ]; then
echo "### Ethernet 10G SFP+ LAN DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 10G SFP+ LAN DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 LAN 0 Testing ####"
udhcpc -t 5 -n -i lan0
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 LAN 0 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 LAN 0 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 LAN 1 Testing ####"
udhcpc -t 5 -n -i lan1
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 LAN 1 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 LAN 1 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 LAN 2 Testing ####"
udhcpc -t 5 -n -i lan2
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 LAN 2 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 LAN 2 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 LAN 3 Testing ####"
udhcpc -t 5 -n -i lan3
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 LAN 3 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 LAN 3 DHCP can not got ip address failure"
fi
echo "######################################################################################"
echo " "
echo " "
echo " "
sleep 2
return ${RET}