1*0Sstevel@tonic-gate# 2*0Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 3*0Sstevel@tonic-gate# 4*0Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 5*0Sstevel@tonic-gate# Use is subject to license terms. 6*0Sstevel@tonic-gate# 7*0Sstevel@tonic-gate# CDDL HEADER START 8*0Sstevel@tonic-gate# 9*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 10*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 11*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 12*0Sstevel@tonic-gate# with the License. 13*0Sstevel@tonic-gate# 14*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 15*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 16*0Sstevel@tonic-gate# See the License for the specific language governing permissions 17*0Sstevel@tonic-gate# and limitations under the License. 18*0Sstevel@tonic-gate# 19*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 20*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 21*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 22*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 23*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 24*0Sstevel@tonic-gate# 25*0Sstevel@tonic-gate# CDDL HEADER END 26*0Sstevel@tonic-gate# 27*0Sstevel@tonic-gate# initial properties, set during installation 28*0Sstevel@tonic-gate# NOTICE: bootpath and boot-args should be set by this point. 29*0Sstevel@tonic-gate#================================================================ 30*0Sstevel@tonic-gategetprop bootpath bp 31*0Sstevel@tonic-gategetprop boot-args bootargs 32*0Sstevel@tonic-gateif .streq ( "${bootargs}"X , kernel/unixX ) 33*0Sstevel@tonic-gate set bootargs 34*0Sstevel@tonic-gateendif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gateset ba0 bogus_response 37*0Sstevel@tonic-gateset cmd_err 0 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate# display current defaults 40*0Sstevel@tonic-gateecho " <<< Current Boot Parameters >>> 41*0Sstevel@tonic-gateBoot path: ${bp} 42*0Sstevel@tonic-gateBoot args: ${bootargs}" 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate#comment out following line if auto booting is not desired 45*0Sstevel@tonic-gateset boot_timeout 5 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate# display initial boot prompt 48*0Sstevel@tonic-gateecho ' 49*0Sstevel@tonic-gateType b [file-name] [boot-flags] <ENTER> to boot with options 50*0Sstevel@tonic-gateor i <ENTER> to enter boot interpreter 51*0Sstevel@tonic-gateor <ENTER> to boot with defaults' 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gateif ! .streq ( ${boot_timeout}X , X ) 54*0Sstevel@tonic-gate echo " 55*0Sstevel@tonic-gate <<< timeout in ${boot_timeout} seconds >>>" 56*0Sstevel@tonic-gateendif 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gateecho -n ' 59*0Sstevel@tonic-gateSelect (b)oot or (i)nterpreter: ' 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate# read response to boot prompt 62*0Sstevel@tonic-gateif .streq ( ${boot_timeout}X , X ) 63*0Sstevel@tonic-gate read ba0 ba1 ba2 ba3 ba4 ba5 ba6 ba7 ba8 64*0Sstevel@tonic-gateelse 65*0Sstevel@tonic-gate readt ${boot_timeout} ba0 ba1 ba2 ba3 ba4 ba5 ba6 ba7 ba8 66*0Sstevel@tonic-gateendif 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate# process response to boot prompt 69*0Sstevel@tonic-gate# i command 70*0Sstevel@tonic-gateif .streq ( ${ba0}X , iX ) 71*0Sstevel@tonic-gate echo 'Entering boot interpreter - type ctrl-d to resume boot' 72*0Sstevel@tonic-gate console 73*0Sstevel@tonic-gate if .streq ( ${bootfile}X , X ) # if bootfile not set 74*0Sstevel@tonic-gate set bootfile $def_bootfile # set to default 75*0Sstevel@tonic-gate endif 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate# b command 78*0Sstevel@tonic-gateelseif .streq ( ${ba0}X , bX ) || .streq ( ${ba0}X , bootX ) 79*0Sstevel@tonic-gate if .strneq ( ${ba1}X , \\- , 1 ) # if first arg is a flag 80*0Sstevel@tonic-gate # save it in bootargs 81*0Sstevel@tonic-gate set bootargs "$ba1 $ba2 $ba3 $ba4 $ba5 $ba6 $ba7 $ba8" 82*0Sstevel@tonic-gate set bootfile $def_bootfile # set default boot file 83*0Sstevel@tonic-gate elseif ! .streq ( ${ba1}X , X ) # else if first arg is present 84*0Sstevel@tonic-gate set bootfile $ba1 # set bootfile to it 85*0Sstevel@tonic-gate set bootargs "$ba2 $ba3 $ba4 $ba5 $ba6 $ba7 $ba8" 86*0Sstevel@tonic-gate else # else 87*0Sstevel@tonic-gate set bootfile $def_bootfile # set default boot file 88*0Sstevel@tonic-gate endif 89*0Sstevel@tonic-gate setprop boot-args "$bootargs" 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate# anything else 92*0Sstevel@tonic-gateelse # no command 93*0Sstevel@tonic-gate if ! .streq ( ${ba0}X , X ) 94*0Sstevel@tonic-gate echo "invalid response: \"${ba0}\"" 95*0Sstevel@tonic-gate set cmd_err 1 # user entered invalid response 96*0Sstevel@tonic-gate endif 97*0Sstevel@tonic-gate if .streq ( ${bootfile}X , X ) # if bootfile not set 98*0Sstevel@tonic-gate set bootfile $def_bootfile # set to default 99*0Sstevel@tonic-gate endif 100*0Sstevel@tonic-gateendif 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate# other stuff 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gatesetprop whoami $bootfile 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate# 'b', 'i', or <ENTER> are the only valid responses 107*0Sstevel@tonic-gateif ( ${cmd_err} == 1 ) 108*0Sstevel@tonic-gate source /etc/bootrc 109*0Sstevel@tonic-gateelse 110*0Sstevel@tonic-gate run $bootfile 111*0Sstevel@tonic-gate echo "could not run ${bootfile}" 112*0Sstevel@tonic-gate set bootfile 113*0Sstevel@tonic-gate source /etc/bootrc 114*0Sstevel@tonic-gateendif 115