2015-03-27 21:55:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test -z "$1" && echo "Error: should be called from udhcpc" && exit 1
|
|
|
|
|
|
|
|
RESOLV_CONF="/etc/resolv.conf"
|
|
|
|
test -n "$broadcast" && BROADCAST="broadcast $broadcast"
|
|
|
|
test -n "$subnet" && NETMASK="netmask $subnet"
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
deconfig)
|
2015-04-09 09:53:52 +02:00
|
|
|
logger -p local0.notice "DHCP deconfig"
|
2015-03-27 21:55:18 +01:00
|
|
|
grep -q -v ip= /proc/cmdline
|
|
|
|
if test $? -eq 0; then
|
2015-04-09 09:53:52 +02:00
|
|
|
ifconfig $interface up
|
2015-03-27 21:55:18 +01:00
|
|
|
fi
|
|
|
|
grep -q -v nfsroot= /proc/cmdline
|
|
|
|
if test $? -eq 0; then
|
2015-04-09 09:53:52 +02:00
|
|
|
ifconfig $interface 0.0.0.0
|
2015-03-27 21:55:18 +01:00
|
|
|
fi
|
2015-04-09 09:53:52 +02:00
|
|
|
rm -f /tmp/satip-network
|
|
|
|
killall -9 minisatip 2> /dev/null
|
2015-03-27 21:55:18 +01:00
|
|
|
;;
|
|
|
|
leasefail|nak)
|
2015-04-09 09:53:52 +02:00
|
|
|
logger -p local0.notice "DHCP $1"
|
2015-03-27 21:55:18 +01:00
|
|
|
;;
|
|
|
|
renew|bound)
|
2015-04-09 09:53:52 +02:00
|
|
|
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
|
2015-03-27 21:55:18 +01:00
|
|
|
if test -n "$router" ; then
|
2015-04-09 09:53:52 +02:00
|
|
|
while route del default gw 0.0.0.0 dev $interface 2> /dev/null; do
|
2015-03-27 21:55:18 +01:00
|
|
|
:
|
|
|
|
done
|
|
|
|
for i in $router ; do
|
|
|
|
route add default gw $i dev $interface
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
echo -n > $RESOLV_CONF
|
|
|
|
test -n "$domain" && echo "search $domain" >> $RESOLV_CONF
|
|
|
|
for i in $dns ; do
|
|
|
|
echo "nameserver $i" >> $RESOLV_CONF
|
|
|
|
done
|
2018-09-17 09:38:39 +02:00
|
|
|
# kill always ntpd
|
|
|
|
killall -9 ntpd 2> /dev/null
|
2015-04-09 09:53:52 +02:00
|
|
|
# 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
|
2015-03-27 21:55:18 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exit 0
|