* added testing for /etc/default/locale
[debian/lxdm.git] / debian / lxdm.init
CommitLineData
a382005b
AL
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# Required-Start: $local_fs $remote_fs
25# Required-Stop: $local_fs $remote_fs
26# Should-Start: $named acpid hal
27# Should-Stop: $named
28# Default-Start: 2 3 4 5
29# Default-Stop: 0 1 6
30# Short-Description: Start lxdm
31### END INIT INFO
32
33set -e
34
35HEED_DEFAULT_DISPLAY_MANAGER=
36# To start lxdm even if it is not the default display manager, change
37# HEED_DEFAULT_DISPLAY_MANAGER to "false."
38# Also overridable from command line like:
39# HEED_DEFAULT_DISPLAY_MANAGER=false /etc/init.d/lxdm start
40[ -z "$HEED_DEFAULT_DISPLAY_MANAGER" ] && HEED_DEFAULT_DISPLAY_MANAGER=true
41
42DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
43
44PATH=/bin:/usr/bin:/sbin:/usr/sbin
4445d853 45DAEMON=/usr/sbin/lxdm-binary
a382005b
AL
46PIDFILE=/var/run/lxdm.pid
47
5f4488eb
DS
48if [ -r /etc/default/locale ]; then
49 . /etc/default/locale
50 export LANG LANGUAGE
4445d853
NP
51fi
52
a382005b
AL
53test -x $DAEMON || exit 0
54
55. /lib/lsb/init-functions
56
57SSD_START_ARGS="--pidfile $PIDFILE --name $(basename $DAEMON) --startas $DAEMON -- -d"
58SSD_STOP_ARGS="--pidfile $PIDFILE --name $(basename $DAEMON) --retry TERM/5/TERM/5"
59
60case "$1" in
61 start)
62 if [ "$HEED_DEFAULT_DISPLAY_MANAGER" = "true" ] &&
63 [ -e $DEFAULT_DISPLAY_MANAGER_FILE ] &&
4445d853 64 [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" != "/usr/sbin/lxdm" ]; then
a382005b
AL
65 echo "Not starting X display manager (lxdm); it is not the default" \
66 "display manager."
67 else
68 log_daemon_msg "Starting X display manager" "lxdm"
69 start-stop-daemon --start --quiet $SSD_START_ARGS \
70 || log_progress_msg "already running"
71 log_end_msg 0
72 fi
73 ;;
74
75 restart)
76 [ -f $PIDFILE ] && /etc/init.d/lxdm stop
77 [ -f $PIDFILE ] && exit 1
78 /etc/init.d/lxdm start
79 ;;
80
81 stop)
82 log_daemon_msg "Stopping X display manager" "lxdm"
83 if ! [ -f $PIDFILE ]; then
84 log_progress_msg "not running ($PIDFILE not found)"
85 else
86 start-stop-daemon --stop --quiet $SSD_STOP_ARGS
87 SSD_RES=$?
88 if [ $SSD_RES -eq 1 ]; then
89 log_progress_msg "not running"
90 fi
91 if [ $SSD_RES -eq 2 ]; then
92 log_progress_msg "not responding to TERM signals"
93 else
94 if [ -f $PIDFILE ]; then
95 log_progress_msg "(removing stale $PIDFILE)"
96 rm $PIDFILE
97 fi
98 fi
99 fi
100 log_end_msg 0
101 ;;
102 force-reload)
103 /etc/init.d/lxdm restart
104 ;;
105
106 *)
107 echo "Usage: /etc/init.d/lxdm {start|stop|restart|force-reload}"
108 exit 1
109 ;;
110esac
111
112exit 0