Gentoo Archives: gentoo-commits

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