mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
Fix pingtest at ip-up
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
== List of softwares used to build IPFire Version: 2.3-test ==
|
||||
== List of softwares used to build IPFire Version: 2.3-beta2 ==
|
||||
* Archive-Tar-1.29
|
||||
* Archive-Zip-1.16
|
||||
* BerkeleyDB-0.27
|
||||
|
||||
@@ -43,20 +43,36 @@ fi
|
||||
echo -n "$1" > /var/ipfire/red/iface
|
||||
echo -n "$4" > /var/ipfire/red/local-ipaddress
|
||||
echo -n "$5" > /var/ipfire/red/remote-ipaddress
|
||||
|
||||
grep -v "gateway" /etc/hosts > /tmp/hosts
|
||||
|
||||
TEST=`ping -c 2 $5 2>/dev/null | tail -2 | head -1 | cut -d"," -f2`;
|
||||
|
||||
if [ "$TEST" == " 2 packets received" ]; then
|
||||
echo "$5 gateway" >> /tmp/hosts
|
||||
else
|
||||
FIRE=`nslookup ping.ipfire.org | tail -2 | head -1 | cut -d" " -f2`;
|
||||
echo "$FIRE gateway" >> /tmp/hosts
|
||||
fi
|
||||
|
||||
mv /tmp/hosts /etc/hosts
|
||||
echo "$5 gateway" >> /tmp/hosts
|
||||
touch /var/ipfire/red/active
|
||||
mv /tmp/hosts /etc/hosts
|
||||
|
||||
#Start pingtest in background and store the pid
|
||||
ping -c 2 $5 > /tmp/gatewayping &
|
||||
PINGPID=$!
|
||||
|
||||
run_subdir ${rc_base}/init.d/networking/red.up/
|
||||
|
||||
[ -e "/var/ipfire/ppp/nobeeps" ] || /etc/rc.d/init.d/beep up
|
||||
|
||||
#Make sure that pingtest has enough time
|
||||
sleep 3
|
||||
|
||||
#Kill the pingtest
|
||||
kill $PINGPID >/dev/null 2>&1
|
||||
|
||||
#Check if gateway has answerd to ping, if not replace with ping.ipfire.org
|
||||
TEST=`cat /tmp/gatewayping | tail -2 | head -1 | cut -d"," -f2`;
|
||||
|
||||
if [ "$TEST" == " 2 packets received" ]; then
|
||||
echo Ping gateway
|
||||
else
|
||||
echo Ping ipfire
|
||||
FIRE=`nslookup ping.ipfire.org | tail -2 | head -1 | cut -d" " -f2`;
|
||||
grep -v "gateway" /etc/hosts > /tmp/hosts
|
||||
echo "$FIRE gateway" >> /tmp/hosts
|
||||
mv /tmp/hosts /etc/hosts
|
||||
fi
|
||||
rm -f /tmp/gatewayping
|
||||
|
||||
Reference in New Issue
Block a user