You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4 KiB

#! /bin/sh
### BEGIN INIT INFO
# Provides: elogind
# Required-Start: dbus $remote_fs $syslog
# Required-Stop: dbus $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start elogind at boot tim
# Description: Enable user and session management by elogind
### END INIT INFO
set -e
# /etc/init.d/elogind: start and stop the elogind session management daemon
ELOGIND=/usr/sbin/elogind
test -x $ELOGIND || exit 0
umask 022
. /lib/lsb/init-functions
ELOGIND_OPTS="-D"
ELOGIND_PID=/run/elogind.pid
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
log_daemon_msg "Starting session management daemon" "elogind" || true
if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping session management daemon" "elogind" || true
if start-stop-daemon --stop --quiet --oknodo --pidfile $ELOGIND_PID; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
reload|force-reload|restart)
log_daemon_msg "Restarting session management daemon" "elogind" || true
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $ELOGIND_PID
if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
try-restart)
log_daemon_msg "Restarting session management daemon" "elogind" || true
RET=0
start-stop-daemon --stop --quiet --retry 30 --pidfile $ELOGIND_PID || RET="$?"
case $RET in
0)
# old daemon stopped
if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
1)
# daemon not running
log_progress_msg "(not running)" || true
log_end_msg 0 || true
;;
*)
# failed to stop
log_progress_msg "(failed to stop)" || true
log_end_msg 1 || true
;;
esac
;;
status)
status_of_proc -p $ELOGIND_PID $ELOGIND elogind && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/elogind {start|stop|reload|force-reload|restart|try-restart|status}" || true
exit 1
esac
exit 0