diff options
author | Laurent Bercot <ska-adelie@skarnet.org> | 2019-10-03 10:31:29 -0500 |
---|---|---|
committer | Laurent Bercot <ska-adelie@skarnet.org> | 2019-10-03 10:31:29 -0500 |
commit | 2c782daf6fae1b418168a5e8a9336fe9e6b9215e (patch) | |
tree | 8b749945bc1d8baca29d60e573ceadbab69e8c6f /system | |
parent | 7fabe3e35d27fd34b780d135ac09b846a4083257 (diff) | |
download | packages-2c782daf6fae1b418168a5e8a9336fe9e6b9215e.tar.gz packages-2c782daf6fae1b418168a5e8a9336fe9e6b9215e.tar.bz2 packages-2c782daf6fae1b418168a5e8a9336fe9e6b9215e.tar.xz packages-2c782daf6fae1b418168a5e8a9336fe9e6b9215e.zip |
system/s6-linux-init: make early getty configurable. PLEASE REVIEW.
Also touches gettys-openrc to avoid spawning the same getty twice.
Diffstat (limited to 'system')
-rw-r--r-- | system/gettys-openrc/gettys.initd | 26 | ||||
-rw-r--r-- | system/s6-linux-init/APKBUILD | 13 | ||||
-rw-r--r-- | system/s6-linux-init/earlygetty.run | 31 |
3 files changed, 53 insertions, 17 deletions
diff --git a/system/gettys-openrc/gettys.initd b/system/gettys-openrc/gettys.initd index a1fbb2082..1f02d29f4 100644 --- a/system/gettys-openrc/gettys.initd +++ b/system/gettys-openrc/gettys.initd @@ -11,14 +11,11 @@ makeservice() { tty="$1" eval 'options="$GETTYS_'"$tty"'_OPTIONS"' eval 'baud="$GETTYS_'"$tty"'_BAUDRATE"' - if test -z "$baud" ; then - baud=38400 - fi mkdir -p -m 0755 "/var/lib/s6/services/getty-$tty" { echo '#!/bin/execlineb -P' echo - echo "/sbin/agetty $options -- $baud $tty linux" + echo "/sbin/agetty $options -- $tty $baud" } > "/var/lib/s6/services/getty-$tty/run" chmod 0755 "/var/lib/s6/services/getty-$tty/run" } @@ -32,6 +29,17 @@ nomatchname() { return 0 } +notearly() { + if test -d /etc/s6-linux-init/current/run-image/service/s6-linux-init-early-getty ; then + if early=`head -n 1 /run/kernel_env/earlygetty` ; then + early="${early%%,*}" + else + early=tty2 + fi + test "$1" != "$early" + fi +} + start() { set -e ebegin "Applying getty configuration" @@ -46,13 +54,9 @@ start() { done for i in $GETTYS ; do - if test -c /dev/"$i" ; then - if test -d "/etc/s6-linux-init/current/run-image/service/getty-$i" ; then - : - else - makeservice "$i" - ln -nsf "/var/lib/s6/services/getty-$i" "/run/service/getty-$i" - fi + if test -c /dev/"$i" && notearly "$i" ; then + makeservice "$i" + ln -nsf "/var/lib/s6/services/getty-$i" "/run/service/getty-$i" fi done diff --git a/system/s6-linux-init/APKBUILD b/system/s6-linux-init/APKBUILD index 7dff13d2e..d9855abd2 100644 --- a/system/s6-linux-init/APKBUILD +++ b/system/s6-linux-init/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Laurent Bercot <ska-adelie@skarnet.org> pkgname=s6-linux-init pkgver=1.0.3.0 -pkgrel=0 +pkgrel=1 pkgdesc="A s6-based init system" url="https://skarnet.org/software/$pkgname/" arch="all" @@ -12,10 +12,9 @@ _skalibs_version=2.9.0.0 depends="execline s6 s6-linux-init-common" makedepends="skalibs-dev>=$_skalibs_version execline-dev s6-dev utmps-dev" subpackages="$pkgname-common:common:noarch $pkgname-early-getty:earlygetty:noarch $pkgname-libs $pkgname-dev $pkgname-libs-dev:libsdev $pkgname-doc" -source="https://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz rc.init runlevel rc.shutdown reboot.sh" +source="https://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz rc.init runlevel rc.shutdown reboot.sh earlygetty.run" install="$pkgname.post-install $pkgname.post-upgrade $pkgname.pre-deinstall" provides="/sbin/init=0" -_earlytty=tty2 build() { cd "$builddir" @@ -46,7 +45,7 @@ package() { ./s6-linux-init-maker \ -u catchlog \ - -G "/sbin/agetty -- 38400 $_earlytty linux" \ + -G "sleep 86400" \ -1 \ -L \ -p "/usr/bin:/usr/sbin:/bin:/sbin" \ @@ -78,12 +77,14 @@ common() { earlygetty() { - pkgdesc="Files for an early getty on $_earlytty" + pkgdesc="Files for a configurable early getty" depends="s6-linux-init-common" svcimg="$pkgdir/etc/s6-linux-init/current/run-image/service" subsvcimg="$subpkgdir/etc/s6-linux-init/current/run-image/service" mkdir -p -m 0755 "$subsvcimg" - mv "$svcimg/s6-linux-init-early-getty" "$subsvcimg/getty-$_earlytty" + mv "$svcimg/s6-linux-init-early-getty" "$subsvcimg/" + cp -f "$srcdir/earlygetty.run" "$subsvcimg/s6-linux-init-early-getty/run" + chmod 0755 "$subsvcimg/s6-linux-init-early-getty/run" } diff --git a/system/s6-linux-init/earlygetty.run b/system/s6-linux-init/earlygetty.run new file mode 100644 index 000000000..809fac747 --- /dev/null +++ b/system/s6-linux-init/earlygetty.run @@ -0,0 +1,31 @@ +#!/bin/sh -e + +tty=tty2 +baud= +options='-L' + +if line=`head -n 1 /run/kernel_env/earlygetty` ; then + tty="${line%%,*}" + bpnf="${line##*,}" + nf= + f= + clean=false + case "$bpnf" in + *n*) baud=${bpnf%%n*} ; nf="${bpnf##*n}" ; clean=true ;; + *o*) baud=${bpnf%%o*} ; nf="${bpnf##*o}" ;; + *e*) baud=${bpnf%%e*} ; nf="${bpnf##*e}" ;; + [[:digit:]]*) baud=$bpnf + esac + case "$nf" in + 7*) clean=false ; f="${nf#7}" ;; + [[:digit:]]*) clean=true ; f="${nf#?}" + esac + if $clean ; then + options="$options -8" + fi + if test "$f" = 'r' ; then + options="$options -h" + fi +fi + +exec /sbin/agetty $options -- "$tty" "$baud" |