diff --git a/initramfs-init.in b/initramfs-init.in index 8233af46afdfe89a56cdd970777588f90bf7a05b..81a18c95da2c09c6649cb290cb0468d41f1ff3a0 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -105,34 +105,28 @@ rc_add() { ln -sf /etc/init.d/$1 $sysroot/etc/runlevels/$2/$1 } -setup_inittab_console(){ - while [ $# -gt 0 ]; do - local tty=${1%,*} - local speed=${1#*,} - local line= - local term= - case "$tty" in - ttyS*|ttyMFD*|ttyUSB*|ttyAMA*) - term=vt100 - line=-L - flow=${speed##*[^r]} - speed=${speed%%[^0-9]*} - speed=${speed:-115200} - ;; - *) - [ "$speed" = "$1" ] && speed=38400 - ;; - esac - shift +# Recursively resolve tty aliases like console or tty0 +list_console_devices() { + if ! [ -e /sys/class/tty/$1/active ]; then + echo $1 + return + fi - # skip "current console" from being added to inittab - [ "$tty" = "tty0" ] && continue + for dev in $(cat /sys/class/tty/$1/active); do + list_console_devices $dev + done +} +setup_inittab_console(){ + term=vt100 + # Inquire the kernel for list of console= devices + for tty in $(list_console_devices console); do # do nothing if inittab already have the tty set up if ! grep -q "^$tty:" $sysroot/etc/inittab; then echo "# enable login on alternative console" \ >> $sysroot/etc/inittab - echo "$tty::respawn:/sbin/getty ${flow:+-h }$line $speed $tty $term" \ + # Baudrate of 0 keeps settings from kernel + echo "$tty::respawn:/sbin/getty -L 0 $tty $term" \ >> $sysroot/etc/inittab fi if [ -e "$sysroot"/etc/securetty ] && ! grep -q -w "$tty" "$sysroot"/etc/securetty; then @@ -292,10 +286,6 @@ for opt; do SINGLEMODE=yes continue ;; - console=*) - CONSOLE="$CONSOLE ${opt#console=}" - continue - ;; esac for i in $myopts; do @@ -707,7 +697,7 @@ if [ -f "$sysroot"/etc/fstab ]; then fi # fix inittab if alternative console -setup_inittab_console $CONSOLE +setup_inittab_console # copy alpine release info #if ! [ -f "$sysroot"/etc/alpine-release ] && [ -f $ALPINE_MNT/.alpine-release ]; then