5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
24 # Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
27 # This started its life as the Caiman text-installer menu, hence the old
28 # OpenSolaris CDDL statement.
30 # LOGNAME variable is needed to display the shell prompt appropriately
33 # Block all signals which could terminate the menu or return to a parent process
34 trap "" TSTP INT TERM ABRT QUIT
36 # Determine which shell program to use by grabbing this user's login-shell
38 ROOT_SHELL
=$
(/usr
/bin
/getent passwd
$LOGNAME |
/usr
/bin
/cut
-d':' -f7)
40 # On the off chance that $LOGNAME has no shell (default grabbed from passwd(4)p)
41 if [[ -z "$ROOT_SHELL" ]]; then
42 ROOT_SHELL
="/usr/bin/sh"
46 /kayak
/mount_media unleashed-installer
48 # Get the user's keyboard choice out of the way now.
51 # Remember it post-installation scribbling into installed-image /etc/default/kbd
52 ktype
=`/usr/bin/kbd -l | grep type | awk -F= '{print $2}'`
53 layout
=`/usr/bin/kbd -l | grep layout | awk -F= '{print $2}' | awk '{print $1}'`
54 klang
=`grep -w $layout /usr/share/lib/keytables/type_$ktype/kbd_layouts | awk -F= '{print $1}'`
56 # Define the menu of commands and prompts
58 (menu_str
="Find disks, create rpool, and install unleashed" \
59 cmds
=("/kayak/find-and-install.sh $klang") \
60 do_subprocess
="true" \
62 (menu_str
="Install to a preconfigured rpool" \
63 cmds
=("/kayak/rpool-install.sh rpool $klang") \
64 do_subprocess
="true" \
66 (menu_str
="Shell (for manual rpool creation, or post-install ops on /mnt)" \
67 cmds
=("$ROOT_SHELL") \
68 do_subprocess
="true" \
69 msg_str
="To return to the main menu, exit the shell") \
70 # this string gets overwritten every time $TERM is updated
71 (menu_str
="Terminal type (currently ""$TERM)" \
72 cmds
=("prompt_for_term_type") \
73 do_subprocess
="false" \
76 cmds
=("/usr/sbin/reboot" "/usr/bin/sleep 10000") \
77 do_subprocess
="true" \
81 # Update the menu_str for the terminal type
82 # entry. Every time the terminal type has been
83 # updated, this function must be called.
84 function update_term_menu_str
86 # update the menu string to reflect the current TERM
87 for i
in "${!menu_items[@]}"; do
88 if [[ "${menu_items[$i].cmds[0]}" = "prompt_for_term_type" ]] ; then
89 menu_items
[$i].menu_str
="Terminal type (currently $TERM)"
94 # Set the TERM variable as follows:
96 # Just set it to "sun-color" for now.
98 function set_term_type
100 export TERM
=sun-color
104 # Prompt the user for terminal type
105 function prompt_for_term_type
109 # list of suggested termtypes
112 integer list_len
# number of terminal types
115 # hard coded common terminal types
116 termtypes.fixedlist
=(
117 [0]=( name
="sun-color" desc
="PC Console" )
118 [1]=( name
="xterm" desc
="xterm" )
119 [2]=( name
="vt100" desc
="DEC VT100" )
122 termtypes.list_len
=${#termtypes.fixedlist[@]}
124 # Start with a newline before presenting the choices
126 printf "Indicate the type of terminal being used, such as:\n"
128 # list suggested terminal types
129 for (( i
=0 ; i
< termtypes.list_len
; i
++ )) ; do
130 nameref node
=termtypes.fixedlist
[$i]
131 printf " %-10s %s\n" "${node.name}" "${node.desc}"
135 # Prompt user to select terminal type and check for valid entry
138 read "term?Enter terminal type [$TERM]: " ||
continue
140 # if the user just hit return, don't set the term variable
141 [[ "${term}" = "" ]] && return
143 # check if the user specified option is valid
144 term_entry
=`/usr/bin/ls /usr/share/terminfo/*/$term 2> /dev/null`
145 [[ ! -z ${term_entry} ]] && break
146 print
"terminal type not supported. Supported terminal types can be \n" "${term}"
147 print
"found by using the Shell to list the contents of /usr/share/terminfo.\n\n"
150 export TERM
="${term}"
156 # default to the Installer option
165 "Welcome to the unleashed installation menu"
167 for i
in "${!menu_items[@]}"; do
168 print
"\t$((${i} + 1)) ${menu_items[$i].menu_str}"
171 # Take an entry (by number). If multiple numbers are
172 # entered, accept only the first one.
175 print
-n "\nPlease enter a number [${defaultchoice}]: "
176 read input dummy
2>/dev
/null
178 # If no input was supplied, select the default option
179 [[ -z ${input} ]] && input
=$defaultchoice
181 # First char must be a digit.
182 if [[ ${input} =~ [^1-9] || ${input} > ${#menu_items[@]} ]] ; then
186 # Reorient to a zero base.
187 input
=$
((${input} - 1))
189 nameref msg_str
=menu_items
[$input].msg_str
191 # Launch commands as a subprocess.
192 # However, launch the functions within the context
193 # of the current process.
194 if [[ "${menu_items[$input].do_subprocess}" = "true" ]] ; then
196 trap - TSTP INT TERM ABRT QUIT
197 # Print out a message if requested
198 [[ ! -z "${msg_str}" ]] && printf "%s\n" "${msg_str}"
199 for j
in "${!menu_items[$input].cmds[@]}"; do
200 ${menu_items[${input}].cmds[$j]}
204 # Print out a message if requested
205 [[ ! -z "${msg_str}" ]] && printf "%s\n" "${msg_str}"
206 for j
in "${!menu_items[$input].cmds[@]}"; do
207 ${menu_items[${input}].cmds[$j]}