summaryrefslogtreecommitdiff
path: root/debian/lightdm.init
blob: 2e81f60ad0351b24858a7cc5c680d26d7016ed42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh
### BEGIN INIT INFO
# Provides:          lightdm
# Should-Start:      console-screen kbd acpid dbus hal consolekit
# Required-Start:    $local_fs $remote_fs x11-common
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Light Display Manager
# Description:       Debian init script for the Light Display Manager
### END INIT INFO
#
# Author:       Yves-Alexis Perez <corsac@debian.org> using gdm script from 
#               Ryan Murray <rmurray@debian.org>
#
set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lightdm

test -x $DAEMON || exit 0

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi

. /lib/lsb/init-functions

# To start lightdm even if it is not the default display manager, change
# HEED_DEFAULT_DISPLAY_MANAGER to "false."
HEED_DEFAULT_DISPLAY_MANAGER=true
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager

case "$1" in
  start)
        CONFIGURED_DAEMON=$(basename "$(cat $DEFAULT_DISPLAY_MANAGER_FILE 2> /dev/null)")
        if grep -wqs text /proc/cmdline; then
            log_warning_msg "Not starting Light Display Manager (lightdm); found 'text' in kernel commandline."
        elif [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ] && \
           [ "$HEED_DEFAULT_DISPLAY_MANAGER" = "true" ] && \
           [ "$CONFIGURED_DAEMON" != lightdm ] ; then
                log_action_msg "Not starting Light Display Manager; it is not the default display manager"
        else
                log_daemon_msg "Starting Light Display Manager" "lightdm"
                start-stop-daemon --start --quiet --pidfile /var/run/lightdm.pid --name lightdm --exec $DAEMON -b|| echo -n " already running"
                log_end_msg $?
        fi
  ;;
  stop)
        log_daemon_msg "Stopping Light Display Manager" "lightdm"
        set +e
        start-stop-daemon --stop --quiet --pidfile /var/run/lightdm.pid \
                --name lightdm --retry 5
        set -e
        log_end_msg $?
  ;;
  reload)
        log_daemon_msg "Scheduling reload of Light Display Manager configuration" "lightdm"
        set +e
        start-stop-daemon --stop --signal USR1 --quiet --pidfile \
                /var/run/lightdm.pid --name lightdm
        set -e
        log_end_msg $?
  ;;
  status)
        status_of_proc -p "$PIDFILE" "$DAEMON" lightdm && exit 0 || exit $?
  ;;
  restart|force-reload)
        $0 stop
        sleep 1
        $0 start
  ;;
  *)
        echo "Usage: /etc/init.d/lightdm {start|stop|restart|reload|force-reload|status}"
        exit 1
  ;;
esac

exit 0