summaryrefslogtreecommitdiff
path: root/system/gettys-openrc/gettys.initd
diff options
context:
space:
mode:
Diffstat (limited to 'system/gettys-openrc/gettys.initd')
-rw-r--r--system/gettys-openrc/gettys.initd38
1 files changed, 38 insertions, 0 deletions
diff --git a/system/gettys-openrc/gettys.initd b/system/gettys-openrc/gettys.initd
new file mode 100644
index 000000000..cf74b0e8a
--- /dev/null
+++ b/system/gettys-openrc/gettys.initd
@@ -0,0 +1,38 @@
+#!/sbin/openrc-run
+
+description="Create s6 services for gettys on user-chosen terminals"
+
+depend() {
+ after dev-mount
+}
+
+makeservice() {
+ set -e
+ tty="$1"
+ eval 'options="$GETTYS_'"$tty"'_OPTIONS"'
+ eval 'baud="$GETTYS_'"$tty"'_BAUDRATE"'
+ if test -z "$baud" ; then
+ baud=38400
+ fi
+ mkdir -p -m 0755 "/run/early-services/getty-$tty"
+ {
+ echo '#!/bin/execlineb -P'
+ echo
+ echo "/sbin/agetty $options -- $baud $tty linux"
+ } > "/run/early-services/getty-$tty/run"
+ chmod 0755 "/run/early-services/getty-$tty/run"
+}
+
+start()
+{
+ set -e
+ mkdir -m 0755 -p /run/early-services
+ . /etc/conf.d/gettys
+ for i in $GETTYS ; do
+ if test -c /dev/"$i" ; then
+ ebegin "Creating getty service for $i"
+ makeservice "$i"
+ eend $?
+ fi
+ done
+}