install.sh revision 1.4
1#!/bin/sh 2# $NetBSD: install.sh,v 1.4 2022/05/03 20:52:30 andvar Exp $ 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# 19# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29# POSSIBILITY OF SUCH DAMAGE. 30# 31 32# NetBSD installation script. 33# In a perfect world, this would be a nice C program, with a reasonable 34# user interface. 35 36FILESYSTEMS="/tmp/filesystems" # used throughout 37MODE="install" 38 39# include machine-dependent functions 40# The following functions must be provided: 41# md_prep_disklabel() - label the root disk 42# md_welcome_banner() - display friendly message 43# md_congrats() - display friendly message 44# md_makerootwritable() - make root writable (at least /tmp) 45 46# we need to make sure .'s below work if this directory is not in $PATH 47case $0 in 48*/*) Mydir=${0%/*};; 49*) Mydir=.;; 50esac 51Mydir=$(cd "${Mydir}" && pwd) 52 53# 54# Sub-parts 55# 56getresp() { 57 read resp 58 if [ -z "$resp" ]; then 59 resp=$1 60 fi 61} 62 63isin() { 64# test the first argument against the remaining ones, return succes on a match 65 local a=$1 66 shift 67 while [ $# != 0 ]; do 68 if [ "$a" = "$1" ]; then return 0; fi 69 shift 70 done 71 return 1 72} 73 74getrootdisk() { 75 cat << \__getrootdisk_1 76 77The installation program needs to know which disk to consider 78the root disk. Note the unit number may be different than 79the unit number you used in the standalone installation 80program. 81 82Available disks are: 83 84__getrootdisk_1 85 _DKDEVS=`md_get_diskdevs` 86 echo "$_DKDEVS" 87 echo "" 88 echo -n "Which disk is the root disk? " 89 getresp "" 90 if isin $resp $_DKDEVS ; then 91 ROOTDISK="$resp" 92 else 93 echo "" 94 echo "The disk $resp does not exist." 95 ROOTDISK="" 96 fi 97} 98 99labelmoredisks() { 100 cat << \__labelmoredisks_1 101 102You may label the following disks: 103 104__labelmoredisks_1 105 echo "$_DKDEVS" 106 echo "" 107 echo -n "Label which disk? [done] " 108 getresp "done" 109 case "$resp" in 110 "done") 111 ;; 112 113 *) 114 if isin $resp $_DKDEVS ; then 115 md_labeldisk $resp 116 else 117 echo "" 118 echo "The disk $resp does not exist." 119 fi 120 ;; 121 esac 122} 123 124# 125# include machine dependent subroutines 126. $Mydir/install.md 127 128# Good {morning,afternoon,evening,night}. 129md_welcome_banner 130echo -n "Proceed? [n] " 131getresp "n" 132case "$resp" in 133 y*|Y*) 134 echo "Cool! Let's get to it..." 135 ;; 136 *) 137 md_not_going_to_install 138 exit 139 ;; 140esac 141 142# XXX Work around vnode aliasing bug (thanks for the tip, Chris...) 143ls -l /dev > /dev/null 2>&1 144 145# Deal with terminal issues 146md_set_term 147 148# Make sure we can write files (at least in /tmp) 149# This might make an MFS mount on /tmp, or it may 150# just re-mount the root with read-write enabled. 151md_makerootwritable 152 153while [ "X${ROOTDISK}" = "X" ]; do 154 getrootdisk 155done 156 157# Deal with disklabels, including editing the root disklabel 158# and labeling additional disks. This is machine-dependent since 159# some platforms may not be able to provide this functionality. 160md_prep_disklabel ${ROOTDISK} 161 162# Pat on the back. 163md_congrats 164 165# ALL DONE! 166exit 0 167