/[gentoo-x86]/x11-base/xorg-server/files/xdm.initd-5
Gentoo

Contents of /x11-base/xorg-server/files/xdm.initd-5

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Nov 24 13:09:40 2011 UTC (2 years, 7 months ago) by chithanh
Branch: MAIN
Change "after dbus" to "use dbus", bug #327257, bug #390609, and bug #391275.

(Portage version: 2.2.0_alpha77/cvs/Linux x86_64)

1 #!/sbin/runscript
2 # Copyright 1999-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License, v2
4 # $Header: /var/cvsroot/gentoo-x86/x11-base/xorg-server/files/xdm.initd-4,v 1.1 2011/11/16 21:49:59 chithanh Exp $
5
6 # This is here to serve as a note to myself, and future developers.
7 #
8 # Any Display manager (gdm,kdm,xdm) has the following problem: if
9 # it is started before any getty, and no vt is specified, it will
10 # usually run on vt2. When the getty on vt2 then starts, and the
11 # DM is already started, the getty will take control of the keyboard,
12 # leaving us with a "dead" keyboard.
13 #
14 # Resolution: add the following line to /etc/inittab
15 #
16 # x:a:once:/etc/X11/startDM.sh
17 #
18 # and have /etc/X11/startDM.sh start the DM in daemon mode if
19 # a lock is present (with the info of what DM should be started),
20 # else just fall through.
21 #
22 # How this basically works, is the "a" runlevel is a additional
23 # runlevel that you can use to fork processes with init, but the
24 # runlevel never gets changed to this runlevel. Along with the "a"
25 # runlevel, the "once" key word means that startDM.sh will only be
26 # run when we specify it to run, thus eliminating respawning
27 # startDM.sh when "xdm" is not added to the default runlevel, as was
28 # done previously.
29 #
30 # This script then just calls "telinit a", and init will run
31 # /etc/X11/startDM.sh after the current runlevel completes (this
32 # script should only be added to the actual runlevel the user is
33 # using).
34 #
35 # Martin Schlemmer
36 # aka Azarah
37 # 04 March 2002
38
39 depend() {
40 need localmount xdm-setup
41
42 # this should start as early as possible
43 # we can't do 'before *' as that breaks it
44 # (#139824) Start after ypbind and autofs for network authentication
45 # (#145219 #180163) Could use lirc mouse as input device
46 # (#70689 comment #92) Start after consolefont to avoid display corruption
47 # (#291269) Start after quota, since some dm need readable home
48 # (#390609) gdm-3 will fail when dbus is not running
49 after bootmisc consolefont modules netmount
50 after readahead-list ypbind autofs openvpn gpm lircmd
51 after quota
52 before alsasound
53
54 # Start before X
55 use consolekit dbus xfs
56 }
57
58 setup_dm() {
59 local MY_XDM
60
61 MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')
62
63 # Load our root path from profile.env
64 # Needed for kdm
65 PATH=${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}")
66
67 NAME=
68 case "${MY_XDM}" in
69 kdm|kde)
70 EXE="$(which kdm)"
71 PIDFILE=/var/run/kdm.pid
72 ;;
73 kdm-*)
74 EXE="/usr/kde/${MY_XDM#kdm-}/bin/kdm"
75 PIDFILE=/var/run/kdm.pid
76 ;;
77 entrance*)
78 EXE=/usr/sbin/entranced
79 PIDFILE=/var/lib/entranced.pid
80 ;;
81 gdm|gnome)
82 EXE=/usr/bin/gdm
83 [ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary
84 PIDFILE=/var/run/gdm.pid
85 ;;
86 wdm)
87 EXE=/usr/bin/wdm
88 PIDFILE=
89 ;;
90 gpe)
91 EXE=/usr/bin/gpe-dm
92 PIDFILE=/var/run/gpe-dm.pid
93 ;;
94 lxdm)
95 EXE=/usr/sbin/lxdm-binary
96 PIDFILE=/var/run/lxdm.pid
97 START_STOP_ARGS="--background"
98 ;;
99 lightdm)
100 EXE=/usr/sbin/lightdm
101 PIDFILE=/var/run/lightdm.pid
102 START_STOP_ARGS="--background"
103 ;;
104 *)
105 # first find out if there is such executable
106 EXE="$(which ${MY_XDM} 2>/dev/null)"
107 PIDFILE="/var/run/${MY_XDM}.pid"
108
109 # warn user that he is doing sick things if the exe was not found
110 if [ -z "${EXE}" ]; then
111 echo "ERROR: Your XDM value is invalid."
112 echo " No ${MY_XDM} executable could be found on your system."
113 fi
114 ;;
115 esac
116
117 if ! [ -x "${EXE}" ]; then
118 EXE=/usr/bin/xdm
119 PIDFILE=/var/run/xdm.pid
120 if ! [ -x "/usr/bin/xdm" ]; then
121 echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
122 echo " or install x11-apps/xdm package"
123 eend 255
124 fi
125 fi
126 }
127
128 # Check to see if something is defined on our VT
129 vtstatic() {
130 if [ -e /etc/inittab ] ; then
131 grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
132 elif [ -e /etc/ttys ] ; then
133 grep -q "^ttyv$(($1 - 1))" /etc/ttys
134 else
135 return 1
136 fi
137 }
138
139 start() {
140 local EXE NAME PIDFILE
141 setup_dm
142
143 if [ -f /etc/.noxdm ]; then
144 einfo "Skipping ${EXE##*/}, /etc/.noxdm found or \"nox\" bootparam passed."
145 rm /etc/.noxdm
146 return 0
147 fi
148
149 ebegin "Setting up ${EXE##*/}"
150
151 # save the prefered DM
152 save_options "service" "${EXE}"
153 save_options "name" "${NAME}"
154 save_options "pidfile" "${PIDFILE}"
155 save_options "start_stop_args" "${START_STOP_ARGS}"
156
157 if [ -n "${CHECKVT-y}" ] ; then
158 if vtstatic "${CHECKVT:-7}" ; then
159 if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then
160 ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later"
161 telinit a >/dev/null 2>&1
162 return 0
163 else
164 eerror "Something is already defined on VT ${CHECKVT:-7}, not starting"
165 return 1
166 fi
167 fi
168 fi
169
170 /etc/X11/startDM.sh
171 eend 0
172 }
173
174 stop() {
175 local curvt retval
176
177 retval=0
178 if [ -t 0 ]; then
179 if type fgconsole >/dev/null 2>&1; then
180 curvt=$(fgconsole 2>/dev/null)
181 else
182 curvt=$(tty)
183 case "${curvt}" in
184 /dev/ttyv[0-9]*) curvt=${curvt#/dev/ttyv} ;;
185 *) curvt= ;;
186 esac
187 fi
188 fi
189 local myexe myname mypidfile myservice
190 myexe=$(get_options "service")
191 myname=$(get_options "name")
192 mypidfile=$(get_options "pidfile")
193 myservice=${myexe##*/}
194
195 [ -z "${myexe}" ] && return 0
196
197 ebegin "Stopping ${myservice}"
198
199 if start-stop-daemon --quiet --test --stop --exec "${myexe}"; then
200 start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
201 ${mypidfile:+--pidfile} ${mypidfile} \
202 ${myname:+--name} ${myname}
203 retval=${?}
204 fi
205
206 # switch back to original vt
207 if [ -n "${curvt}" ]; then
208 if type chvt >/dev/null 2>&1; then
209 chvt "${curvt}"
210 else
211 vidcontrol -s "$((curvt + 1))"
212 fi
213 fi
214
215 eend ${retval} "Error stopping ${myservice}"
216 return ${retval}
217 }
218
219 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20