testing-script/ethernet-script/ethernet-script.sh
2025-04-15 14:12:57 +08:00

110 lines
3.1 KiB
Bash
Executable File

#/bin/bash
RET=0
sleep 2
echo " "
echo " "
echo " "
echo "######################################################################################"
ifconfig eth4 up
ifconfig eth5 up
ifconfig eth0 up
ifconfig eth1 up
ifconfig eth2 up
ifconfig eth3 up
ifconfig br-lan down
brctl delbr br-lan
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 2.5G RJ45 WAN Testing ####"
udhcpc -t 5 -n -i eth4
if [ $? == 0 ]; then
echo "### Ethernet 2.5G RJ45 WAN DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 2.5G RJ45 WAN DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 LAN Testing ####"
udhcpc -t 5 -n -i eth5
if [ $? == 0 ]; then
echo "### Ethernet 1G 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 ETH 0 Testing ####"
udhcpc -t 5 -n -i eth0
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 ETH 0 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 ETH 0 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 ETH 1 Testing ####"
udhcpc -t 5 -n -i eth1
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 ETH 1 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 ETH 1 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 ETH 2 Testing ####"
udhcpc -t 5 -n -i eth2
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 ETH 2 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 ETH 2 DHCP can not got ip address failure"
fi
echo "----------------------------------------------------------------------------------------"
sleep 3
echo "### Ethernet 1G RJ45 ETH 3 Testing ####"
udhcpc -t 5 -n -i eth3
if [ $? == 0 ]; then
echo "### Ethernet 1G RJ45 ETH 3 DHCP got ip address successfully ###"
else
RET=1
echo "Error Notice: Ethernet 1G RJ45 ETH 3 DHCP can not got ip address failure"
fi
echo "######################################################################################"
echo " "
echo " "
echo " "
sleep 2
return ${RET}