|
没有通用性...针对我们自己的设备的...
!/bin/sh
#---------------------------------
#1.var
#---------------------------------
#(1)define var
#1.1 usual var
FTPSERV="192.168.10.1"
FTPSERV2="192.168.20.1"
FTPUSER="1"
FTPPASS="111111"
READCSIZE="142516"
RCSIZE="0"
PLATFORM="none"
USBCHK="none"
POWCHK="none"
ETHX=0
#1.2 error var
WANERR="none"
USBERR="none"
POWERR="none"
STAERR="none"
ALAERR="none"
ADSLERR="none"
#---------------------------------
#2 function
#---------------------------------
jecho()
{
echo -e "\t$1"
}
get_platform()
{
jecho "lease input a choice\n"
jecho "1.008"
jecho "2.108WithADSL"
jecho "3.108WithoutADSL"
jecho "4.exit"
echo -en "\t"
read PLATFORM
case $PLATFORM in
1)PLATFORM="008";;
2)PLATFORM="108WithADSL";;
3)PLATFORM="108WithoutADSL";;
4)exit;;
5)PLATFORM="none";jecho "Invalid input,select again";;
esac
}
check_wan_network()
{
if [ $IXP1 = "192.168.10.10" ] && [ $MASK = "255.255.255.0" ];then
jecho "(3)Info: The Wan interface set to \"$IXP1/$MASK\"..."
else
jecho "(3)Error: Wan interface error"
WANERR="error";
fi
}
check_download_readcert()
{
if [ -f ./readcert ] && [ $RCSIZE -eq $READCSIZE ];then
jecho "(4)Info: Download readcert Success"
else
jecho "(4)Warningownload readcert failed...now exit"
exit 1
fi
}
check_x_property()
{
if [ -x ./readcert ];then
jecho "(5)Info: Get execute property success..."
else
jecho "(5)Warning:readcert can't get execute property,exit..."
exit
fi
}
check_usb()
{
echo -ne "\tNow,Plase insert a usb key has certificate in it..."
read -p "ress any key to continue" -s -n 1 && echo
./readcert
jecho "Question(1): Does it display normally?y|n"
echo -en "\t"
read USBCHK
case $USBCHK in
y|yes|Y|YES)
jecho "(6)Info: USBKey success..."
USBERR="good";
;;
n|no|N|NO)
jecho "(6)Error: USBKey error..."
USBERR="error";
;;
*)
jecho "(6)Warning:Invalid input,please reinput..."
USBERR="none";
;;
esac
}
check_power_led()
{
jecho "Question(2): Does the power led be right?y|n"
echo -ne "\t"
read POWCHK
case $POWCHK in
y|Y|yes|YES)
jecho "(7)Info: Power led seems good..."
POWERR="good"
;;
n|N|no|NO)
jecho "(7)Error: Power led seems error.."
POWERR="error"
;;
*)
jecho "invalid input,please use y or n again."
POWERR="none"
;;
esac
}
check_status_led()
{
jecho "Question(3): Does the status led be right?y|n"
echo -ne "\t"
read STACHK
case $STACHK in
y|Y|yes|YES)
jecho "(8)Info: status led seems good..."
STAERR="good"
;;
n|N|no|NO)
jecho "(8)Error: status led seems error.."
STAERR="error"
;;
*)
jecho "invalid input,please use y or n again."
STAERR="none"
;;
esac
}
check_alarm_led()
{
jecho "Question(4): Does the alarm led be right?y|n"
echo -ne "\t"
read ALACHK
case $ALACHK in
y|Y|yes|YES)
jecho "(9)Info: alarm led seems good..."
ALAERR="good"
;;
n|N|no|NO)
jecho "(9)Error: alarm led seems error.."
ALAERR="error"
;;
*)
jecho "invalid input,please use y or n again."
ALAERR="none"
;;
esac
}
check_108_wan()
{
if [ $WANERR = "error" ];then
jecho "Error()Wan Interface is error..."
fi
}
check_108_adsl_wan()
{
jecho "check_108_adsl_wan"
#1. WANLED
WANLEDCHK="none"
while [ $WANLEDCHK = "none" ]
do
jecho "Question()oes the Wan interface led be right?y|n"
read WANLEDCHK
case $WANLEDCHK in
y|Y|yes|YES)
jecho "()Info:OK,the wan led seems good"
WANLEDCHK="good"
;;
n|N|no|NO)
jecho "()Error:Maybe it has these errors:"
jecho "()Error->108 board ixp1 interface error"
jecho "()Error->adsl board error"
jecho "()Error->adsl and 108 board error"
WANLEDCHK="error"
;;
*)
jecho "Invalid input,please select y or n"
WANLEDCHK="none"
;;
esac
done
#2. ifconfig
ifconfig ixp1 192.168.1.10
ping -c 1 192.168.1.1 >/dev/null 2>&1 && jecho "()Info:adsl and 108 board connect good" || jecho "()Error:adsl and 108 board connect error"
#3. connect adsl line to wan interface
jecho "lease insert adsl line to wan interface,and wait 1 minutes"
while [ $LD5CHK="none" ]
do
jecho "Questionoes ld5 led be right after 1 minutes?"
read LD5CHK
case $LD5CHCK in
y|Y|yes|YES)
jecho "()Info:OK,the adsl line is good"
LD5CHK="good"
;;
n|N|no|NO)
jecho "()Error:Oh,the adsl line or adsl board seems error"
LD5CHK="error"
;;
*)
jecho "Invalid input,Please input y or n"
LD5CHK="none"
;;
esac
done
#4. determine adsl
if [ $WANLEDCHK="good" ] && [ $LD5CHK="good" ];then
jecho "Error(): ADSL board error"
fi
}
check_108_lan()
{
X=0
jecho "Now checking 108 lan..."
while [ $X -lt 7 ]
do
echo -ne "\tPlease connect the eth$X and the ftpserv with ixp0,and press enter"
read
if ping -c 1 $FTPSERV2 >/dev/null 2>&1
then
jecho "(10)Info: eth$X seems good"
eval err$X="good"
else
jecho "(10)Error: eth$X seems error"
eval err$X="error"
fi
X=`expr $X + 1`
done
}
check_008_lan()
{
X=0
while [ $X -lt 4 ]
do
echo -ne "\tPlease connect the lan$X and the ftpserv with ixp0,and press enter"
read
if ping -c 1 $FTPSERV2 >/dev/null 2>&1
then
jecho "(10)Info: eth$X seems good"
eval err$X="good"
else
jecho "(10)Error: eth$X seems error"
eval err$X="error"
fi
X=`expr $X + 1`
done
}
print_led_result()
{
#led power
if [ $POWERR = "good" ];then
jecho "Result(2): Led Power seems good"
elif [ $POWERR = "error" ];then
jecho "Result(2): Led Power seems error"
fi
#led status
if [ $STAERR = "good" ];then
jecho "Result(3): Led status seems good"
elif [ $STAERR = "error" ];then
jecho "Result(3): Led status seems good"
fi
#led alarm
if [ $ALAERR = "good" ];then
jecho "Result(4): Led Alarm seems good"
elif [ $ALAERR = "error" ];then
jecho "Result(4): Led Alarm seem error"
fi
}
print_108_lan_result()
{
Y=0
while [ $Y -lt 7 ]
do
test=`eval 'echo "$err'"$Y"'"'`
if [ $test = "error" ];then
jecho "Result(5): eth$Y seems error"
elif [ $test = "good" ];then
jecho "Result(5): eth$Y seems good"
else
exit
fi
Y=`expr $Y + 1`
done
}
print_008_lan_result()
{
Y=0
while [ $Y -lt 4 ]
do
test=`eval 'echo "$err'"$Y"'"'`
if [ $test = "error" ];then
jecho "Result(5): lan$Y seems error"
elif [ $test = "good" ];then
jecho "Result(5): lan$Y seems good"
else
exit
fi
Y=`expr $Y + 1`
done
}
print_lan_result()
{
if [ $PLATFORM="108WithADSL" ] || [ $PLATFORM="108WithoutADSL" ];then
print_108_lan_result
elif [ $PLATFORM="008" ];then
print_008_lan_result
else
exit
fi
}
print_usb_result()
{
if [ $USBERR = "error" ];then
jecho "Result(1):USB interface seems good"
else
jecho "Result(1):USB interface seems good"
fi
}
print_wan_result()
{
if [ $WANERR="good" ];then
jecho "Result(6): Wan interface seems good"
elif [ $WANERR="error" ];then
jecho "Result(6): Wan interface seems error"
fi
}
print_008_result()
{
print_led_result
print_lan_result
print_wan_result
}
print_108_result()
{
print_usb_result
print_led_result
print_lan_result
print_wan_result
}
print_108_adsl_result()
{
print_usb_result
print_led_result
print_lan_result
print_wan_result
}
#3 test
#3.1 get platform
echo -e "\n\n"
jecho "--===Welcome to sunyard vpn autotest program===--"
echo -e "\n\n"
while [ $PLATFORM = "none" ]
do
get_platform
done
jecho "Here's Test steps----->"
echo -e "\n"
jecho "(1)Info: You have select $PLATFORM"
jecho "(2)Warninglease make sure the ftpserver hasn't got a firewall running"
jecho "please connect the wan and the ftpserv"
#3.2 Network setting
ifconfig ixp1 192.168.10.10 netmask 255.255.255.0
IXP1=`ifconfig ixp1 | grep "inet" | cut -d: -f2 | awk '{print $1}'`
MASK=`ifconfig ixp1 | grep "Mask" | cut -d: -f4`
check_wan_network
#3.3 Download readcert
if [ $PLATFORM = "108WithADSL" ] && [ $PLATFORM = "108WithoutADSL" ];then
wget ftp://$FTPUSERFTPPASS@$FTPSERV/readcert >/dev/null 2>&1
RCSIZE=`ls -l ./readcert | awk '{print $5}'`
check_download_readcert
chmod +x ./readcert
check_x_property
#3.insert usb key and check
while [ $USBERR = "none" ]
do
check_usb
done
fi
#3.2 led test
#3.2.1 power led
while [ $POWERR = "none" ]
do
check_power_led
done
#3.2.2 status led
while [ $STAERR = "none" ]
do
ledflicker 1
check_status_led
done
#3.2.3 alarm led
while [ $ALAERR = "none" ]
do
ledflicker 2
check_alarm_led
done
#3.2.4 108 test
#if [ $PLATFORM="108WithADSL" ] && [ $PLATFORM="108WithoutADSL" ];then
#ledonoff on 1 red
#ledonoff on 2 red
#ledonoff on 3 red
#jecho "Does status alarm and power be red?"
#read LEDRED
#fi
#3.3 wan test
if [ $WANERR = "error" ];then
if [ $PLATFORM = "008" ] || [ $PLATFORM = "108WithoutADSL" ];then
check_108_wan
elif [ $PLATFORM = "108WithADSL" ];then
check_108_adsl_wan
else
jecho "invalid platform..."
exit 1
fi
fi
#3.4 lan test
ifconfig ixp1 down
ifconfig | grep -q "ixp1" && jecho "ixp1 down failed" || jecho "ixp1 down success"
ifconfig ixp0 192.168.20.11 netmask 255.255.255.0 #should check if the ip is ok
if [ $PLATFORM = "008" ];then
check_008_lan #complete
elif [ $PLATFORM = "108WithADSL" ] || [ $PLATFORM = "108WithoutADSL" ];then
check_108_lan #complete
else
jecho "invalid platform..."
exit 2
fi
#3.5 rtc test
jecho "(11)Info: Now time set to 101010102005,Please save and check after it reboot"
date 101010102005 >/dev/null 2>&1
hwclock -w
jecho "(11)Info: Please wait while save the configuration"
bkcon
#4.0 Test Result
echo -e "\n\n"
jecho "-------------Here's the result------------"
echo ""
if [ $PLATFORM = "008" ];then
print_008_result
elif [ $PLATFORM = "108WithoutADSL" ];then
print_108_result
elif [ $PLATFORM = "108WithADSL" ];then
print_108_adsl_result
fi |
|