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