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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Sep 28 12:43:19 2010 UTC (4 years ago) by scarabeus
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
Revision bump to fix initscript, thx to Michal Gorny (bug #338837). Apply patch to fix compilation issues, thx to Alexandre Rostovtsev (bug #337020). Update deps per bug #338519.

(Portage version: 2.2_rc87/cvs/Linux x86_64)

1 #!/sbin/runscript
2 # Copyright 1999-2004 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-2,v 1.1 2010/09/12 20:45:23 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
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 after bootmisc consolefont modules netmount
49 after readahead-list ypbind autofs openvpn gpm lircmd
50 after quota
51 before alsasound
52
53 # Start before X
54 use consolekit xfs
55 }
56
57 setup_dm() {
58 local MY_XDM="$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')"
59
60 # Load our root path from profile.env
61 # Needed for kdm
62 PATH="${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}")"
63
64 case "${MY_XDM}" in
65 kdm|kde)
66 EXE="$(which kdm)"
67 PIDFILE=/var/run/kdm.pid
68 ;;
69 kdm-*)
70 EXE="/usr/kde/${MY_XDM#kdm-}/bin/kdm"
71 PIDFILE=/var/run/kdm.pid
72 ;;
73 entrance*)
74 EXE=/usr/sbin/entranced
75 PIDFILE=/var/lib/entranced.pid
76 ;;
77 gdm|gnome)
78 EXE=/usr/bin/gdm
79 [ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary
80 PIDFILE=/var/run/gdm.pid
81 ;;
82 wdm)
83 EXE=/usr/bin/wdm
84 PIDFILE=
85 ;;
86 gpe)
87 EXE=/usr/bin/gpe-dm
88 PIDFILE=/var/run/gpe-dm.pid
89 ;;
90 *)
91 # first find out if there is such executable
92 EXE="$(which ${MY_XDM} 2>/dev/null)"
93 PIDFILE="/var/run/${MY_XDM}.pid"
94
95 # warn user that he is doing sick things if the exe was not found
96 if [ "${EXE}" = "" ]; then
97 echo "ERROR: Your XDM value is invalid."
98 echo " No ${MY_XDM} executable could be found on your system."
99 fi
100 ;;
101 esac
102
103 if ! [ -x "${EXE}" ]; then
104 EXE=/usr/bin/xdm
105 PIDFILE=/var/run/xdm.pid
106 if ! [ -x "/usr/bin/xdm" ]; then
107 echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
108 echo " or install x11-apps/xdm package"
109 eend 255
110 fi
111 fi
112 }
113
114 # Check to see if something is defined on our VT
115 vtstatic() {
116 if [ -e /etc/inittab ] ; then
117 grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
118 elif [ -e /etc/ttys ] ; then
119 grep -q "^ttyv$(($1 - 1))" /etc/ttys
120 else
121 return 1
122 fi
123 }
124
125 start() {
126 local EXE= NAME= PIDFILE=
127 setup_dm
128
129 if [ -f /etc/.noxdm ] || get_bootparam "nox" ; then
130 einfo "Skipping ${EXE##*/}, /etc/.noxdm found or \"nox\" bootparam passed."
131 rm /etc/.noxdm
132 return 0
133 fi
134
135 ebegin "Setting up ${EXE##*/}"
136
137 # save the prefered DM
138 save_options "service" "${EXE}"
139 save_options "name" "${NAME}"
140 save_options "pidfile" "${PIDFILE}"
141
142 if [ -n "${CHECKVT-y}" ] ; then
143 if vtstatic "${CHECKVT:-7}" ; then
144 if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ] ; then
145 ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later"
146 telinit a >/dev/null 2>/dev/null
147 return 0
148 else
149 eerror "Something is already defined on VT ${CHECKVT:-7}, not starting"
150 return 1
151 fi
152 fi
153 fi
154
155 /etc/X11/startDM.sh
156 eend 0
157 }
158
159 stop() {
160 local retval=0
161 local curvt=
162 if [ -t 0 ] ; then
163 if type fgconsole >/dev/null 2>/dev/null ; then
164 curvt="$(fgconsole 2>/dev/null)"
165 else
166 curvt="$(tty)"
167 case "${curvt}" in
168 /dev/ttyv[0-9]*) curvt="${curvt#/dev/ttyv*}" ;;
169 *) curvt= ;;
170 esac
171 fi
172 fi
173 local myexe="$(get_options "service")"
174 local myname="$(get_options "name")"
175 local mypidfile="$(get_options "pidfile")"
176 local myservice=${myexe##*/}
177
178 [ -z "${myexe}" ] && return 0
179
180 ebegin "Stopping ${myservice}"
181
182 if start-stop-daemon --quiet --test --stop --exec "${myexe}" ; then
183 start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
184 ${mypidfile:+--pidfile} ${mypidfile} \
185 ${myname:+--name} ${myname}
186 retval=$?
187 fi
188
189 # switch back to original vt
190 if [ -n "${curvt}" ] ; then
191 if type chvt >/dev/null 2>/dev/null ; then
192 chvt "${curvt}"
193 else
194 vidcontrol -s "$((${curvt} + 1))"
195 fi
196 fi
197
198 eend ${retval} "Error stopping ${myservice}"
199 return ${retval}
200 }
201
202 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20