11.2Smartin#! /bin/sh -m 21.5Sabs# $NetBSD: install.sh,v 1.5 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.2Smartintermfile=/tmp/sysinst.term 381.2Smartin 391.1Smartin# Check if we are on a framebuffer or on serial console and default 401.1Smartin# the terminal type accordingly. 411.3Sjoerg# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly; 421.1Smartin# ttyE0 is 90,0 -> 0x5a00 431.1Smartincase $(sysctl -nx kern.consdev) in 441.1Smartin 0000000000005a0*) 451.2Smartin TERM=wsvt25 461.2Smartin ;; 471.1Smartin *) 481.2Smartin if [ -r ${termfile} ]; then 491.2Smartin . ${termfile} 501.2Smartin else 511.2Smartin TERM=vt220 521.2Smartin fi 531.2Smartin ;; 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.2SmartinSHELL=/bin/sh 641.2Smartinexport 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.2Smartincd / 901.4Smartincmd=/usr/sbin/sysinst 911.2Smartin 921.2Smartinwhile [ -n "${cmd}" ] 931.2Smartindo 941.2Smartin ${cmd} 951.2Smartin if [ $? = 4 ]; then 961.2Smartin echo "Oops, something went wrong - we will try again" 971.2Smartin exit 981.2Smartin else 991.2Smartin if [ -n "$(jobs)" ]; then 1001.2Smartin tput clear 1011.2Smartin echo "You have stopped sysinst, return to it by" \ 1021.2Smartin "typing 'exit' or ^D." 1031.5Sabs ${SHELL} -i -E 1041.2Smartin cmd="fg" 1051.2Smartin else 1061.2Smartin cmd="" 1071.2Smartin fi 1081.2Smartin fi 1091.2Smartindone 1101.1Smartin 1111.2Smartin# remember terminal type, now that we know it for sure 1121.2Smartinecho "TERM=${TERM}" > ${termfile} 1131.2Smartinecho 1141.1Smartinecho "To return to the installer, quit this shell by typing 'exit' or ^D." 1151.5Sabsexec ${SHELL} -E 116