Correcting debian/lxdm.install file.
[debian/lxdm.git] / debian / lxdm.init
CommitLineData
6da61772
DB
1#!/bin/sh
2
3# Largely adapted from xdm's init script:
4# Copyright 1998-2002, 2004, 2005 Branden Robinson <branden@debian.org>.
5# Copyright 2006 Eugene Konev <ejka@imfi.kspu.ru>
6#
7# This is free software; you may redistribute it and/or modify
8# it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2,
10# or (at your option) any later version.
11#
12# This is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License with
18# the Debian operating system, in /usr/share/common-licenses/GPL; if
19# not, write to the Free Software Foundation, Inc., 51 Franklin Street,
20# Fifth Floor, Boston, MA 02110-1301, USA.
21
22### BEGIN INIT INFO
23# Provides: lxdm
24# Should-Start: $named console-screen dbus acpid hal consolekit
25# Required-Start: $local_fs $remote_fs x11-common
26# Required-Stop: $local_fs $remote_fs
27# Should-Stop: $named
28# Default-Start: 2 3 4 5
29# Default-Stop: 0 1 6
30# Short-Description: LXDE Display Manager (LXDM)
31# Description: Debian init script for the LXDE Display Manager
32### END INIT INFO
33
34set -e
35
36HEED_DEFAULT_DISPLAY_MANAGER=
37# To start lxdm even if it is not the default display manager, change
38# HEED_DEFAULT_DISPLAY_MANAGER to "false."
39# Also overridable from command line like:
40# HEED_DEFAULT_DISPLAY_MANAGER=false /etc/init.d/lxdm start
41[ -z "$HEED_DEFAULT_DISPLAY_MANAGER" ] && HEED_DEFAULT_DISPLAY_MANAGER=true
42
43DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
44
45PATH=/bin:/usr/bin:/sbin:/usr/sbin
46DAEMON=/usr/sbin/lxdm-binary
47PIDFILE=/var/run/lxdm.pid
48
49if [ -r /etc/default/locale ]; then
50 . /etc/default/locale
51 export LANG LANGUAGE
52fi
53
54test -x $DAEMON || exit 0
55
56. /lib/lsb/init-functions
57
58SSD_START_ARGS="--pidfile $PIDFILE --name $(basename $DAEMON) --startas $DAEMON -- -d"
59SSD_STOP_ARGS="--pidfile $PIDFILE --name $(basename $DAEMON) --retry TERM/5/TERM/5"
60
61case "$1" in
62 start)
63 if [ "$HEED_DEFAULT_DISPLAY_MANAGER" = "true" ] &&
64 [ -e $DEFAULT_DISPLAY_MANAGER_FILE ] &&
65 [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" != "/usr/sbin/lxdm" ]; then
66 echo "Not starting X display manager (lxdm); it is not the default" \
67 "display manager."
68 else
69 log_daemon_msg "Starting X display manager" "lxdm"
70 start-stop-daemon --start --quiet $SSD_START_ARGS \
71 || log_progress_msg "already running"
72 log_end_msg 0
73 fi
74 ;;
75
76 restart)
77 [ -f $PIDFILE ] && /etc/init.d/lxdm stop
78 [ -f $PIDFILE ] && exit 1
79 /etc/init.d/lxdm start
80 ;;
81
82 stop)
83 log_daemon_msg "Stopping X display manager" "lxdm"
84 if ! [ -f $PIDFILE ]; then
85 log_progress_msg "not running ($PIDFILE not found)"
86 else
87 start-stop-daemon --stop --quiet $SSD_STOP_ARGS
88 SSD_RES=$?
89 if [ $SSD_RES -eq 1 ]; then
90 log_progress_msg "not running"
91 fi
92 if [ $SSD_RES -eq 2 ]; then
93 log_progress_msg "not responding to TERM signals"
94 else
95 if [ -f $PIDFILE ]; then
96 log_progress_msg "(removing stale $PIDFILE)"
97 rm $PIDFILE
98 fi
99 fi
100 fi
101 log_end_msg 0
102 ;;
103 force-reload)
104 /etc/init.d/lxdm restart
105 ;;
106
107 *)
108 echo "Usage: /etc/init.d/lxdm {start|stop|restart|force-reload}"
109 exit 1
110 ;;
111esac
112
113exit 0