Home | History | Annotate | Line # | Download | only in installimage
install.sh revision 1.1.6.1
      1      1.1  jmcneill #! /bin/sh -m
      2  1.1.6.1    martin # $NetBSD: install.sh,v 1.1.6.1 2023/02/24 13:48:28 martin Exp $
      3      1.1  jmcneill #
      4      1.1  jmcneill # -
      5      1.1  jmcneill #  Copyright (c) 2010 The NetBSD Foundation, Inc.
      6      1.1  jmcneill #  All rights reserved.
      7      1.1  jmcneill # 
      8      1.1  jmcneill #  This code is derived from software contributed to The NetBSD Foundation
      9      1.1  jmcneill #  by Martin Husemann <martin (at] NetBSD.org>.
     10      1.1  jmcneill # 
     11      1.1  jmcneill #  Redistribution and use in source and binary forms, with or without
     12      1.1  jmcneill #  modification, are permitted provided that the following conditions
     13      1.1  jmcneill #  are met:
     14      1.1  jmcneill #  1. Redistributions of source code must retain the above copyright
     15      1.1  jmcneill #     notice, this list of conditions and the following disclaimer.
     16      1.1  jmcneill #  2. Redistributions in binary form must reproduce the above copyright
     17      1.1  jmcneill #     notice, this list of conditions and the following disclaimer in the
     18      1.1  jmcneill #     documentation and/or other materials provided with the distribution.
     19      1.1  jmcneill # 
     20      1.1  jmcneill #  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21      1.1  jmcneill #  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22      1.1  jmcneill #  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23      1.1  jmcneill #  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24      1.1  jmcneill #  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25      1.1  jmcneill #  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26      1.1  jmcneill #  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27      1.1  jmcneill #  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28      1.1  jmcneill #  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29      1.1  jmcneill #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30      1.1  jmcneill #  POSSIBILITY OF SUCH DAMAGE.
     31      1.1  jmcneill 
     32      1.1  jmcneill 
     33      1.1  jmcneill # setup basic environment
     34      1.1  jmcneill PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
     35      1.1  jmcneill export PATH
     36      1.1  jmcneill 
     37      1.1  jmcneill termfile=/tmp/sysinst.term
     38      1.1  jmcneill 
     39      1.1  jmcneill # Check if we are on a framebuffer or on serial console and default
     40      1.1  jmcneill # the terminal type accordingly.
     41      1.1  jmcneill # There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
     42      1.1  jmcneill # ttyE0 is 60,0 -> 0x3c00
     43      1.1  jmcneill case $(sysctl -nx kern.consdev) in
     44      1.1  jmcneill  003c000000000000)
     45      1.1  jmcneill     TERM=wsvt25
     46      1.1  jmcneill     ;;
     47      1.1  jmcneill  *)
     48      1.1  jmcneill     if [ -r ${termfile} ]; then
     49      1.1  jmcneill 	. ${termfile}
     50      1.1  jmcneill     else
     51      1.1  jmcneill 	TERM=vt220
     52      1.1  jmcneill     fi
     53      1.1  jmcneill     ;;
     54      1.1  jmcneill esac
     55      1.1  jmcneill 
     56      1.1  jmcneill export TERM
     57      1.1  jmcneill HOME=/
     58      1.1  jmcneill export HOME
     59      1.1  jmcneill BLOCKSIZE=1k
     60      1.1  jmcneill export BLOCKSIZE
     61      1.1  jmcneill EDITOR=ed
     62      1.1  jmcneill export EDITOR
     63      1.1  jmcneill SHELL=/bin/sh
     64      1.1  jmcneill export SHELL
     65      1.1  jmcneill 
     66      1.1  jmcneill umask 022
     67      1.1  jmcneill 
     68      1.1  jmcneill stty newcrt werase ^W intr ^C kill ^U erase ^?
     69      1.1  jmcneill if [ $TERM != "wsvt25" ]; then
     70      1.1  jmcneill 	cat << "EOM"
     71      1.1  jmcneill 
     72      1.1  jmcneill 
     73      1.1  jmcneill You are using a serial console, we do not know your terminal emulation.
     74      1.1  jmcneill Please select one, typical values are:
     75      1.1  jmcneill 
     76      1.1  jmcneill 	vt100
     77      1.1  jmcneill 	ansi
     78      1.1  jmcneill 	xterm
     79      1.1  jmcneill 
     80      1.1  jmcneill EOM
     81      1.1  jmcneill 	echo -n "Terminal type (just hit ENTER for '$TERM'): "
     82      1.1  jmcneill 	read ans
     83      1.1  jmcneill 	if [ -n "$ans" ];then
     84      1.1  jmcneill 	    TERM=$ans
     85      1.1  jmcneill 	fi
     86      1.1  jmcneill fi
     87      1.1  jmcneill 
     88      1.1  jmcneill # run the installation or upgrade script.
     89      1.1  jmcneill cd /
     90  1.1.6.1    martin cmd=/usr/sbin/sysinst
     91      1.1  jmcneill 
     92      1.1  jmcneill while [ -n "${cmd}" ]
     93      1.1  jmcneill do
     94      1.1  jmcneill 	${cmd}
     95      1.1  jmcneill 	if [ $? = 4 ]; then
     96      1.1  jmcneill 		echo "Oops, something went wrong - we will try again"
     97      1.1  jmcneill 		exit
     98      1.1  jmcneill 	else
     99      1.1  jmcneill 		if [ -n "$(jobs)" ]; then
    100      1.1  jmcneill 			tput clear
    101      1.1  jmcneill 			echo "You have stopped sysinst, return to it by" \
    102      1.1  jmcneill 				"typing 'exit' or ^D."
    103  1.1.6.1    martin 			${SHELL} -i -E
    104      1.1  jmcneill 			cmd="fg"
    105      1.1  jmcneill 		else
    106      1.1  jmcneill 			cmd=""
    107      1.1  jmcneill 		fi
    108      1.1  jmcneill 	fi
    109      1.1  jmcneill done
    110      1.1  jmcneill 
    111      1.1  jmcneill # remember terminal type, now that we know it for sure
    112      1.1  jmcneill echo "TERM=${TERM}" > ${termfile}
    113      1.1  jmcneill echo
    114      1.1  jmcneill echo "To return to the installer, quit this shell by typing 'exit' or ^D."
    115  1.1.6.1    martin exec ${SHELL} -E
    116