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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sat Jun 9 19:49:30 2012 UTC (2 years, 2 months ago) by chithanh
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
Drop vulnerable versions.

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

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

  ViewVC Help
Powered by ViewVC 1.1.20