~didrocks/lightdm/packaging-cleanup

« back to all changes in this revision

Viewing changes to debian/lightdm.init

  • Committer: Robert Ancell
  • Date: 2013-04-30 19:12:50 UTC
  • Revision ID: robert.ancell@canonical.com-20130430191250-g7tj2exduq8bc3ri
Add packaging

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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:          lightdm
 
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 lightdm
 
31
### END INIT INFO
 
32
 
 
33
set -e
 
34
 
 
35
HEED_DEFAULT_DISPLAY_MANAGER=
 
36
# To start lightdm 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/lightdm start
 
40
[ -z "$HEED_DEFAULT_DISPLAY_MANAGER" ] && HEED_DEFAULT_DISPLAY_MANAGER=true
 
41
 
 
42
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
 
43
 
 
44
PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
45
DAEMON=/usr/bin/lightdm
 
46
PIDFILE=/var/run/lightdm.pid
 
47
 
 
48
if [ -r /etc/default/locale ]; then
 
49
  . /etc/default/locale
 
50
  export LANG LANGUAGE
 
51
fi
 
52
 
 
53
test -x $DAEMON || exit 0
 
54
 
 
55
. /lib/lsb/init-functions
 
56
 
 
57
SSD_START_ARGS="--pidfile $PIDFILE --name $(basename $DAEMON) --startas $DAEMON -- -d"
 
58
SSD_STOP_ARGS="--pidfile $PIDFILE --name $(basename $DAEMON) --retry TERM/5/TERM/5"
 
59
 
 
60
case "$1" in
 
61
  start)
 
62
    if [ "$HEED_DEFAULT_DISPLAY_MANAGER" = "true" ] &&
 
63
       [ -e $DEFAULT_DISPLAY_MANAGER_FILE ] &&
 
64
       [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" != "/usr/bin/lightdm" ]; then
 
65
      echo "Not starting X display manager (lightdm); it is not the default" \
 
66
        "display manager."
 
67
    else
 
68
      log_daemon_msg "Starting X display manager" "lightdm"
 
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/lightdm stop
 
77
    [ -f $PIDFILE ] && exit 1
 
78
    /etc/init.d/lightdm start
 
79
  ;;
 
80
 
 
81
  stop)
 
82
    log_daemon_msg "Stopping X display manager" "lightdm"
 
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/lightdm restart
 
104
  ;;
 
105
 
 
106
  *)
 
107
    echo "Usage: /etc/init.d/lightdm {start|stop|restart|force-reload}"
 
108
    exit 1
 
109
    ;;
 
110
esac
 
111
 
 
112
exit 0