diff --git a/extra/lemurs.openrc b/extra/lemurs.openrc new file mode 100644 index 0000000..7bffa5a --- /dev/null +++ b/extra/lemurs.openrc @@ -0,0 +1,26 @@ +#!/sbin/openrc-run + +# This section is kindly copied from display-manager-init +depend() { + need localmount + + after bootmisc consolefont modules netmount + after readahead-list ypbind autofs openvpn gpm lircmd + after quota keymaps + after elogind + after sssd + before alsasound + + use dbus xfs +} + +tty=7 +supervisor=supervise-daemon +command="/usr/bin/openvt" +command_args="--console ${tty} -e /usr/bin/lemurs" +# Use -f to ignore processes from past sessions i.e. tmux +#command_args="-f ${command_args}" +pidfile="/run/${RC_SVCNAME}.pid" +respawn_delay=2 +respawn_max=5 +respawn_period=15 diff --git a/extra/lemurs.sysv b/extra/lemurs.sysv new file mode 100644 index 0000000..4953fb2 --- /dev/null +++ b/extra/lemurs.sysv @@ -0,0 +1,51 @@ +#!/bin/sh +tty=7 +export RC_SVCNAME="lemurs" +# Linux +pidfile="/run/${RC_SVCNAME}.pid" +# Unix +#pidfile="/var/run/${RC_SVCNAME}.pid" +# Use -f to ignore processes from past sessions i.e. tmux. +args="--console ${tty} -e lemurs" +#args="-f ${args}" + +start() { + unset XDG_SESSION_TYPE + supervise-daemon "${RC_SVCNAME}" -D 1 -m 5 --respawn-period 15 -p "${pidfile}" --start openvt -- ${args} +} + +stop() { + supervise-daemon lemurs --stop -p "${pidfile}" +} + +restart() { + stop + start +} + +status() { + if [ -e /run/lemurs.pid ]; then + if ps -P $(cat "${pidfile}") &>/dev/null; then + echo "Running" + else + echo "Crashed" + fi + else + echo "Stopped" + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + status) + status + ;; +esac diff --git a/extra/s6/finish b/extra/s6/finish new file mode 100644 index 0000000..e916f99 --- /dev/null +++ b/extra/s6/finish @@ -0,0 +1,2 @@ +#!/bin/execlineb -P +s6-permafailon 15 5 SIGTERM exit diff --git a/extra/s6/run b/extra/s6/run new file mode 100644 index 0000000..d102291 --- /dev/null +++ b/extra/s6/run @@ -0,0 +1,7 @@ +#!/bin/execlineb -P +tty=7 +args="--console ${tty} -e /usr/bin/lemurs" +# Use -f to ignore processes from past sessions i.e. tmux +#args="-f ${args}" +foreground { echo "Starting service lemurs..." } +openvt "${args}"