dot.instutils revision 1.2
1#	$NetBSD: dot.instutils,v 1.2 1997/08/04 22:33:58 phil Exp $
2#
3# Copyright (c) 1994 Christopher G. Demetriou
4# All rights reserved.
5# 
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14# 3. All advertising materials mentioning features or use of this software
15#    must display the following acknowledgement:
16#	This product includes software developed by Christopher G. Demetriou.
17# 4. The name of the author may not be used to endorse or promote products
18#    derived from this software without specific prior written permission
19#
20# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30#
31
32# Installation configuration utilities (functions), to get NetBSD configured
33# reasonably once it is installed on the hard disk.  These are meant to be
34# invoked from the shell prompt, by people installing NetBSD.
35
36Configure()
37{
38	DEV=/dev
39	ETC=/etc
40	if [ ! -f /etc/fstab ]; then
41		DEV=/mnt/dev
42		ETC=/mnt/etc
43	fi
44
45	echo	"You will now be prompted for information about this"
46	echo	"machine.  If you hit return, the default answer (in"
47	echo	"brackets) will be used."
48
49	echo	""
50	echo -n	"What is this machine's hostname? [unknown.host.domain] "
51	read hname
52	if [ "$hname" = "" ]; then
53		hname=unknown.host.domain
54	fi
55	echo $hname > ${ETC}/myname
56	proto_domain=`echo $hname | sed -e 's/[^.]*\.//'`
57
58	echo	""
59	echo	"What domain is this machine in (this is NOT its YP"
60	echo -n	"domain name)? [$proto_domain] "
61	read dname
62	if [ "$dname" = "" ]; then
63		dname=$proto_domain
64	fi
65
66	echo	""
67	if [ -e $ETC/sendmail.cf ]; then
68		echo	"WARNING: A default sendmail.cf exists, and probably"
69		echo	"needs to be tuned and/or replaced, to work properly at"
70		echo	"your site!"
71	else
72		echo	"WARNING: No default sendmail.cf installed.  Did you"
73		echo	"forget to install the 'etc' distribution?"
74	fi
75
76	echo	"127.0.0.1	localhost localhost.$dname" > ${ETC}/hosts
77
78	echo	""
79	echo -n	"Does this machine have an ethernet interface? [y] "
80        read resp
81        case "$resp" in
82	n*)
83		;;
84	*)
85		intf=
86		while [ "$intf" = "" ]; do
87			echo -n "What is the primary interface name "
88			echo -n "(e.g. ed0, ep0, etc)? "
89			read intf
90		done
91		echo -n "What is the hostname for this interface? [$hname] "
92		read ifname
93		if [ "$ifname" = "" ]; then
94 			ifname=$hname
95		fi
96		ifaddr=
97		while [ "$ifaddr" = "" ]; do
98			echo -n "What is the IP address associated with "
99			echo -n "interface ${intf}? "
100			read ifaddr
101		done
102		echo "$ifaddr	$ifname `echo $ifname | sed -e s/\.$dname//`" \
103		    >> ${ETC}/hosts
104
105		echo -n "Does this interface have a special netmask? [n] "
106		read resp
107		case "$resp" in
108			y*)
109				echo -n "What is the netmask? [0xffffff00] "
110				read ifnetmask
111				if [ "$ifnetmask" = "" ]; then
112					ifnetmask=0xffffff00
113				fi
114				;;
115			*)
116				ifnetmask=
117				;;
118		esac
119
120		echo -n "Does this interface need additional flags? [n] "
121		read resp
122		case "$resp" in
123			y*)
124				echo -n "What flags? [link0] "
125				read ifflags
126				if [ "$ifflags" = "" ]; then
127					ifflags=link0
128				fi
129				;;
130			*)
131				ifflags=
132				;;
133		esac
134		echo "inet $ifname $ifnetmask $ifflags" > ${ETC}/ifconfig.$intf
135
136		echo    ""
137		echo -n	"WARNING: if you have any more ethernet interfaces, "
138		echo	"you will have to configure"
139		echo -n "them by hand.  Read the comments in /etc/netstart to "
140		echo	"learn how to do this."
141		;;
142	esac
143	
144	echo	""
145	echo -n	"Making device nodes (may take a while)..."
146	cd ${DEV}
147	sh MAKEDEV all
148	echo	" done."
149
150	sync
151
152	echo	""
153	echo	"If you haven't already installed a kernel on the hard drive"
154	echo	"using your kernel-copy floppy, do so now.  Kernel"
155	echo 	"installation instructions can be found in the"
156	echo 	"installation notes."	
157}
158
159# Upgrade cleanup utilities (functions), to make sure a recently-upgraded
160# system is safely runnable.  These are meant to be invoked from the shell
161# prompt, by people installing NetBSD.
162
163Cleanup()
164{
165	upgrade_dir=/
166
167	if [ ! -f /etc/fstab ]; then
168		upgrade_dir=/mnt
169	fi
170
171	echo	"Cleaning up miscellaneous files in /etc..."
172	mv $upgrade_dir/etc/rc.bak $upgrade_dir/etc/rc
173	chroot $upgrade_dir /usr/sbin/pwd_mkdb -p /etc/master.passwd
174	chroot $upgrade_dir /bin/rm /etc/sendmail.fc > /dev/null 2>&1
175	sync
176	echo	"Done."
177
178	echo	""
179	echo	"All that's left to do now is to install a new NetBSD kernel"
180	echo	"on your hard disk.  You should now halt your machine using"
181	echo	"the 'halt' command.  Once the machine is halted, replace the"
182	echo	"installation floppy with the kernel-copy floppy and hit any"
183	echo	"key to reboot.  Use the kernel-copy floppy to copy a kernel"
184	echo	"to your hard disk."
185}
186