#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: make_ypbind,v 1.2 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_ypbind
# configures ypclient
#
# TODO: Update this program to work with SLES8 and above
#       for now use make_config_files and make_sysconfig instead
#
# Sections:	ypbind
# Tags:	        START_YPBIND, YP_SERVER, YP_DOMAINE_NAME, START_PORTMAP, 
# Tags:         CREATE_YP_CONF, USE_NETGROUPS
#
##############################################################################
 
usage()
{
   echo "$_self -h | --help | -?"
   echo "$_self -fqhn"
}

test -n "$alice_dir" || alice_dir="/usr/lib/alice2/"
export alice_dir

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
GET_CONFIGURATION $GET_CONFIG_OPTION ypbind

#################################################################
#
# in order to make all startup scripts happy we set variables
# in /etc/rc.config correctly
#
#################################################################
#
# let's see if rc.config sets START_YPBIND correctly
 
RC_CONFIG_SET START_YPBIND ${START_YPBIND}

################################################################
#                                     
# let's see if rc.config sets YP_SERVER correctly

RC_CONFIG_SET YP_SERVER ${YP_SERVER}

##############################################################
#
# let's see if rc.config sets YP_DOMAINNAME correctly

RC_CONFIG_SET YP_DOMAINNAME ${YP_DOMAINNAME}

##############################################################
#
# let's see if rc.config sets START_PORTMAP correctly

RC_CONFIG_SET START_PORTMAP $START_PORTMAP

##############################################################
#
# let's see if rc.config sets CREATE_YP_CONF correctly

RC_CONFIG_SET CREATE_YP_CONF ${CREATE_YP_CONF}

#
###############################################################
#
# now we can configure the /etc/yp.conf file
#

#BACKUP /etc/yp.conf 2>/dev/null
#(
#    echo "# /etc/yp.conf"
#    echo "# generated by RRZE alice $(date)"
#    if [ -n "$YP_SERVER" ]
#    then
#       echo "ypserver      $YP_SERVER"
#    else
#       echo "# no ypserver set !!"
#    fi       
#) > /etc/yp.conf

# Thats all .... if our new script alice-setup/bin/make_suseconfig is a nice guy

#
# make sure that we have netgroup support here!
#

if [ "$USE_NETGROUPS" = "yes" ]; then
  sed -e s+"^netgroup:.*"+"netgroup:       nis files"+ /etc/nsswitch.conf > /etc/nsswitch.conf.2
  mv /etc/nsswitch.conf.2 /etc/nsswitch.conf
fi

GOOD_BYE
