From bf4ced07d08a226fa49da4f78d94f8daf98f7e17 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 12 Jul 2016 15:10:11 +0200 Subject: [PATCH 1/4] 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 From 39d3ac8429d8e29f57494753a31a9efbdbbe331a Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 13 Jul 2016 18:06:34 +0200 Subject: [PATCH 2/4] remove getty from inittab Depend on specifying the console as a boot option Signed-off-by: Natanael Copa --- alpine/inittab.armhf | 4 +--- alpine/inittab.x86_64 | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/alpine/inittab.armhf b/alpine/inittab.armhf index d641de0ab..33ae471da 100644 --- a/alpine/inittab.armhf +++ b/alpine/inittab.armhf @@ -4,11 +4,9 @@ ::sysinit:/sbin/openrc boot ::wait:/sbin/openrc default -# Put a getty on the serial port -ttyAMA0::respawn:/sbin/getty -L ttyAMA0 115200 vt100 - # Stuff to do for the 3-finger salute ::ctrlaltdel:/sbin/reboot # Stuff to do before rebooting ::shutdown:/sbin/rc shutdown + diff --git a/alpine/inittab.x86_64 b/alpine/inittab.x86_64 index ba4999ea5..33ae471da 100644 --- a/alpine/inittab.x86_64 +++ b/alpine/inittab.x86_64 @@ -4,14 +4,9 @@ ::sysinit:/sbin/openrc boot ::wait:/sbin/openrc default -# Put a getty on the serial port -ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 - -# Put a getty on the console -tty1::respawn:/sbin/getty 115200 tty1 linux - # Stuff to do for the 3-finger salute ::ctrlaltdel:/sbin/reboot # Stuff to do before rebooting ::shutdown:/sbin/rc shutdown + From 34bd1e9322017f377326ce4b676a3555ae603a35 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 13 Jul 2016 18:24:02 +0200 Subject: [PATCH 3/4] fix initrd.img dependencies trigger rebuild if init or inittab was changed Signed-off-by: Natanael Copa --- alpine/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpine/Makefile b/alpine/Makefile index 67b9f9060..63132f7f2 100644 --- a/alpine/Makefile +++ b/alpine/Makefile @@ -3,7 +3,7 @@ all: initrd.img.gz mobylinux-efi.iso ETCFILES=etc/issue etc/motd etc/network/interfaces ETCFILES+=etc/securetty -initrd.img: Dockerfile mkinitrd.sh $(ETCFILES) +initrd.img: Dockerfile mkinitrd.sh inittab.x86_64 init $(ETCFILES) rm -f initrd.img $(MAKE) -C packages $(MAKE) -C kernel From 9bbf27cb66078d54f3c3981f8c55645d6fa7ade0 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 13 Jul 2016 18:46:03 +0200 Subject: [PATCH 4/4] merge inittab.x86_64 and inittab.armhf with the login tty generated from boot cmdline the inittab will be equal on all archs and platforms so we can merge and move to etc/ Signed-off-by: Natanael Copa --- alpine/Makefile | 5 ++--- alpine/{inittab.armhf => etc/inittab} | 0 alpine/inittab.x86_64 | 12 ------------ 3 files changed, 2 insertions(+), 15 deletions(-) rename alpine/{inittab.armhf => etc/inittab} (100%) delete mode 100644 alpine/inittab.x86_64 diff --git a/alpine/Makefile b/alpine/Makefile index 63132f7f2..0346bbcb9 100644 --- a/alpine/Makefile +++ b/alpine/Makefile @@ -1,13 +1,12 @@ all: initrd.img.gz mobylinux-efi.iso ETCFILES=etc/issue etc/motd etc/network/interfaces -ETCFILES+=etc/securetty +ETCFILES+=etc/securetty etc/inittab -initrd.img: Dockerfile mkinitrd.sh inittab.x86_64 init $(ETCFILES) +initrd.img: Dockerfile mkinitrd.sh init $(ETCFILES) rm -f initrd.img $(MAKE) -C packages $(MAKE) -C kernel - cp inittab.x86_64 etc/inittab docker-compose build moby docker-compose run --rm -T moby /bin/mkinitrd.sh diff --git a/alpine/inittab.armhf b/alpine/etc/inittab similarity index 100% rename from alpine/inittab.armhf rename to alpine/etc/inittab diff --git a/alpine/inittab.x86_64 b/alpine/inittab.x86_64 deleted file mode 100644 index 33ae471da..000000000 --- a/alpine/inittab.x86_64 +++ /dev/null @@ -1,12 +0,0 @@ -# /etc/inittab - -::sysinit:/sbin/openrc sysinit -::sysinit:/sbin/openrc boot -::wait:/sbin/openrc default - -# Stuff to do for the 3-finger salute -::ctrlaltdel:/sbin/reboot - -# Stuff to do before rebooting -::shutdown:/sbin/rc shutdown -