diff --git a/alpine/Makefile b/alpine/Makefile index 67b9f9060..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 $(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 72% rename from alpine/inittab.armhf rename to alpine/etc/inittab index d641de0ab..33ae471da 100644 --- a/alpine/inittab.armhf +++ b/alpine/etc/inittab @@ -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/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 diff --git a/alpine/inittab.x86_64 b/alpine/inittab.x86_64 deleted file mode 100644 index ba4999ea5..000000000 --- a/alpine/inittab.x86_64 +++ /dev/null @@ -1,17 +0,0 @@ -# /etc/inittab - -::sysinit:/sbin/openrc sysinit -::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