dot.instutils revision 1.6
1# $NetBSD: dot.instutils,v 1.6 2000/06/14 06:48:57 cgd 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# Installation configuration utilities (functions), to get NetBSD configured 32# reasonably once it is installed on the hard disk. These are meant to be 33# invoked from the shell prompt, by people installing NetBSD. 34 35config_int() 36{ 37 local intf resp ifname ifaddr ifflags 38 intf=$1 39 case "$intf" in 40 ""|lo*|ppp*|sl*|tun*) 41 return 0; 42 ;; 43 *) 44 ;; 45 esac 46 47 echo -n "Configure" $intf "? [y]" 48 read resp 49 case "$resp" in 50 n*|N*) 51 return 0; 52 ;; 53 *) 54 ;; 55 esac 56 57 echo -n "What is the hostname for this interface? [$hname] " 58 read ifname 59 if [ "$ifname" = "" ]; then 60 ifname=$hname 61 fi 62 ifaddr= 63 while [ "$ifaddr" = "" ]; do 64 echo -n "What is the IP address associated with " 65 echo -n "interface ${intf}? " 66 read ifaddr 67 done 68 echo "$ifaddr $ifname `echo $ifname | sed -e s/\.$dname//`" \ 69 >> ${ETC}/hosts 70 71 echo -n "Does this interface have a special netmask? [n] " 72 read resp 73 case "$resp" in 74 y*) 75 echo -n "What is the netmask? [0xffffff00] " 76 read ifnetmask 77 if [ "$ifnetmask" = "" ]; then 78 ifnetmask=0xffffff00 79 fi 80 ifnetmask_arg="netmask $ifnetmask" 81 ;; 82 *) 83 ifnetmask= 84 ifnetmask_arg= 85 ;; 86 esac 87 88 echo -n "Does this interface need a special media type? [n] " 89 read resp 90 case "$resp" in 91 y*) 92 echo -n "What media type? [10baseT/UTP] " 93 read ifflags 94 if [ "$ifflags" = "" ]; then 95 ifflags="10baseT/UTP" 96 fi 97 ifflags_arg="media $ifflags" 98 ;; 99 *) 100 ifflags= 101 ifflags_arg= 102 ;; 103 esac 104 echo "inet $ifname $ifnetmask_arg $ifflags_arg" > ${ETC}/ifconfig.$intf 105} 106 107 108Configure() 109{ 110 DEV=/dev 111 ETC=/etc 112 ROOT=/ 113 if [ ! -f /etc/fstab ]; then 114 DEV=/mnt/dev 115 ETC=/mnt/etc 116 ROOT=/mnt 117 fi 118 119 echo "You will now be prompted for information about this" 120 echo "machine. If you hit return, the default answer (in" 121 echo "brackets) will be used." 122 123 echo "" 124 echo -n "What is this machine's hostname? [unknown.host.domain] " 125 read hname 126 if [ "$hname" = "" ]; then 127 hname=unknown.host.domain 128 fi 129 echo $hname > ${ETC}/myname 130 proto_domain=`echo $hname | sed -e 's/[^.]*\.//'` 131 132 echo "" 133 echo "What DNS domain is this machine in (this is NOT its YP" 134 echo -n "domain name)? [$proto_domain] " 135 read dname 136 if [ "$dname" = "" ]; then 137 dname=$proto_domain 138 fi 139 140 echo "" 141 if [ -e $ETC/sendmail.cf ]; then 142 echo "WARNING: A default sendmail.cf exists, and probably" 143 echo "needs to be tuned and/or replaced, to work properly at" 144 echo "your site!" 145 else 146 echo "WARNING: No default sendmail.cf installed. Did you" 147 echo "forget to install the 'etc' distribution?" 148 fi 149 150 echo "127.0.0.1 localhost localhost.$dname" > ${ETC}/hosts 151 152 echo "" 153 echo -n "Configure network interfaces? [y] " 154 read resp 155 case "$resp" in 156 n*) 157 ;; 158 *) 159 for if in `ifconfig -l` 160 do 161 config_int $if 162 done 163 ;; 164 esac 165 166 167 echo "" 168 echo -n "Making device nodes (may take a while)..." 169 cd ${DEV} 170 sh MAKEDEV all 171 echo " done." 172 173 sync 174 175 if [ ! -f ${ROOT}/netbsd ] 176 then 177 echo "You have not unpacked the kernel installation" 178 echo "set. You must do so before you reboot." 179 fi 180} 181 182# Upgrade cleanup utilities (functions), to make sure a recently-upgraded 183# system is safely runnable. These are meant to be invoked from the shell 184# prompt, by people installing NetBSD. 185 186Cleanup() 187{ 188 upgrade_dir=/ 189 190 if [ ! -f /etc/fstab ]; then 191 upgrade_dir=/mnt 192 fi 193 194 echo "Cleaning up miscellaneous files in /etc..." 195 mv $upgrade_dir/etc/rc.bak $upgrade_dir/etc/rc 196 chroot $upgrade_dir /usr/sbin/pwd_mkdb -p /etc/master.passwd 197 chroot $upgrade_dir /bin/rm /etc/sendmail.fc > /dev/null 2>&1 198 sync 199 echo "Done." 200 201 echo "" 202 echo "All that's left to do now is to install a new NetBSD kernel" 203 echo "on your hard disk. You should now halt your machine using" 204 echo "the 'halt' command. Once the machine is halted, replace the" 205 echo "installation floppy with the kernel-copy floppy and hit any" 206 echo "key to reboot. Use the kernel-copy floppy to copy a kernel" 207 echo "to your hard disk." 208} 209