#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: make_oem,v 1.3 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 2000 SuSE Linux Solutions AG, Eschborn, 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: Juergen Henge-Ernst
#
############################################################################
#
# make_oem
# change some settings after installation to ship the ready configured PC
# to the customer
#
# Sections: oem
# Tags:     DNS_*, NET_IP_CONFIG, DEF_GATEWAY
#
# TODO: Check if we need this program any longer
# TODO: If needed, update for SLES8 and above
#

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

std_route_conf=/etc/route.conf
WELCOME
#
############################################################################
#
GET_CONFIGURATION --require oem $CFG_DEBUG

#
# Set the new default gateway
#
if [ -n "$DEF_GATEWAY" ]; then
	echo "default $DEF_GATEWAY" >> ${std_route_conf}.alice
fi
mv ${std_route_conf}.alice ${std_route_conf}

#
# Set the nameservers
#
if [ -n "${DNS_NAMESERVER}" ]; then
	RC_CONFIG_SET NAMESERVER "${DNS_NAMESERVER}"
	RC_CONFIG_SET SERACHLIST "${DNS_SERACHLIST}"
	(
	echo "# generated via make_oem"
	for i in ${DNS_NAMESERVER}
	do
		echo "nameserver $i"
	done
	echo "search ${DNS_SEARCHLIST}"
	) > /etc/resolv.conf
fi

#
# Set the interface configuration
#
if [ -n "$NET_IP_CONFIG" ]; then
	i=0
	echo "$NET_IP_CONFIG" | while read dev ip netmask bcast ; do
		RC_CONFIG_SET IPADDR_$i "$ip"
		RC_CONFIG_SET NETDEV_$i "$dev"
		RC_CONFIG_SET IFCONFIG_$i "$ip broadcast $bcast netmask $netmask"
		i=$[ $i + 1 ]
	done;
	#
	# TODO: make NETCONFIG configure more than the first device
	#
	RC_CONFIG_SET NETCONFIG "_0"
fi

/sbin/SuSEconfig

#
############################################################################
# Thats all
GOOD_BYE 
