Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding init scripts for OpenRC, s6, and old school sysvinit. #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions extra/lemurs.openrc
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions extra/lemurs.sysv
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions extra/s6/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/execlineb -P
s6-permafailon 15 5 SIGTERM exit
7 changes: 7 additions & 0 deletions extra/s6/run
Original file line number Diff line number Diff line change
@@ -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}"
Loading