xref: /netbsd-src/distrib/utils/script-installer/dot.instutils (revision 8d1781e39d68be4d52a585d8d0631111639fd30a)
1*8d1781e3Ssalo# $NetBSD: dot.instutils,v 1.8 2003/07/26 17:07:38 salo Exp $
23148c0e4Sperry#
33148c0e4Sperry# Copyright (c) 1994 Christopher G. Demetriou
43148c0e4Sperry# All rights reserved.
53148c0e4Sperry#
63148c0e4Sperry# Redistribution and use in source and binary forms, with or without
73148c0e4Sperry# modification, are permitted provided that the following conditions
83148c0e4Sperry# are met:
93148c0e4Sperry# 1. Redistributions of source code must retain the above copyright
103148c0e4Sperry#    notice, this list of conditions and the following disclaimer.
113148c0e4Sperry# 2. Redistributions in binary form must reproduce the above copyright
123148c0e4Sperry#    notice, this list of conditions and the following disclaimer in the
133148c0e4Sperry#    documentation and/or other materials provided with the distribution.
143148c0e4Sperry# 3. All advertising materials mentioning features or use of this software
153148c0e4Sperry#    must display the following acknowledgement:
16db755e7cScgd#          This product includes software developed for the
17*8d1781e3Ssalo#          NetBSD Project.  See http://www.NetBSD.org/ for
18db755e7cScgd#          information about NetBSD.
193148c0e4Sperry# 4. The name of the author may not be used to endorse or promote products
20db755e7cScgd#    derived from this software without specific prior written permission.
213148c0e4Sperry#
223148c0e4Sperry# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
233148c0e4Sperry# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
243148c0e4Sperry# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
253148c0e4Sperry# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
263148c0e4Sperry# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
273148c0e4Sperry# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
283148c0e4Sperry# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
293148c0e4Sperry# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
303148c0e4Sperry# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
313148c0e4Sperry# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32db755e7cScgd#
33db755e7cScgd# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
343148c0e4Sperry
353148c0e4Sperry# Installation configuration utilities (functions), to get NetBSD configured
363148c0e4Sperry# reasonably once it is installed on the hard disk.  These are meant to be
373148c0e4Sperry# invoked from the shell prompt, by people installing NetBSD.
383148c0e4Sperry
39945e8578Sperryconfig_int()
40945e8578Sperry{
41945e8578Sperry	local intf resp ifname ifaddr ifflags
42945e8578Sperry	intf=$1
43945e8578Sperry	case "$intf" in
44945e8578Sperry		""|lo*|ppp*|sl*|tun*)
45945e8578Sperry			return 0;
46945e8578Sperry			;;
47945e8578Sperry		*)
48945e8578Sperry			;;
49945e8578Sperry	esac
50945e8578Sperry
51945e8578Sperry	echo -n "Configure" $intf "? [y]"
52945e8578Sperry	read resp
53945e8578Sperry	case "$resp" in
54945e8578Sperry	n*|N*)
55945e8578Sperry		return 0;
56945e8578Sperry		;;
57945e8578Sperry	*)
58945e8578Sperry		;;
59945e8578Sperry	esac
60945e8578Sperry
61945e8578Sperry	echo -n "What is the hostname for this interface? [$hname] "
62945e8578Sperry	read ifname
63945e8578Sperry	if [ "$ifname" = "" ]; then
64945e8578Sperry		ifname=$hname
65945e8578Sperry	fi
66945e8578Sperry	ifaddr=
67945e8578Sperry	while [ "$ifaddr" = "" ]; do
68945e8578Sperry		echo -n "What is the IP address associated with "
69945e8578Sperry		echo -n "interface ${intf}? "
70945e8578Sperry		read ifaddr
71945e8578Sperry	done
72945e8578Sperry	echo "$ifaddr	$ifname `echo $ifname | sed -e s/\.$dname//`" \
73945e8578Sperry	    >> ${ETC}/hosts
74945e8578Sperry
75945e8578Sperry	echo -n "Does this interface have a special netmask? [n] "
76945e8578Sperry	read resp
77945e8578Sperry	case "$resp" in
78945e8578Sperry		y*)
79945e8578Sperry			echo -n "What is the netmask? [0xffffff00] "
80945e8578Sperry			read ifnetmask
81945e8578Sperry			if [ "$ifnetmask" = "" ]; then
82945e8578Sperry				ifnetmask=0xffffff00
83945e8578Sperry			fi
84945e8578Sperry			ifnetmask_arg="netmask $ifnetmask"
85945e8578Sperry			;;
86945e8578Sperry		*)
87945e8578Sperry			ifnetmask=
88945e8578Sperry			ifnetmask_arg=
89945e8578Sperry			;;
90945e8578Sperry	esac
91945e8578Sperry
92945e8578Sperry	echo -n "Does this interface need a special media type? [n] "
93945e8578Sperry	read resp
94945e8578Sperry	case "$resp" in
95945e8578Sperry		y*)
96945e8578Sperry			echo -n "What media type? [10baseT/UTP] "
97945e8578Sperry			read ifflags
98945e8578Sperry			if [ "$ifflags" = "" ]; then
99945e8578Sperry				ifflags="10baseT/UTP"
100945e8578Sperry			fi
101945e8578Sperry			ifflags_arg="media $ifflags"
102945e8578Sperry			;;
103945e8578Sperry		*)
104945e8578Sperry			ifflags=
105945e8578Sperry			ifflags_arg=
106945e8578Sperry			;;
107945e8578Sperry	esac
108945e8578Sperry	echo "inet $ifname $ifnetmask_arg $ifflags_arg" > ${ETC}/ifconfig.$intf
109945e8578Sperry}
110945e8578Sperry
111945e8578Sperry
1123148c0e4SperryConfigure()
1133148c0e4Sperry{
1143148c0e4Sperry	DEV=/dev
1153148c0e4Sperry	ETC=/etc
116945e8578Sperry	ROOT=/
1173148c0e4Sperry	if [ ! -f /etc/fstab ]; then
1183148c0e4Sperry		DEV=/mnt/dev
1193148c0e4Sperry		ETC=/mnt/etc
120945e8578Sperry		ROOT=/mnt
1213148c0e4Sperry	fi
1223148c0e4Sperry
1233148c0e4Sperry	echo	"You will now be prompted for information about this"
1243148c0e4Sperry	echo	"machine.  If you hit return, the default answer (in"
1253148c0e4Sperry	echo	"brackets) will be used."
1263148c0e4Sperry
1273148c0e4Sperry	echo	""
1283148c0e4Sperry	echo -n	"What is this machine's hostname? [unknown.host.domain] "
1293148c0e4Sperry	read hname
1303148c0e4Sperry	if [ "$hname" = "" ]; then
1313148c0e4Sperry		hname=unknown.host.domain
1323148c0e4Sperry	fi
1333148c0e4Sperry	echo $hname > ${ETC}/myname
1343148c0e4Sperry	proto_domain=`echo $hname | sed -e 's/[^.]*\.//'`
1353148c0e4Sperry
1363148c0e4Sperry	echo	""
1371efdb577Scgd	echo	"What DNS domain is this machine in (this is NOT its YP"
1383148c0e4Sperry	echo -n	"domain name)? [$proto_domain] "
1393148c0e4Sperry	read dname
1403148c0e4Sperry	if [ "$dname" = "" ]; then
1413148c0e4Sperry		dname=$proto_domain
1423148c0e4Sperry	fi
1433148c0e4Sperry
1443148c0e4Sperry	echo	""
1453148c0e4Sperry	if [ -e $ETC/sendmail.cf ]; then
1463148c0e4Sperry		echo	"WARNING: A default sendmail.cf exists, and probably"
1473148c0e4Sperry		echo	"needs to be tuned and/or replaced, to work properly at"
1483148c0e4Sperry		echo	"your site!"
1493148c0e4Sperry	else
1503148c0e4Sperry		echo	"WARNING: No default sendmail.cf installed.  Did you"
1513148c0e4Sperry		echo	"forget to install the 'etc' distribution?"
1523148c0e4Sperry	fi
1533148c0e4Sperry
1543148c0e4Sperry	echo	"127.0.0.1	localhost localhost.$dname" > ${ETC}/hosts
1553148c0e4Sperry
1563148c0e4Sperry	echo	""
157945e8578Sperry	echo -n	"Configure network interfaces? [y] "
1583148c0e4Sperry        read resp
1593148c0e4Sperry        case "$resp" in
1603148c0e4Sperry	n*)
1613148c0e4Sperry		;;
1623148c0e4Sperry	*)
163945e8578Sperry		for if in `ifconfig -l`
164945e8578Sperry		do
165945e8578Sperry			config_int $if
1663148c0e4Sperry		done
1673148c0e4Sperry		;;
1683148c0e4Sperry	esac
1693148c0e4Sperry
1703148c0e4Sperry
1713148c0e4Sperry	echo	""
1723148c0e4Sperry	echo -n	"Making device nodes (may take a while)..."
1733148c0e4Sperry	cd ${DEV}
1743148c0e4Sperry	sh MAKEDEV all
1753148c0e4Sperry	echo	" done."
1763148c0e4Sperry
1773148c0e4Sperry	sync
1783148c0e4Sperry
179945e8578Sperry	if [ ! -f ${ROOT}/netbsd ]
180945e8578Sperry	then
181945e8578Sperry		echo "You have not unpacked the kernel installation"
182945e8578Sperry		echo "set. You must do so before you reboot."
183945e8578Sperry	fi
1843148c0e4Sperry}
1853148c0e4Sperry
1863148c0e4Sperry# Upgrade cleanup utilities (functions), to make sure a recently-upgraded
1873148c0e4Sperry# system is safely runnable.  These are meant to be invoked from the shell
1883148c0e4Sperry# prompt, by people installing NetBSD.
1893148c0e4Sperry
1903148c0e4SperryCleanup()
1913148c0e4Sperry{
1923148c0e4Sperry	upgrade_dir=/
1933148c0e4Sperry
1943148c0e4Sperry	if [ ! -f /etc/fstab ]; then
1953148c0e4Sperry		upgrade_dir=/mnt
1963148c0e4Sperry	fi
1973148c0e4Sperry
1983148c0e4Sperry	echo	"Cleaning up miscellaneous files in /etc..."
1993148c0e4Sperry	mv $upgrade_dir/etc/rc.bak $upgrade_dir/etc/rc
2003148c0e4Sperry	chroot $upgrade_dir /usr/sbin/pwd_mkdb -p /etc/master.passwd
2013148c0e4Sperry	chroot $upgrade_dir /bin/rm /etc/sendmail.fc > /dev/null 2>&1
2023148c0e4Sperry	sync
2033148c0e4Sperry	echo	"Done."
2043148c0e4Sperry
2053148c0e4Sperry	echo	""
2063148c0e4Sperry	echo	"All that's left to do now is to install a new NetBSD kernel"
2073148c0e4Sperry	echo	"on your hard disk.  You should now halt your machine using"
2083148c0e4Sperry	echo	"the 'halt' command.  Once the machine is halted, replace the"
2093148c0e4Sperry	echo	"installation floppy with the kernel-copy floppy and hit any"
2103148c0e4Sperry	echo	"key to reboot.  Use the kernel-copy floppy to copy a kernel"
2113148c0e4Sperry	echo	"to your hard disk."
2123148c0e4Sperry}
213