# /etc/inittab -- read by busybox init, which is PID 1 on a live Duct system.
#
# Format: <tty>:<ignored>:<action>:<command>. The second field is a runlevel in
# sysvinit and is ignored here; busybox has no runlevels.

# Run once, before anything else, and wait for it.
::sysinit:/usr/libexec/duct-live/rc

# A session on the console -- whatever the kernel decided that is. With no
# console= on the command line it is the active virtual terminal; with
# console=ttyS0 or console=ttyAMA0 it is the serial port, which is how an
# automated boot test watches the machine come up.
#
# console-session rather than bash directly, and that is not a stylistic
# choice: it goes through login(1) when there is one, so PAM runs and
# pam_elogind creates /run/user/<uid>. A bare `bash --login` here works today
# and silently gives a graphical session nowhere to put its Wayland socket
# later. See files/console-session.
::respawn:-/usr/libexec/duct-live/console-session

# tty1 -- the greeter, on a medium that has one.
#
# THIS IS THE ONE ENTRY THAT IS NOT A SHELL, and it is on tty1 because that is
# the terminal a display manager expects to own. On a medium with neither a
# display manager nor a compositor the script says so and exits, which costs
# nothing under `once` and leaves the explanation on the screen.
#
# It can collide with the console entry above, and only in one case: no serial
# port, so /dev/console is tty0, which is tty1. console-session asks
# graphical-session whether it is going to start something and stands aside if
# it is -- so the greeter gets tty1 and the shells are on tty2 and tty3.
#
# `once` RATHER THAN `respawn`, and the reason is what happens on a bad day. A
# respawned greeter that dies at startup restarts forever: the screen flickers,
# the error scrolls past, and there is nothing left to read. Started once, a
# greeter that dies leaves its last words on tty1 and stays there -- and
# because console-session has already stood aside from tty1, the shells on
# tty2 and tty3 keep the machine usable while you read them. On a live medium
# the failure being inspectable is worth more than the session being resilient;
# there is no state to protect and rebooting costs nothing.
tty1::once:/usr/libexec/duct-live/graphical-session

# Two more virtual terminals, on tty2 and tty3.
#
# Not tty1: with no console= parameter /dev/console follows the active virtual
# terminal, which at boot is tty1 -- so an entry for tty1 would put a second
# shell on the same terminal as the console entry above, and the two would
# fight over every keystroke.
tty2::respawn:-/usr/libexec/duct-live/console-session
tty3::respawn:-/usr/libexec/duct-live/console-session

::ctrlaltdel:/usr/bin/busybox reboot
::shutdown:/usr/libexec/duct-live/shutdown
::restart:/usr/sbin/init
