~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to debian/kdm.init

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# /etc/init.d/kdm: start or stop the X display manager
 
3
# Script originally stolen from the xdm package
 
4
#
 
5
# description: K Desktop Manager
 
6
#
 
7
set -e
 
8
 
 
9
# To start kdm even if it is not the default display manager, change
 
10
# HEED_DEFAULT_DISPLAY_MANAGER to "false."
 
11
HEED_DEFAULT_DISPLAY_MANAGER=true
 
12
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
 
13
 
 
14
PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
15
DAEMON=/usr/bin/kdm
 
16
PIDFILE=/var/run/kdm.pid
 
17
UPGRADEFILE=/var/run/kdm.upgrade
 
18
 
 
19
test -x $DAEMON || exit 0
 
20
 
 
21
# uncomment, if you want auto-logon to be runlevel-dependant
 
22
#test "$runlevel" || { runlevel=`runlevel`; runlevel=${runlevel#* }; }
 
23
#test "$runlevel" = 4 && ARG=-autolog || ARG=-noautolog
 
24
 
 
25
# uncomment, if you want tons of debug info in your syslog 
 
26
#ARG="$ARG -debug 255"
 
27
 
 
28
# If we upgraded the daemon, we can't use the --exec argument to
 
29
# start-stop-daemon since the inode will have changed.  The risk here is that
 
30
# in a situation where the daemon died, its pidfile was not cleaned up, and
 
31
# some other process is now running under that pid, start-stop-daemon will send
 
32
# signals to an innocent process.  However, this seems like a corner case.
 
33
# C'est la vie!
 
34
if [ -e $UPGRADEFILE ]; then
 
35
  SSD_ARGS="--pidfile $PIDFILE --startas $DAEMON"
 
36
else
 
37
  SSD_ARGS="--pidfile $PIDFILE --exec $DAEMON"
 
38
fi
 
39
 
 
40
stillrunning () {
 
41
  if expr "$(cat /proc/$DAEMONPID/cmdline 2> /dev/null)" : "$DAEMON" > /dev/null 2>&1; then
 
42
    true
 
43
  else
 
44
    # if the daemon does not remove its own pidfile, we will
 
45
    rm -f $PIDFILE $UPGRADEFILE
 
46
    false
 
47
  fi;
 
48
}
 
49
 
 
50
case "$1" in
 
51
  start)
 
52
    if [ -e $DEFAULT_DISPLAY_MANAGER_FILE ] &&
 
53
       [ "$HEED_DEFAULT_DISPLAY_MANAGER" = "true" ] &&
 
54
       [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" != "$DAEMON" ]; then
 
55
      echo "Not starting K Desktop Manager (kdm); it is not the default display manager."
 
56
    else
 
57
      echo -n "Starting K Desktop Manager: kdm"
 
58
      start-stop-daemon --start --quiet $SSD_ARGS -- $ARG || echo -n " already running"
 
59
      echo "."
 
60
    fi
 
61
  ;;
 
62
 
 
63
  restart)
 
64
    /etc/init.d/kdm stop
 
65
    if [ -f $PIDFILE ]; then
 
66
      if stillrunning; then
 
67
        exit 1
 
68
      fi
 
69
    fi
 
70
    /etc/init.d/kdm start
 
71
  ;;
 
72
 
 
73
  reload)
 
74
    echo -n "Reloading K Desktop Manager configuration..."
 
75
    if start-stop-daemon --stop --signal 1 --quiet $SSD_ARGS; then
 
76
      echo "done."
 
77
    else
 
78
      echo "kdm not running."
 
79
    fi
 
80
  ;;
 
81
 
 
82
  force-reload)
 
83
    /etc/init.d/kdm reload
 
84
  ;;
 
85
 
 
86
  stop)
 
87
    echo -n "Stopping K Desktop Manager: kdm"
 
88
    if [ ! -f $PIDFILE ]; then
 
89
      echo " not running ($PIDFILE not found)."
 
90
      exit 0
 
91
    else
 
92
      DAEMONPID=$(cat $PIDFILE | tr -d '[:blank:]')
 
93
      KILLCOUNT=1
 
94
      if [ ! -e $UPGRADEFILE ]; then
 
95
        if start-stop-daemon --stop --quiet $SSD_ARGS; then
 
96
          # give kdm's signal handler a second to catch its breath
 
97
          sleep 1
 
98
        else
 
99
          echo -n " not running"
 
100
        fi
 
101
      fi
 
102
      while [ $KILLCOUNT -le 5 ]; do
 
103
        if stillrunning; then
 
104
          kill $DAEMONPID
 
105
        else
 
106
          break
 
107
        fi
 
108
        sleep 1
 
109
        KILLCOUNT=$(( $KILLCOUNT + 1 ))
 
110
      done
 
111
      if stillrunning; then
 
112
        echo -n " not responding to TERM signal (pid $DAEMONPID)"
 
113
      else
 
114
        rm -f $UPGRADEFILE
 
115
      fi
 
116
    fi
 
117
    echo "."
 
118
  ;;
 
119
 
 
120
  *)
 
121
    echo "Usage: /etc/init.d/kdm {start|stop|restart|reload|force-reload}"
 
122
    exit 1
 
123
    ;;
 
124
esac
 
125
 
 
126
exit 0