#!/usr/sbin/openrc-run

description="User and session management daemon"

command="/usr/libexec/elogind"
pidfile="/run/elogind.pid"

extra_started_commands="reload"

depend() {
	need dbus
	use logger
	after rsyslog
	provide logind
	before xdm
}

start() {
	[ -x "$command" ] || return 1
	ebegin "Starting ${RC_SVCNAME}"
	start-stop-daemon -S -p "$pidfile" \
		-x "$command" -- ${ELOGIND_OPTS:--D}
	eend $?
}

stop() {
	ebegin "Stopping ${RC_SVCNAME}"
	start-stop-daemon -K -p "$pidfile"
	eend $?
}

reload() {
	ebegin "Reloading ${RC_SVCNAME}"
	start-stop-daemon -K -s HUP -p "${pidfile}"
	eend $?
}

restart() {
	ebegin "Restarting ${RC_SVCNAME}"
	start-stop-daemon -K -s INT -p "${pidfile}" -R 30
	eend $?
	start
}
