#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: make_dns_client,v 1.7 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 2000-2002 SuSE Linux Solutions AG, Eschborn, Germany
#               2002-2004 SuSE Linux AG, Eschborn, Germany
#               2005      SUSE GmbH, Nuernberg, Germany
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#############################################################################
#
# Author: Fabian Herschel
#
############################################################################
#
# make_dns_client
# Configures the dns client (/etc/resolv.conf)
#
# Sections: network
# Tags:     DNS_NAMESERVER, DNS_SEARCHLIST
#
test -n "$alice_dir" || alice_dir="/usr/lib/alice2/"
export alice_dir
usage()
{
   cat <<EOF
usage: $0 -h | --help | -?
       $0 -fqhn hostname

EOF
}

while [ $# -gt 0 ]
do
   case $1 in
       -h | --help | -? ) usage
                          exit 1
                          ;;
       -fqhn ) export fqhn=$2; shift
            ;;

   esac
   shift
done   

. $alice_dir/lib/alicerc

WELCOME
std_resolv_conf=/etc/resolv.conf
#
############################################################################
#
GET_CONFIGURATION network $CFG_DEBUG
if [ -n "$DNS_NAMESERVER" ]
then
 (
   cat << EOHD
#
# /etc/resolv.conf
# generated by ALICE unsing $0
# Generation date: $(date)
#
EOHD
   echo "search $DNS_SEARCHLIST"
   for i in $DNS_NAMESERVER
   do
      echo "nameserver $i"
   done 
 ) > ${std_resolv_conf}.alice
    CHANGED ${std_resolv_conf} || {
	BACKUP ${std_resolv_conf}
	mv ${std_resolv_conf}.alice ${std_resolv_conf}
	if [ -x  /$rc_d_dir/nscd ]
	then
	    if  /$rc_d_dir/nscd status | grep -q OK 
	    then
		/$rc_d_dir/nscd restart
	    fi
	fi
    }
fi
#
############################################################################
# Thats all
GOOD_BYE 
