1# $NetBSD: install.md,v 1.1 2002/05/17 17:52:35 lukem Exp $ 2# 3# 4# Copyright (c) 1996 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Jason R. Thorpe. 9# 10# Redistribution and use in source and binary forms, with or without 11# modification, are permitted provided that the following conditions 12# are met: 13# 1. Redistributions of source code must retain the above copyright 14# notice, this list of conditions and the following disclaimer. 15# 2. Redistributions in binary form must reproduce the above copyright 16# notice, this list of conditions and the following disclaimer in the 17# documentation and/or other materials provided with the distribution. 18# 3. All advertising materials mentioning features or use of this software 19# must display the following acknowledgement: 20# This product includes software developed by the NetBSD 21# Foundation, Inc. and its contributors. 22# 4. Neither the name of The NetBSD Foundation nor the names of its 23# contributors may be used to endorse or promote products derived 24# from this software without specific prior written permission. 25# 26# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36# POSSIBILITY OF SUCH DAMAGE. 37# 38 39# 40# machine dependent section of installation/upgrade script. 41# 42 43# Machine-dependent install sets 44# MDSETS="xbin xman xinc xcon" XXX 45MDSETS="" 46 47md_set_term() { 48 if [ ! -z "$TERM" ]; then 49 return 50 fi 51 echo -n "Specify terminal type [sun]: " 52 getresp "sun" 53 TERM="$resp" 54 export TERM 55} 56 57__mount_kernfs() { 58 # Make sure kernfs is mounted. 59 if [ ! -d /kern -o ! -e /kern/msgbuf ]; then 60 mkdir /kern > /dev/null 2>&1 61 /sbin/mount_kernfs /kern /kern 62 fi 63} 64 65md_makerootwritable() { 66 # Just remount the root device read-write. 67 if [ ! -e /tmp/root_writable ]; then 68 echo "Remounting root read-write..." 69 __mount_kernfs 70 mount -u /kern/rootdev / 71 swapctl -a /kern/rootdev 72 cp /dev/null /tmp/root_writable 73 fi 74} 75 76md_get_diskdevs() { 77 # return available disk devices 78 __mount_kernfs 79 sed -n -e '/^sd[0-9] /s/ .*//p' \ 80 -e '/^xd[0-9] /s/ .*//p' \ 81 -e '/^xy[0-9] /s/ .*//p' \ 82 < /kern/msgbuf | sort -u 83} 84 85md_get_cddevs() { 86 # return available CDROM devices 87 __mount_kernfs 88 sed -n -e '/^cd[0-9] /s/ .*//p' \ 89 < /kern/msgbuf | sort -u 90} 91 92md_get_ifdevs() { 93 # return available network devices 94 __mount_kernfs 95 sed -n -e '/^ie[0-9] /s/ .*//p' \ 96 -e '/^le[0-9] /s/ .*//p' \ 97 < /kern/msgbuf | sort -u 98} 99 100md_get_partition_range() { 101 # return an expression describing the valid partition id's 102 echo '[a-h]' 103} 104 105md_installboot() { 106 # install the boot block on disk $1 107 echo "Installing boot block..." 108 ( cd /usr/mdec ;\ 109 cp -p ./ufsboot /mnt/ufsboot ;\ 110 sync ; sleep 1 ; sync ;\ 111 /usr/sbin/installboot -v /dev/r${1}a bootxx ufsboot ) 112 echo "done." 113} 114 115md_native_fstype() { 116} 117 118md_native_fsopts() { 119} 120 121md_prep_disklabel() { 122 # $1 is the root disk 123 echo -n "Do you wish to edit the disklabel on ${1}? [y]" 124 getresp "y" 125 case "$resp" in 126 y*|Y*) ;; 127 *) return ;; 128 esac 129 130 # display example 131 cat << \__md_prep_disklabel_1 132Here is an example of what the partition information will look like once 133you have entered the disklabel editor. Disk partition sizes and offsets 134are in sector (most likely 512 bytes) units. Make sure all partitions 135start on a cylinder boundary (c/t/s == XXX/0/0). 136 137[Example] 138partition start (c/t/s) nblks (c/t/s) type 139 140 a (root) 0 (0/00/00) 31392 (109/00/00) 4.2BSD 141 b (swap) 31392 (109/00/00) 73440 (255/00/00) swap 142 c (disk) 0 (0/00/00) 1070496 (3717/00/00) unused 143 d (user) 104832 (364/00/00) 30528 (106/00/00) 4.2BSD 144 e (user) 135360 (470/00/00) 40896 (142/00/00) 4.2BSD 145 f (user) 176256 (612/00/00) 92160 (320/00/00) 4.2BSD 146 g (user) 268416 (932/00/00) 802080 (2785/00/00) 4.2BSD 147 148[End of example] 149 150Hit the <return> key when you have read this... 151 152__md_prep_disklabel_1 153 getresp "" 154 edlabel /dev/r${1}c 155} 156 157md_copy_kernel() { 158 set -- `sysctl -n hw.model` 159 echo -n "Copying $1 kernel..." 160 cp -p /netbsd.$1 /mnt/netbsd 161 echo "done." 162} 163 164md_welcome_banner() { 165 if [ "$MODE" = "install" ]; then 166 echo "" 167 echo "Welcome to the NetBSD/sun3 ${VERSION} installation program." 168 cat << \__welcome_banner_1 169 170This program is designed to help you put NetBSD on your disk, 171in a simple and rational way. You'll be asked several questions, 172and it would probably be useful to have your disk's hardware 173manual, the installation notes, and a calculator handy. 174__welcome_banner_1 175 176 else 177 echo "" 178 echo "Welcome to the NetBSD/sun3 ${VERSION} upgrade program." 179 cat << \__welcome_banner_2 180 181This program is designed to help you upgrade your NetBSD system in a 182simple and rational way. 183 184As a reminder, installing the `etc' binary set is NOT recommended. 185Once the rest of your system has been upgraded, you should manually 186merge any changes to files in the `etc' set into those files which 187already exist on your system. 188__welcome_banner_2 189 fi 190 191cat << \__welcome_banner_3 192 193As with anything which modifies your disk's contents, this 194program can cause SIGNIFICANT data loss, and you are advised 195to make sure your data is backed up before beginning the 196installation process. 197 198Default answers are displayed in brackets after the questions. 199You can hit Control-C at any time to quit, but if you do so at a 200prompt, you may have to hit return. Also, quitting in the middle of 201installation may leave your system in an inconsistent state. 202 203__welcome_banner_3 204} 205 206md_not_going_to_install() { 207 cat << \__not_going_to_install_1 208 209OK, then. Enter `halt' at the prompt to halt the machine. Once the 210machine has halted, power-cycle the system to load new boot code. 211 212__not_going_to_install_1 213} 214 215md_congrats() { 216 local what; 217 if [ "$MODE" = "install" ]; then 218 what="installed"; 219 else 220 what="upgraded"; 221 fi 222 cat << __congratulations_1 223 224CONGRATULATIONS! You have successfully $what NetBSD! 225To boot the installed system, enter halt at the command prompt. Once the 226system has halted, reset the machine and boot from the disk. 227 228__congratulations_1 229} 230