From 235ab0058226ae80d9a1bdb161fa66d99bf6a356 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 12 Jul 2016 15:10:11 +0200 Subject: [PATCH] add console options from boot cmdline to inittab This will make sure that you get a login console that corresponds to the boot option. Signed-off-by: Natanael Copa --- alpine/init | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/alpine/init b/alpine/init index 8261480bb..5519d5b3f 100755 --- a/alpine/init +++ b/alpine/init @@ -1,7 +1,43 @@ #!/bin/sh +setup_console() { + tty=${1%,*} + speed=${1#*,} + inittab="$2" + securetty="$3" + line= + term="linux" + [ "$speed" = "$1" ] && speed=115200 + + case "$tty" in + ttyS*|ttyAMA*|ttyUSB*|ttyMFD*) + line="-L" + term="vt100" + ;; + tty0) + # skip current console + return 0 + ;; + esac + # skip consoles already in inittab + grep -q "^$tty:" "$inittab" && return + + echo "$tty::respawn:/sbin/getty $line $speed $tty $term" >> "$inittab" + if ! grep -q -w "$tty" "$securetty"; then + echo "$tty" >> "$securetty" + fi +} + /bin/mount -t tmpfs tmpfs /mnt /bin/cp -a / /mnt 2>/dev/null +/bin/mount -t proc -o noexec,nosuid,nodev proc /proc +for opt in $(cat /proc/cmdline); do + case "$opt" in + console=*) + setup_console ${opt#console=} /mnt/etc/inittab /mnt/etc/securetty;; + esac +done + exec /bin/busybox switch_root /mnt /sbin/init