#!/bin/sh
# Sample udhcpc renew script

. /etc/init.d/shell-utils.sh
DEBUG=0

[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

/sbin/ifconfig $interface $ip $BROADCAST $NETMASK

# assign metric value based on interface
if [ "$interface" == "eth0" ]; then
  metric=0
else
  metric=1
fi

# update default gw for given interface
update_default_gw_for_interface "$interface" "$router" "$metric"

if [ ! -f $RESOLV_CONF ]; then
    echo "options rotate          #options" > $RESOLV_CONF
    echo "options timeout: 1      #options" >> $RESOLV_CONF
fi

exclude $RESOLV_CONF $interface

if [ "$interface" == "eth0" ]; then
  get_fw_env "dnsip" DNS_IP
else
  get_fw_env "wifi_int_dns" DNS_IP
fi

if [ -n "$DNS_IP" ]; then
  echo nameserver $DNS_IP " #$interface" >> $RESOLV_CONF
else
  [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
  for i in $dns
  do
    echo adding dns $i
    echo nameserver $i " #$interface"   >> $RESOLV_CONF
  done
fi

