dhcp: start minisatip after dhcp obtained ip address

This commit is contained in:
Jaroslav Kysela 2015-04-09 09:53:52 +02:00
parent b86c6ec039
commit 2e5e6a4eb7
5 changed files with 38 additions and 8 deletions

View File

@ -1,4 +1,4 @@
BUILD=4
BUILD=5
VERSION=$(shell date +%Y%m%d%H%M)-$(BUILD)
CPUS=4
STLINUX=/opt/STM/STLinux-2.4

View File

@ -8,22 +8,32 @@ test -n "$subnet" && NETMASK="netmask $subnet"
case "$1" in
deconfig)
logger -p local0.notice "DHCP deconfig"
grep -q -v ip= /proc/cmdline
if test $? -eq 0; then
/sbin/ifconfig $interface up
ifconfig $interface up
fi
grep -q -v nfsroot= /proc/cmdline
if test $? -eq 0; then
/sbin/ifconfig $interface 0.0.0.0
ifconfig $interface 0.0.0.0
fi
rm -f /tmp/satip-network
killall -9 minisatip 2> /dev/null
;;
leasefail|nak)
logger -p local0.notice "DHCP $1"
;;
renew|bound)
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
old=$(ifconfig $interface | head -2 | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)
logger -p local0.notice "DHCP $1 ('$ip' '$BROADCAST' '$NETMASK' | '$router' '$dns') replacing '$old'"
if test "$old" != "$ip" -a -r /tmp/satip-network; then
logger -p local0.notice "DHCP IPv4 changed, killing minisatip"
rm -f /tmp/satip-network
killall -9 minisatip 2> /dev/null
fi
ifconfig $interface $ip $BROADCAST $NETMASK
if test -n "$router" ; then
echo "deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do
while route del default gw 0.0.0.0 dev $interface 2> /dev/null; do
:
done
for i in $router ; do
@ -33,9 +43,12 @@ renew|bound)
echo -n > $RESOLV_CONF
test -n "$domain" && echo "search $domain" >> $RESOLV_CONF
for i in $dns ; do
echo "adding dns $i"
echo "nameserver $i" >> $RESOLV_CONF
done
# notify satip init script
echo "ok" | nc 127.0.0.1 999 2> /dev/null
sleep 0.5
echo "ok" | nc 127.0.0.1 999 2> /dev/null
;;
esac
exit 0

View File

@ -3,7 +3,7 @@
test -r /etc/sysconfig/config && . /etc/sysconfig/config
if test "$IPV4" = "dhcp"; then
exec /sbin/udhcpc -f -S -p /tmp/udhcpc.pid -s /etc/init.d/dhcpc-event
exec /sbin/udhcpc -f -S -p /var/run/udhcpc.pid -s /etc/init.d/dhcpc-event
else
ifconfig eth0 $IPV4 netmask $IPV4_NETMASK broadcast $IPV4_BROADCAST
route add default gw $IPV4_GATEWAY
@ -12,3 +12,11 @@ fi
if test -r /etc/sysconfig/resolv.conf; then
ln -s sysconfig/resolv.conf /etc/resolv.conf
fi
# notify satip init script
touch /tmp/satip-network
echo "ok" | nc 127.0.0.1 999 2> /dev/null
sleep 0.5
echo "ok" | nc 127.0.0.1 999 2> /dev/null
sleep 1
echo "ok" | nc 127.0.0.1 999 2> /dev/null

View File

@ -8,6 +8,9 @@ fi
cd /tmp
while test ! -f /tmp/nosatip; do
while ! test -r /tmp/satip-network; do
nc -l 127.0.0.1:999 -e /etc/init.d/satip-network
done
minisatip -f -g $MINISATIP_OPTS
logger "minisatip exited $?, restarting"
done

View File

@ -0,0 +1,6 @@
#!/bin/sh
read i
if test "$i" = "ok"; then
touch /tmp/satip-network
fi