1219820Sjeff#!/bin/sh 2219820Sjeff# $NetBSD: install.sh,v 1.5 2022/12/30 09:08:47 andvar Exp $ 3219820Sjeff# 4219820Sjeff# Copyright (c) 1996 The NetBSD Foundation, Inc. 5219820Sjeff# All rights reserved. 6219820Sjeff# 7219820Sjeff# This code is derived from software contributed to The NetBSD Foundation 8219820Sjeff# by Jason R. Thorpe. 9219820Sjeff# 10219820Sjeff# Redistribution and use in source and binary forms, with or without 11219820Sjeff# modification, are permitted provided that the following conditions 12219820Sjeff# are met: 13219820Sjeff# 1. Redistributions of source code must retain the above copyright 14219820Sjeff# notice, this list of conditions and the following disclaimer. 15219820Sjeff# 2. Redistributions in binary form must reproduce the above copyright 16219820Sjeff# notice, this list of conditions and the following disclaimer in the 17219820Sjeff# documentation and/or other materials provided with the distribution. 18219820Sjeff# 19219820Sjeff# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20219820Sjeff# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21219820Sjeff# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22219820Sjeff# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23219820Sjeff# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24219820Sjeff# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25219820Sjeff# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26219820Sjeff# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27219820Sjeff# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28219820Sjeff# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29219820Sjeff# POSSIBILITY OF SUCH DAMAGE. 30219820Sjeff# 31219820Sjeff 32219820Sjeff# NetBSD installation script. 33219820Sjeff# In a perfect world, this would be a nice C program, with a reasonable 34219820Sjeff# user interface. 35219820Sjeff 36219820SjeffFILESYSTEMS="/tmp/filesystems" # used throughout 37219820SjeffMODE="install" 38219820Sjeff 39219820Sjeff# include machine-dependent functions 40219820Sjeff# The following functions must be provided: 41219820Sjeff# md_prep_disklabel() - label the root disk 42219820Sjeff# md_welcome_banner() - display friendly message 43219820Sjeff# md_congrats() - display friendly message 44219820Sjeff# md_makerootwritable() - make root writable (at least /tmp) 45219820Sjeff 46219820Sjeff# we need to make sure .'s below work if this directory is not in $PATH 47219820Sjeffcase $0 in 48219820Sjeff*/*) Mydir=${0%/*};; 49219820Sjeff*) Mydir=.;; 50219820Sjeffesac 51219820SjeffMydir=$(cd "${Mydir}" && pwd) 52219820Sjeff 53219820Sjeff# 54219820Sjeff# Sub-parts 55219820Sjeff# 56219820Sjeffgetresp() { 57219820Sjeff read resp 58219820Sjeff if [ -z "$resp" ]; then 59219820Sjeff resp=$1 60219820Sjeff fi 61219820Sjeff} 62219820Sjeff 63219820Sjeffisin() { 64219820Sjeff# test the first argument against the remaining ones, return success on a match 65219820Sjeff local a=$1 66219820Sjeff shift 67219820Sjeff while [ $# != 0 ]; do 68219820Sjeff if [ "$a" = "$1" ]; then return 0; fi 69219820Sjeff shift 70219820Sjeff done 71219820Sjeff return 1 72219820Sjeff} 73219820Sjeff 74219820Sjeffgetrootdisk() { 75219820Sjeff cat << \__getrootdisk_1 76219820Sjeff 77219820SjeffThe installation program needs to know which disk to consider 78219820Sjeffthe root disk. Note the unit number may be different than 79219820Sjeffthe unit number you used in the standalone installation 80219820Sjeffprogram. 81219820Sjeff 82219820SjeffAvailable disks are: 83219820Sjeff 84219820Sjeff__getrootdisk_1 85219820Sjeff _DKDEVS=`md_get_diskdevs` 86219820Sjeff echo "$_DKDEVS" 87219820Sjeff echo "" 88219820Sjeff echo -n "Which disk is the root disk? " 89219820Sjeff getresp "" 90219820Sjeff if isin $resp $_DKDEVS ; then 91219820Sjeff ROOTDISK="$resp" 92219820Sjeff else 93219820Sjeff echo "" 94219820Sjeff echo "The disk $resp does not exist." 95219820Sjeff ROOTDISK="" 96219820Sjeff fi 97219820Sjeff} 98219820Sjeff 99219820Sjefflabelmoredisks() { 100219820Sjeff cat << \__labelmoredisks_1 101219820Sjeff 102219820SjeffYou may label the following disks: 103219820Sjeff 104219820Sjeff__labelmoredisks_1 105219820Sjeff echo "$_DKDEVS" 106219820Sjeff echo "" 107219820Sjeff echo -n "Label which disk? [done] " 108219820Sjeff getresp "done" 109219820Sjeff case "$resp" in 110219820Sjeff "done") 111219820Sjeff ;; 112219820Sjeff 113219820Sjeff *) 114219820Sjeff if isin $resp $_DKDEVS ; then 115219820Sjeff md_labeldisk $resp 116219820Sjeff else 117219820Sjeff echo "" 118219820Sjeff echo "The disk $resp does not exist." 119219820Sjeff fi 120219820Sjeff ;; 121219820Sjeff esac 122219820Sjeff} 123219820Sjeff 124219820Sjeff# 125219820Sjeff# include machine dependent subroutines 126219820Sjeff. $Mydir/install.md 127219820Sjeff 128219820Sjeff# Good {morning,afternoon,evening,night}. 129219820Sjeffmd_welcome_banner 130219820Sjeffecho -n "Proceed? [n] " 131219820Sjeffgetresp "n" 132219820Sjeffcase "$resp" in 133219820Sjeff y*|Y*) 134219820Sjeff echo "Cool! Let's get to it..." 135219820Sjeff ;; 136219820Sjeff *) 137219820Sjeff md_not_going_to_install 138219820Sjeff exit 139219820Sjeff ;; 140219820Sjeffesac 141219820Sjeff 142219820Sjeff# XXX Work around vnode aliasing bug (thanks for the tip, Chris...) 143219820Sjeffls -l /dev > /dev/null 2>&1 144219820Sjeff 145219820Sjeff# Deal with terminal issues 146219820Sjeffmd_set_term 147219820Sjeff 148219820Sjeff# Make sure we can write files (at least in /tmp) 149219820Sjeff# This might make an MFS mount on /tmp, or it may 150219820Sjeff# just re-mount the root with read-write enabled. 151219820Sjeffmd_makerootwritable 152219820Sjeff 153219820Sjeffwhile [ "X${ROOTDISK}" = "X" ]; do 154219820Sjeff getrootdisk 155219820Sjeffdone 156219820Sjeff 157219820Sjeff# Deal with disklabels, including editing the root disklabel 158219820Sjeff# and labeling additional disks. This is machine-dependent since 159219820Sjeff# some platforms may not be able to provide this functionality. 160219820Sjeffmd_prep_disklabel ${ROOTDISK} 161219820Sjeff 162219820Sjeff# Pat on the back. 163219820Sjeffmd_congrats 164219820Sjeff 165219820Sjeff# ALL DONE! 166219820Sjeffexit 0 167219820Sjeff