11.1Smartin#! /bin/sh -m 21.3Sabs# $NetBSD: install.sh,v 1.3 2023/02/12 19:27:20 abs Exp $ 31.1Smartin# 41.1Smartin# - 51.1Smartin# Copyright (c) 2010 The NetBSD Foundation, Inc. 61.1Smartin# All rights reserved. 71.1Smartin# 81.1Smartin# This code is derived from software contributed to The NetBSD Foundation 91.1Smartin# by Martin Husemann <martin@NetBSD.org>. 101.1Smartin# 111.1Smartin# Redistribution and use in source and binary forms, with or without 121.1Smartin# modification, are permitted provided that the following conditions 131.1Smartin# are met: 141.1Smartin# 1. Redistributions of source code must retain the above copyright 151.1Smartin# notice, this list of conditions and the following disclaimer. 161.1Smartin# 2. Redistributions in binary form must reproduce the above copyright 171.1Smartin# notice, this list of conditions and the following disclaimer in the 181.1Smartin# documentation and/or other materials provided with the distribution. 191.1Smartin# 201.1Smartin# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 211.1Smartin# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 221.1Smartin# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 231.1Smartin# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 241.1Smartin# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 251.1Smartin# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 261.1Smartin# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 271.1Smartin# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 281.1Smartin# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 291.1Smartin# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 301.1Smartin# POSSIBILITY OF SUCH DAMAGE. 311.1Smartin 321.1Smartin 331.1Smartin# setup basic environment 341.1SmartinPATH=/sbin:/bin:/usr/bin:/usr/sbin:/ 351.1Smartinexport PATH 361.1Smartin 371.1Smartintermfile=/tmp/sysinst.term 381.1Smartin 391.1Smartin# Check if we are on a framebuffer or on serial console and default 401.1Smartin# the terminal type accordingly. 411.1Smartin# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly; 421.1Smartin# ttyE0 is 68,0 -> 0x4400 431.1Smartincase $(sysctl -nx kern.consdev) in 441.1Smartin 440*000000000000) 451.1Smartin TERM=wsvt25 461.1Smartin ;; 471.1Smartin *) 481.1Smartin if [ -r ${termfile} ]; then 491.1Smartin . ${termfile} 501.1Smartin else 511.1Smartin TERM=vt220 521.1Smartin fi 531.1Smartin ;; 541.1Smartinesac 551.1Smartin 561.1Smartinexport TERM 571.1SmartinHOME=/ 581.1Smartinexport HOME 591.1SmartinBLOCKSIZE=1k 601.1Smartinexport BLOCKSIZE 611.1SmartinEDITOR=ed 621.1Smartinexport EDITOR 631.1SmartinSHELL=/bin/sh 641.1Smartinexport SHELL 651.1Smartin 661.1Smartinumask 022 671.1Smartin 681.1Smartinstty newcrt werase ^W intr ^C kill ^U erase ^? 691.1Smartinif [ $TERM != "wsvt25" ]; then 701.1Smartin cat << "EOM" 711.1Smartin 721.1Smartin 731.1SmartinYou are using a serial console, we do not know your terminal emulation. 741.1SmartinPlease select one, typical values are: 751.1Smartin 761.1Smartin vt100 771.1Smartin ansi 781.1Smartin xterm 791.1Smartin 801.1SmartinEOM 811.1Smartin echo -n "Terminal type (just hit ENTER for '$TERM'): " 821.1Smartin read ans 831.1Smartin if [ -n "$ans" ];then 841.1Smartin TERM=$ans 851.1Smartin fi 861.1Smartinfi 871.1Smartin 881.1Smartin# run the installation or upgrade script. 891.1Smartincd / 901.2Smartincmd=/usr/sbin/sysinst 911.1Smartin 921.1Smartinwhile [ -n "${cmd}" ] 931.1Smartindo 941.1Smartin ${cmd} 951.1Smartin if [ $? = 4 ]; then 961.1Smartin echo "Oops, something went wrong - we will try again" 971.1Smartin exit 981.1Smartin else 991.1Smartin if [ -n "$(jobs)" ]; then 1001.1Smartin tput clear 1011.1Smartin echo "You have stopped sysinst, return to it by" \ 1021.1Smartin "typing 'exit' or ^D." 1031.3Sabs ${SHELL} -i -E 1041.1Smartin cmd="fg" 1051.1Smartin else 1061.1Smartin cmd="" 1071.1Smartin fi 1081.1Smartin fi 1091.1Smartindone 1101.1Smartin 1111.1Smartin# remember terminal type, now that we know it for sure 1121.1Smartinecho "TERM=${TERM}" > ${termfile} 1131.1Smartinecho 1141.1Smartinecho "To return to the installer, quit this shell by typing 'exit' or ^D." 1151.3Sabsexec ${SHELL} -E 116