From 4c67611c9013f86bac452317ce55f8f6b69ffc53 Mon Sep 17 00:00:00 2001 From: Pops Dylan Date: Thu, 5 Dec 2019 20:58:47 -0800 Subject: [PATCH] postmarketos-base: configure getty using deviceinfo_getty variable (!771) On some devices a getty should run on the serial console. Configure the getty by setting the deviceinfo_getty variable. The format is ";". For example, "ttyS0;115200". A post-installation trigger in postmarketos-base checks /etc/deviceinfo, and modifies /etc/inittab if the device should run a getty. --- main/postmarketos-base/APKBUILD | 3 +- .../postmarketos-base.trigger | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 main/postmarketos-base/postmarketos-base.trigger diff --git a/main/postmarketos-base/APKBUILD b/main/postmarketos-base/APKBUILD index 5b87f155e..ec0bd5592 100644 --- a/main/postmarketos-base/APKBUILD +++ b/main/postmarketos-base/APKBUILD @@ -1,6 +1,6 @@ pkgname=postmarketos-base pkgver=3 -pkgrel=29 +pkgrel=30 pkgdesc="Meta package for minimal postmarketOS base" url="https://postmarketos.org" arch="noarch" @@ -26,6 +26,7 @@ depends=" pulseaudio pulseaudio-alsa" install="$pkgname.post-install" +triggers="$pkgname.trigger=/etc" subpackages="$pkgname-x11" source=" firmwareload.sh diff --git a/main/postmarketos-base/postmarketos-base.trigger b/main/postmarketos-base/postmarketos-base.trigger new file mode 100644 index 000000000..1162d1924 --- /dev/null +++ b/main/postmarketos-base/postmarketos-base.trigger @@ -0,0 +1,40 @@ +#!/bin/sh -e + +# Each argument to this shell script is a path that caused the trigger to execute. +# If /etc/deviceinfo was installed (which should be the case for any device) and +# deviceinfo_getty is set, then configure a getty. + +deviceinfo="false" + +for i in "$@"; do + case "$i" in + /etc) + if [ -f /etc/deviceinfo ]; then + deviceinfo="true" + fi + break ;; + esac +done + +if [ "$deviceinfo" = "true" ]; then + deviceinfo_getty="" + + # shellcheck disable=SC1091 + . /etc/deviceinfo + + if [ -n "${deviceinfo_getty}" ]; then + port=$(echo "${deviceinfo_getty}" | cut -s -d ";" -f 1) + baudrate=$(echo "${deviceinfo_getty}" | cut -s -d ";" -f 2) + + if [ -n "${port}" ] && [ -n "${baudrate}" ]; then + echo "Configuring a getty on port ${port} with baud rate ${baudrate}" + sed -i -e "s/#ttyS0::respawn:\/sbin\/getty -L ttyS0 115200 vt100/${port}::respawn:\/sbin\/getty -L ${port} ${baudrate} vt100/" /etc/inittab + else + echo "ERROR: Invalid value for deviceinfo_getty: ${deviceinfo_getty}" + exit 1 + fi + fi +fi + +sync +exit 0