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