package/openrc: add support for spawning getty
We install a template getty service, and we 'instantiate' it in the default runlevel, using the configured tty. Ideally, packages that provide a getty program would be responsible for installing the corresponding service file. However, to keep consistency with the existing init systems (busybox, systemd, and sysv), so we do provide it from the openrc package itself. OpenRC only acts on the files in a runlevel sub-directory, but the documentation [0] actually suggests that the instance symlink be done in init.d, and then again symlinked into the actual runlevel sub-directory. So, we abide by the rules. Also, to be noted, the getty service file is installed without ensuring that a getty command is available. This again is not unlike other init systems, sysvinit and busybox, which behave the same. [0] https://wiki.gentoo.org/wiki/OpenRC Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl> [yann.morin.1998@free.fr: - move getty template to openrc package (Thomas) - fix namespace of the vaiables (Thomas) - simplify creation of the defaults file - rewrite commit log ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
parent
af8c7b41f5
commit
4019559de0
24
package/openrc/getty
Executable file
24
package/openrc/getty
Executable file
@ -0,0 +1,24 @@
|
||||
#!/sbin/openrc-run
|
||||
# based on agetty service from OpenRC package
|
||||
|
||||
description="start getty on terminal"
|
||||
supervisor=supervise-daemon
|
||||
port="${RC_SVCNAME#*.}"
|
||||
term_type="${term_type:-linux}"
|
||||
command=/sbin/getty
|
||||
command_args_foreground="${getty_options} ${baud} ${port} ${term_type}"
|
||||
pidfile="/run/${RC_SVCNAME}.pid"
|
||||
|
||||
depend() {
|
||||
# start getty at the very end of init
|
||||
after *
|
||||
keyword -prefix
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
export EINFO_QUIET="${quiet:-yes}"
|
||||
}
|
||||
|
||||
stop_pre() {
|
||||
export EINFO_QUIET="${quiet:-yes}"
|
||||
}
|
@ -42,4 +42,22 @@ define OPENRC_REMOVE_UNNEEDED
|
||||
endef
|
||||
OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_REMOVE_UNNEEDED
|
||||
|
||||
ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
|
||||
OPENRC_GETTY_SVCNAME = getty.$(SYSTEM_GETTY_PORT)
|
||||
OPENRC_GETTY_CONF_D = $(TARGET_DIR)/etc/conf.d/$(OPENRC_GETTY_SVCNAME)
|
||||
define OPENRC_SET_GETTY
|
||||
{ \
|
||||
echo "baud=\"$(SYSTEM_GETTY_BAUDRATE)\""; \
|
||||
echo "term_type=\"$(SYSTEM_GETTY_TERM)\"" ; \
|
||||
echo "getty_options=\"-L $(SYSTEM_GETTY_OPTIONS)\""; \
|
||||
} > $(OPENRC_GETTY_CONF_D)
|
||||
$(INSTALL) -D -m 0755 $(OPENRC_PKGDIR)/getty \
|
||||
$(TARGET_DIR)/etc/init.d/getty
|
||||
ln -sf getty $(TARGET_DIR)/etc/init.d/$(OPENRC_GETTY_SVCNAME)
|
||||
ln -sf /etc/init.d/$(OPENRC_GETTY_SVCNAME) \
|
||||
$(TARGET_DIR)/etc/runlevels/default/$(OPENRC_GETTY_SVCNAME)
|
||||
endef
|
||||
OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_SET_GETTY
|
||||
endif # BR2_TARGET_GENERIC_GETTY
|
||||
|
||||
$(eval $(generic-package))
|
||||
|
@ -348,16 +348,16 @@ config BR2_TARGET_GENERIC_GETTY_BAUDRATE
|
||||
config BR2_TARGET_GENERIC_GETTY_TERM
|
||||
string "TERM environment variable"
|
||||
default "vt100"
|
||||
# currently observed only by busybox and sysvinit
|
||||
depends on BR2_INIT_BUSYBOX || BR2_INIT_SYSV
|
||||
# currently observed by all but systemd
|
||||
depends on !BR2_INIT_SYSTEMD
|
||||
help
|
||||
Specify a TERM type.
|
||||
|
||||
config BR2_TARGET_GENERIC_GETTY_OPTIONS
|
||||
string "other options to pass to getty"
|
||||
default ""
|
||||
# currently observed only by busybox and sysvinit
|
||||
depends on BR2_INIT_BUSYBOX || BR2_INIT_SYSV
|
||||
# currently observed by all but systemd
|
||||
depends on !BR2_INIT_SYSTEMD
|
||||
help
|
||||
Any other flags you want to pass to getty,
|
||||
Refer to getty --help for details.
|
||||
|
Loading…
Reference in New Issue
Block a user