11.8Ssalo# $NetBSD: dot.instutils,v 1.8 2003/07/26 17:07:38 salo Exp $
21.1Sperry#
31.1Sperry# Copyright (c) 1994 Christopher G. Demetriou
41.1Sperry# All rights reserved.
51.1Sperry# 
61.1Sperry# Redistribution and use in source and binary forms, with or without
71.1Sperry# modification, are permitted provided that the following conditions
81.1Sperry# are met:
91.1Sperry# 1. Redistributions of source code must retain the above copyright
101.1Sperry#    notice, this list of conditions and the following disclaimer.
111.1Sperry# 2. Redistributions in binary form must reproduce the above copyright
121.1Sperry#    notice, this list of conditions and the following disclaimer in the
131.1Sperry#    documentation and/or other materials provided with the distribution.
141.1Sperry# 3. All advertising materials mentioning features or use of this software
151.1Sperry#    must display the following acknowledgement:
161.7Scgd#          This product includes software developed for the
171.8Ssalo#          NetBSD Project.  See http://www.NetBSD.org/ for
181.7Scgd#          information about NetBSD.
191.1Sperry# 4. The name of the author may not be used to endorse or promote products
201.7Scgd#    derived from this software without specific prior written permission.
211.7Scgd# 
221.1Sperry# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1Sperry# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.1Sperry# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.1Sperry# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.1Sperry# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
271.1Sperry# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
281.1Sperry# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291.1Sperry# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
301.1Sperry# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
311.1Sperry# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321.7Scgd# 
331.7Scgd# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
341.1Sperry
351.1Sperry# Installation configuration utilities (functions), to get NetBSD configured
361.1Sperry# reasonably once it is installed on the hard disk.  These are meant to be
371.1Sperry# invoked from the shell prompt, by people installing NetBSD.
381.1Sperry
391.3Sperryconfig_int()
401.3Sperry{
411.3Sperry	local intf resp ifname ifaddr ifflags
421.3Sperry	intf=$1
431.3Sperry	case "$intf" in
441.3Sperry		""|lo*|ppp*|sl*|tun*)
451.3Sperry			return 0;
461.3Sperry			;;
471.3Sperry		*)
481.3Sperry			;;
491.3Sperry	esac
501.3Sperry		
511.3Sperry	echo -n "Configure" $intf "? [y]"
521.3Sperry	read resp
531.3Sperry	case "$resp" in
541.3Sperry	n*|N*)
551.3Sperry		return 0;
561.3Sperry		;;
571.3Sperry	*)
581.3Sperry		;;
591.3Sperry	esac
601.3Sperry
611.3Sperry	echo -n "What is the hostname for this interface? [$hname] "
621.3Sperry	read ifname
631.3Sperry	if [ "$ifname" = "" ]; then
641.3Sperry		ifname=$hname
651.3Sperry	fi
661.3Sperry	ifaddr=
671.3Sperry	while [ "$ifaddr" = "" ]; do
681.3Sperry		echo -n "What is the IP address associated with "
691.3Sperry		echo -n "interface ${intf}? "
701.3Sperry		read ifaddr
711.3Sperry	done
721.3Sperry	echo "$ifaddr	$ifname `echo $ifname | sed -e s/\.$dname//`" \
731.3Sperry	    >> ${ETC}/hosts
741.3Sperry
751.3Sperry	echo -n "Does this interface have a special netmask? [n] "
761.3Sperry	read resp
771.3Sperry	case "$resp" in
781.3Sperry		y*)
791.3Sperry			echo -n "What is the netmask? [0xffffff00] "
801.3Sperry			read ifnetmask
811.3Sperry			if [ "$ifnetmask" = "" ]; then
821.3Sperry				ifnetmask=0xffffff00
831.3Sperry			fi
841.3Sperry			ifnetmask_arg="netmask $ifnetmask"
851.3Sperry			;;
861.3Sperry		*)
871.3Sperry			ifnetmask=
881.3Sperry			ifnetmask_arg=
891.3Sperry			;;
901.3Sperry	esac
911.3Sperry
921.3Sperry	echo -n "Does this interface need a special media type? [n] "
931.3Sperry	read resp
941.3Sperry	case "$resp" in
951.3Sperry		y*)
961.3Sperry			echo -n "What media type? [10baseT/UTP] "
971.3Sperry			read ifflags
981.3Sperry			if [ "$ifflags" = "" ]; then
991.3Sperry				ifflags="10baseT/UTP"
1001.3Sperry			fi
1011.3Sperry			ifflags_arg="media $ifflags"
1021.3Sperry			;;
1031.3Sperry		*)
1041.3Sperry			ifflags=
1051.3Sperry			ifflags_arg=
1061.3Sperry			;;
1071.3Sperry	esac
1081.3Sperry	echo "inet $ifname $ifnetmask_arg $ifflags_arg" > ${ETC}/ifconfig.$intf
1091.3Sperry}
1101.3Sperry
1111.3Sperry
1121.1SperryConfigure()
1131.1Sperry{
1141.1Sperry	DEV=/dev
1151.1Sperry	ETC=/etc
1161.3Sperry	ROOT=/
1171.1Sperry	if [ ! -f /etc/fstab ]; then
1181.1Sperry		DEV=/mnt/dev
1191.1Sperry		ETC=/mnt/etc
1201.3Sperry		ROOT=/mnt
1211.1Sperry	fi
1221.1Sperry
1231.1Sperry	echo	"You will now be prompted for information about this"
1241.1Sperry	echo	"machine.  If you hit return, the default answer (in"
1251.1Sperry	echo	"brackets) will be used."
1261.1Sperry
1271.1Sperry	echo	""
1281.1Sperry	echo -n	"What is this machine's hostname? [unknown.host.domain] "
1291.1Sperry	read hname
1301.1Sperry	if [ "$hname" = "" ]; then
1311.1Sperry		hname=unknown.host.domain
1321.1Sperry	fi
1331.1Sperry	echo $hname > ${ETC}/myname
1341.1Sperry	proto_domain=`echo $hname | sed -e 's/[^.]*\.//'`
1351.1Sperry
1361.1Sperry	echo	""
1371.5Scgd	echo	"What DNS domain is this machine in (this is NOT its YP"
1381.1Sperry	echo -n	"domain name)? [$proto_domain] "
1391.1Sperry	read dname
1401.1Sperry	if [ "$dname" = "" ]; then
1411.1Sperry		dname=$proto_domain
1421.1Sperry	fi
1431.1Sperry
1441.1Sperry	echo	""
1451.1Sperry	if [ -e $ETC/sendmail.cf ]; then
1461.1Sperry		echo	"WARNING: A default sendmail.cf exists, and probably"
1471.1Sperry		echo	"needs to be tuned and/or replaced, to work properly at"
1481.1Sperry		echo	"your site!"
1491.1Sperry	else
1501.1Sperry		echo	"WARNING: No default sendmail.cf installed.  Did you"
1511.1Sperry		echo	"forget to install the 'etc' distribution?"
1521.1Sperry	fi
1531.1Sperry
1541.1Sperry	echo	"127.0.0.1	localhost localhost.$dname" > ${ETC}/hosts
1551.1Sperry
1561.1Sperry	echo	""
1571.3Sperry	echo -n	"Configure network interfaces? [y] "
1581.1Sperry        read resp
1591.1Sperry        case "$resp" in
1601.1Sperry	n*)
1611.1Sperry		;;
1621.1Sperry	*)
1631.3Sperry		for if in `ifconfig -l`
1641.3Sperry		do
1651.3Sperry			config_int $if
1661.1Sperry		done
1671.1Sperry		;;
1681.1Sperry	esac
1691.3Sperry
1701.1Sperry	
1711.1Sperry	echo	""
1721.1Sperry	echo -n	"Making device nodes (may take a while)..."
1731.1Sperry	cd ${DEV}
1741.1Sperry	sh MAKEDEV all
1751.1Sperry	echo	" done."
1761.1Sperry
1771.1Sperry	sync
1781.1Sperry
1791.3Sperry	if [ ! -f ${ROOT}/netbsd ]
1801.3Sperry	then
1811.3Sperry		echo "You have not unpacked the kernel installation"
1821.3Sperry		echo "set. You must do so before you reboot."
1831.3Sperry	fi
1841.1Sperry}
1851.1Sperry
1861.1Sperry# Upgrade cleanup utilities (functions), to make sure a recently-upgraded
1871.1Sperry# system is safely runnable.  These are meant to be invoked from the shell
1881.1Sperry# prompt, by people installing NetBSD.
1891.1Sperry
1901.1SperryCleanup()
1911.1Sperry{
1921.1Sperry	upgrade_dir=/
1931.1Sperry
1941.1Sperry	if [ ! -f /etc/fstab ]; then
1951.1Sperry		upgrade_dir=/mnt
1961.1Sperry	fi
1971.1Sperry
1981.1Sperry	echo	"Cleaning up miscellaneous files in /etc..."
1991.1Sperry	mv $upgrade_dir/etc/rc.bak $upgrade_dir/etc/rc
2001.1Sperry	chroot $upgrade_dir /usr/sbin/pwd_mkdb -p /etc/master.passwd
2011.1Sperry	chroot $upgrade_dir /bin/rm /etc/sendmail.fc > /dev/null 2>&1
2021.1Sperry	sync
2031.1Sperry	echo	"Done."
2041.1Sperry
2051.1Sperry	echo	""
2061.1Sperry	echo	"All that's left to do now is to install a new NetBSD kernel"
2071.1Sperry	echo	"on your hard disk.  You should now halt your machine using"
2081.1Sperry	echo	"the 'halt' command.  Once the machine is halted, replace the"
2091.1Sperry	echo	"installation floppy with the kernel-copy floppy and hit any"
2101.1Sperry	echo	"key to reboot.  Use the kernel-copy floppy to copy a kernel"
2111.1Sperry	echo	"to your hard disk."
2121.1Sperry}
213