From 0cefb3da8e50c4ef8a2df66ab529c5943b8effdf Mon Sep 17 00:00:00 2001 From: Cavernosa <42952107+Cavernosa@users.noreply.github.com> Date: Sat, 13 Aug 2022 08:44:53 +0000 Subject: [PATCH] OpenRC service and support for more inits (#368) Add OpenRC service and support for other init services Co-authored-by: Jonathan <78560204+wncry@users.noreply.github.com> Co-authored-by: MadcowOG Co-authored-by: MadcowOG <88654251+MadcowOG@users.noreply.github.com> --- makefile | 15 +++++++++++---- readme.md | 23 ++++++++++++++++++++++- res/ly-openrc | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 res/ly-openrc diff --git a/makefile b/makefile index f8cc6ed..6b9177d 100644 --- a/makefile +++ b/makefile @@ -70,7 +70,7 @@ leakgrind: $(BIND)/$(NAME) @less valgrind.log install: $(BIND)/$(NAME) - @echo "installing" + @echo "installing ly" @install -dZ ${DESTDIR}/etc/ly @install -DZ $(BIND)/$(NAME) -t ${DESTDIR}/usr/bin @install -DZ $(RESD)/config.ini -t ${DESTDIR}/etc/ly @@ -78,20 +78,26 @@ install: $(BIND)/$(NAME) @install -DZ $(RESD)/wsetup.sh -t $(DATADIR) @install -dZ $(DATADIR)/lang @install -DZ $(RESD)/lang/* -t $(DATADIR)/lang - @install -DZ $(RESD)/ly.service -m 644 -t ${DESTDIR}/usr/lib/systemd/system @install -DZ $(RESD)/pam.d/ly -m 644 -t ${DESTDIR}/etc/pam.d installnoconf: $(BIND)/$(NAME) - @echo "installing without the configuration file" + @echo "installing ly without the configuration file" @install -dZ ${DESTDIR}/etc/ly @install -DZ $(BIND)/$(NAME) -t ${DESTDIR}/usr/bin @install -DZ $(RESD)/xsetup.sh -t $(DATADIR) @install -DZ $(RESD)/wsetup.sh -t $(DATADIR) @install -dZ $(DATADIR)/lang @install -DZ $(RESD)/lang/* -t $(DATADIR)/lang - @install -DZ $(RESD)/ly.service -m 644 -t ${DESTDIR}/usr/lib/systemd/system @install -DZ $(RESD)/pam.d/ly -m 644 -t ${DESTDIR}/etc/pam.d +installsystemd: + @echo "installing systemd service" + @install -DZ $(RESD)/ly.service -m 644 -t ${DESTDIR}/usr/lib/systemd/system + +installopenrc: + @echo "installing openrc service" + @install -DZ $(RESD)/ly-openrc -m 755 -T ${DESTDIR}/etc/init.d/${NAME} + uninstall: @echo "uninstalling" @rm -rf ${DESTDIR}/etc/ly @@ -99,6 +105,7 @@ uninstall: @rm -f ${DESTDIR}/usr/bin/ly @rm -f ${DESTDIR}/usr/lib/systemd/system/ly.service @rm -f ${DESTDIR}/etc/pam.d/ly + @rm -f ${DESTDIR}/etc/init.d/${NAME} clean: @echo "cleaning" diff --git a/readme.md b/readme.md index f4643f6..31c1309 100644 --- a/readme.md +++ b/readme.md @@ -76,7 +76,7 @@ or a terminal emulator (but desktop environments won't start) Install Ly and the provided systemd service file ``` -# make install +# make install installsystemd ``` Enable the service @@ -90,6 +90,27 @@ disable getty on Ly's tty to prevent "login" from spawning on top of it # systemctl disable getty@tty2.service ``` +### OpenRC + +Clone, compile and test. + +Install Ly and the provided OpenRC service +``` +# make install installopenrc +``` + +Enable the service +``` +# rc-update add ly +``` + +You can edit which tty Ly will start on by editing the `tty` option in the configuration file. + +If you choose a tty that already has a login/getty running (has a basic login prompt), then you have to disable the getty so it doesn't respawn on top of ly +``` +# rc-update del agetty.tty2 +``` + ## Arch Linux Installation You can install ly from the [AUR](https://aur.archlinux.org/packages/ly), using yay for example: ``` diff --git a/res/ly-openrc b/res/ly-openrc new file mode 100644 index 0000000..7021829 --- /dev/null +++ b/res/ly-openrc @@ -0,0 +1,38 @@ +#!/sbin/openrc-run + +name="ly" +description="TUI Display Manager" + +## Supervisor daemon +supervisor=supervise-daemon +respawn_period=60 +pidfile=/run/"${RC_SVCNAME}.pid" + +## Check for getty or agetty +if [ -x /sbin/getty ] || [ -x /bin/getty ]; +then + # busybox + commandB="/sbin/getty" +elif [ -x /sbin/agetty ] || [ -x /bin/agetty ]; +then + # util-linux + commandUL="/sbin/agetty" +fi + +## Get the tty from the conf file +CONFTTY=$(cat /etc/ly/config.ini | sed -n 's/^tty.*=[^1-9]*// p') + +## The execution vars +# If CONFTTY is empty then default to 2 +TTY="tty${CONFTTY:-2}" +TERM=linux +BAUD=38400 +# If we don't have getty then we should have agetty +command=${commandB:-$commandUL} +command_args_foreground="-nl /usr/bin/ly $TTY $BAUD $TERM" + +depend() { + after agetty + provide display-manager + want elogind +}