#! /bin/sh

PREREQ="network"

prereqs()
{
	echo "$PREREQ"
}

case $1 in
prereqs)
	prereqs
	exit 0
	;;
esac

. /scripts/functions
. /scripts/functions-uniklu

[ "$quiet" != "y" ] && log_begin_msg "Initializing resolver library"
if [ ! -e /tmp/NETDEV ]; then
  [ "$quiet" != "y" ] && log_warning_msg "No network device found!" 
  #/bin/sh
else
  . /tmp/NETDEV
  . /tmp/net-${NETDEV}.conf
  rm -f  ${rootmnt}/etc/resolv.conf
  if [ -n "${DNSDOMAIN}" ]; then
    echo "search ${DNSDOMAIN}" > /etc/resolv.conf
  fi

  echo "nameserver ${IPV4DNS0}" >> /etc/resolv.conf  
  if [ -n "${IPV4DNS1}" ]; then
     echo "nameserver ${IPV4DNS1}" >> /etc/resolv.conf  
  fi
  if [ -z "${HOSTNAME}" ]; then
    hn=$(host $IPV4ADDR | awk '{print $5}')
    HOSTNAME=${hn%.}
  fi 
  if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
    HOSTNAME="client-ubuntu.localdomain"
  fi

  echo ${HOSTNAME} > /etc/hostname
  echo ${HOSTNAME} > /etc/mailname
  SHORTHOSTNAME=${HOSTNAME%%.*}
  echo "$IPV4ADDR ${HOSTNAME} ${SHORTHOSTNAME}" > /etc/hosts  
  echo "127.0.0.1 localhost.localdomain localhost" >> /etc/hosts  
fi
[ "$quiet" != "y" ] && log_end_msg

