#! /bin/sh
#
# Copyright (c) 2001-2002 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# /etc/init.d/boot.localnet
#
### BEGIN INIT INFO
# Provides:          boot.localnet
# Required-Start:    boot.cleanup
# Required-Stop:
# Default-Start:     B
# Default-Stop:
# Description:       setup hostname and yp
### END INIT INFO

. /etc/rc.status
. /etc/sysconfig/cron

rc_reset

case "$1" in
  start)
	# clean up old yp bindings
	rm -f /var/yp/binding/*.[12]
	
	#
	# set hostname and domainname
	#
	XHOSTNAME=""
	test -f /etc/HOSTNAME && {
	    XHOSTNAME=`cat /etc/HOSTNAME`
	}
	test -n "$XHOSTNAME" && {
	    echo -n Setting up hostname \'${XHOSTNAME%%.*}\'
	    hostname ${XHOSTNAME%%.*}
	    rc_status -v -r
	}
	
	XDOMAINNAME=""
	test -f /etc/defaultdomain && {
	    XDOMAINNAME=`cat /etc/defaultdomain`
	}
        test -n "$XDOMAINNAME" && {
	    echo -n Setting up NIS domainname \'$XDOMAINNAME\'
        }
	domainname "$XDOMAINNAME"
        test -n "$XDOMAINNAME" && {
	rc_status -v -r
        }
	
	unset XHOSTNAME
	unset XDOMAINNAME

	test -x /sbin/ifup -a -f /etc/sysconfig/network/ifcfg-lo && {
	    echo -n "Setting up loopback interface "
	    /sbin/ifup lo -o rc manual
            rc_status -v -r
	}
	;;
    stop|restart)
        # skip / nothing to do
	;;
    status)
	rc_failed 4
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1
	;;
esac

rc_exit
	
