Last active
October 25, 2016 08:07
-
-
Save dan82840/64131d3ccf23e60a59d0f61e32dcb4a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# ./test-network.sh [[sequence number]] | |
# | |
LOG_FILE=/tmp/network.log | |
CLIENT_IP="192.168.100.1" | |
# $1: sequence number of testing | |
test_network() { | |
local n=$1 | |
echo "==========================================" >> $LOG_FILE | |
echo -n "[$n]Network restart begins: " >> $LOG_FILE | |
date >> $LOG_FILE | |
#/etc/init.d/network restart | |
reload_config network | |
ubus -t 30 wait_for network.interface.* | |
echo -n "[$n]Network restart ends: " >> $LOG_FILE | |
date >> $LOG_FILE | |
brctl show br-lan >> $LOG_FILE | |
ifconfig ath0 >/dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
echo "[$n]ath0 alive" >> $LOG_FILE | |
else | |
echo "[$n]ath0 not alive" >> $LOG_FILE | |
fi | |
ifconfig ath1 >/dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
echo "[$n]ath1 alive" >> $LOG_FILE | |
else | |
echo "[$n]ath1 not alive" >> $LOG_FILE | |
fi | |
iwconfig ath0 | grep ESSID >> $LOG_FILE | |
iwconfig ath1 | grep ESSID >> $LOG_FILE | |
ping $CLIENT_IP -c 1 >/dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
echo "[$n]Ping OK" >> $LOG_FILE | |
else | |
echo "[$n]Ping NOK" >> $LOG_FILE | |
fi | |
} | |
main() { | |
local count=$1 | |
local c=1 | |
[ -z $count ] && count=1 | |
rm -f $LOG_FILE | |
while [ $c -le $count ]; do | |
test_network "$c" | |
c=$(($c + 1 )) | |
done | |
} | |
main $1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment