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-8
Date: Tue, 01 May 2012 22:09:05
Message-Id: 20120501220846.5B3722004C@flycatcher.gentoo.org
1 chithanh 12/05/01 22:08:46
2
3 Added: xdm.initd-8
4 Log:
5 Version bump, bug #413371.
6
7 (Portage version: 2.2.0_alpha101/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 x11-base/xorg-server/files/xdm.initd-8
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-base/xorg-server/files/xdm.initd-8?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-base/xorg-server/files/xdm.initd-8?rev=1.1&content-type=text/plain
14
15 Index: xdm.initd-8
16 ===================================================================
17 #!/sbin/runscript
18 # Copyright 1999-2012 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-8,v 1.1 2012/05/01 22:08:46 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 # (#366753) starting keymaps after X causes problems
66 after bootmisc consolefont modules netmount
67 after readahead-list ypbind autofs openvpn gpm lircmd
68 after quota keymaps
69 before alsasound
70
71 # Start before X
72 use consolekit dbus xfs
73 }
74
75 setup_dm() {
76 local MY_XDM
77
78 MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')
79
80 # Load our root path from profile.env
81 # Needed for kdm
82 PATH=${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}")
83
84 NAME=
85 case "${MY_XDM}" in
86 kdm|kde)
87 EXE=/usr/bin/kdm
88 PIDFILE=/var/run/kdm.pid
89 ;;
90 entrance*)
91 EXE=/usr/sbin/entranced
92 PIDFILE=/var/lib/entranced.pid
93 ;;
94 gdm|gnome)
95 EXE=/usr/bin/gdm
96 [ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary
97 PIDFILE=/var/run/gdm.pid
98 ;;
99 wdm)
100 EXE=/usr/bin/wdm
101 PIDFILE=
102 ;;
103 gpe)
104 EXE=/usr/bin/gpe-dm
105 PIDFILE=/var/run/gpe-dm.pid
106 ;;
107 lxdm)
108 EXE=/usr/sbin/lxdm-binary
109 PIDFILE=/var/run/lxdm.pid
110 START_STOP_ARGS="--background"
111 ;;
112 lightdm)
113 EXE=/usr/sbin/lightdm
114 PIDFILE=/var/run/lightdm.pid
115 START_STOP_ARGS="--background"
116 ;;
117 *)
118 # first find out if there is such executable
119 EXE="$(command -v ${MY_XDM} 2>/dev/null)"
120 PIDFILE="/var/run/${MY_XDM}.pid"
121
122 # warn user that he is doing sick things if the exe was not found
123 if [ -z "${EXE}" ]; then
124 echo "ERROR: Your XDM value is invalid."
125 echo " No ${MY_XDM} executable could be found on your system."
126 fi
127 ;;
128 esac
129
130 if ! [ -x "${EXE}" ]; then
131 EXE=/usr/bin/xdm
132 PIDFILE=/var/run/xdm.pid
133 if ! [ -x "/usr/bin/xdm" ]; then
134 echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
135 echo " or install x11-apps/xdm package"
136 eend 255
137 fi
138 fi
139 }
140
141 # Check to see if something is defined on our VT
142 vtstatic() {
143 if [ -e /etc/inittab ] ; then
144 grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
145 elif [ -e /etc/ttys ] ; then
146 grep -q "^ttyv$(($1 - 1))" /etc/ttys
147 else
148 return 1
149 fi
150 }
151
152 start() {
153 local EXE NAME PIDFILE
154 setup_dm
155
156 if [ -f /etc/.noxdm ]; then
157 einfo "Skipping ${EXE##*/}, /etc/.noxdm found or \"nox\" bootparam passed."
158 rm /etc/.noxdm
159 return 0
160 fi
161
162 ebegin "Setting up ${EXE##*/}"
163
164 # save the prefered DM
165 save_options "service" "${EXE}"
166 save_options "name" "${NAME}"
167 save_options "pidfile" "${PIDFILE}"
168 save_options "start_stop_args" "${START_STOP_ARGS}"
169
170 if [ -n "${CHECKVT-y}" ] ; then
171 if vtstatic "${CHECKVT:-7}" ; then
172 if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then
173 ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later"
174 telinit a >/dev/null 2>&1
175 return 0
176 else
177 eerror "Something is already defined on VT ${CHECKVT:-7}, not starting"
178 return 1
179 fi
180 fi
181 fi
182
183 /etc/X11/startDM.sh
184 eend 0
185 }
186
187 stop() {
188 local curvt retval
189
190 retval=0
191 if [ -t 0 ]; then
192 if type fgconsole >/dev/null 2>&1; then
193 curvt=$(fgconsole 2>/dev/null)
194 else
195 curvt=$(tty)
196 case "${curvt}" in
197 /dev/ttyv[0-9]*) curvt=${curvt#/dev/ttyv} ;;
198 *) curvt= ;;
199 esac
200 fi
201 fi
202 local myexe myname mypidfile myservice
203 myexe=$(get_options "service")
204 myname=$(get_options "name")
205 mypidfile=$(get_options "pidfile")
206 myservice=${myexe##*/}
207
208 [ -z "${myexe}" ] && return 0
209
210 ebegin "Stopping ${myservice}"
211
212 if start-stop-daemon --quiet --test --stop --exec "${myexe}"; then
213 start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
214 ${mypidfile:+--pidfile} ${mypidfile} \
215 ${myname:+--name} ${myname}
216 retval=${?}
217 fi
218
219 # switch back to original vt
220 if [ -n "${curvt}" ]; then
221 if type chvt >/dev/null 2>&1; then
222 chvt "${curvt}"
223 else
224 vidcontrol -s "$((curvt + 1))"
225 fi
226 fi
227
228 eend ${retval} "Error stopping ${myservice}"
229 return ${retval}
230 }
231
232 # vim: set ts=4 :