summaryrefslogtreecommitdiffstats
path: root/redhat/core/tdebase/xdm.oss114
blob: aabe4afb3ecb05074eed6a3e7ee40f3a3d5ce61d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
#! /bin/bash
# Copyright (c) 1996-2002 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Florian La Roche, 1996
#	  Werner Fink <werner@suse.de>, 1996,98,99
#         Martin Scherbaum, 1997
#         Reinhard Max <max@suse.de>, 1997
#
# Please send feedback to http://www.suse.de/feedback
#
# /etc/init.d/xdm
#
### BEGIN INIT INFO
# Provides:          xdm
# Required-Start:    $remote_fs dbus
# Required-Stop:     $remote_fs
# Should-Start: ypbind $syslog gpm firstboot kbd resmgr earlyxdm winbind acpid ntp
# Should-Stop:  ypbind $syslog gpm firstboot kbd resmgr earlyxdm winbind acpid ntp
# Default-Start:     5
# Default-Stop:
# Description:       X Display Manager
### END INIT INFO

. /etc/rc.status
. /etc/sysconfig/displaymanager
. /etc/sysconfig/language
. /etc/sysconfig/windowmanager
test -e /etc/SuSEconfig/profile        && . /etc/SuSEconfig/profile
test -r /etc/profile.d/desktop-data.sh && . /etc/profile.d/desktop-data.sh

locale_vars="     \
LANG              \
LC_CTYPE          \
LC_NUMERIC        \
LC_TIME           \
LC_COLLATE        \
LC_MONETARY       \
LC_MESSAGES       \
LC_PAPER          \
LC_NAME           \
LC_ADDRESS        \
LC_TELEPHONE      \
LC_MEASUREMENT    \
LC_IDENTIFICATION \
LC_ALL"

unset LC_ALL
for lc in $locale_vars
do
    eval val="\$RC_$lc"
    if test -n "$val"; then
        eval $lc="\$RC_$lc"
        export $lc
    fi
done
unset lc val

if test -z "$WINDOWMANAGER" ; then
    SAVEPATH=$PATH
    PATH=$PATH:/usr/X11R6/bin:/usr/openwin/bin
    desktop=/usr/share/xsessions/${DEFAULT_WM}.desktop
    if test -s "$desktop" ; then
        while read -r line; do
            case ${line} in
            Exec=*) WINDOWMANAGER="$(command -v ${line#Exec=})"
                    break
            esac
        done < $desktop
    fi
    if test -n "$DEFAULT_WM" -a -z "$WINDOWMANAGER" ; then
        WINDOWMANAGER="$(command -v ${DEFAULT_WM##*/})"
    fi
    PATH=$SAVEPATH
    unset SAVEPATH desktop
fi
unset DEFAULT_WM
export WINDOWMANAGER

XDM_PIDFILE="/var/run/xdm.pid"
KDM_PIDFILE="/var/run/kdm.pid"
TDM_PIDFILE="/var/run/tdm.pid"
GDM_PIDFILE="/var/run/gdm.pid"
SLIM_PIDFILE="/var/run/slim.lock"
LXDM_PIDFILE="/var/run/lxdm.pid"
ENTRANCE_PIDFILE="/var/run/entrance.pid"
PIDFILE=$XDM_PIDFILE
KDEROOTHOME=/root/.kdm
export KDEROOTHOME
XDMDIR=/etc/X11/xdm
if [ -x /usr/bin/xdm ]; then
  XDM_BIN=/usr/bin/xdm
else
  XDM_BIN=/usr/X11R6/bin/xdm
fi
if [ -x /usr/sbin/gdm ]; then
  GDM_BIN=/usr/sbin/gdm
else
  GDM_BIN=/opt/gnome/sbin/gdm
fi
KDM_BIN=/opt/kde3/bin/kdm
TDM_BIN=/opt/trinity/bin/kdm
KDM4_BIN=/usr/bin/kdm
WDM_BIN=/usr/bin/wdm
SLIM_BIN=/usr/bin/slim
LXDM_BIN=/usr/bin/lxdm
ENTRANCE_BIN=/usr/sbin/entranced
RELOADSIGNAL="-HUP"

DM=${DISPLAYMANAGER##*/}

case "${DM}" in
    kdm3)		 DISPLAYMANAGER=$KDM_BIN
			 PIDFILE=$KDM_PIDFILE
			 ;;
    tdm)		 DISPLAYMANAGER=$TDM_BIN
			 PIDFILE=$TDM_PIDFILE
			 ;;
    kdm|kde|KDM|KDE)	 DISPLAYMANAGER=$KDM_BIN
			 if [ ! -r "$DISPLAYMANAGER" ]; then
				DISPLAYMANAGER=$KDM4_BIN
			 fi
			 PIDFILE=$KDM_PIDFILE
			 ;;
    kdm4)                DISPLAYMANAGER=$KDM4_BIN
			 PIDFILE=$KDM_PIDFILE
			 ;;
    xdm)		 DISPLAYMANAGER=$XDM_BIN
			 ;;
    gdm|GDM|Gnome|GNOME) DISPLAYMANAGER=$GDM_BIN
			 PIDFILE=$GDM_PIDFILE
			 RELOADSIGNAL="-USR1"
			 ;;
    wdm|WDM)		 DISPLAYMANAGER=$WDM_BIN
			 ;;
    slim|SLIM)		 DISPLAYMANAGER=$SLIM_BIN
			 XDMOPTIONS=-d
			 PIDFILE=$SLIM_PIDFILE
			 ;;
    lxdm|LXDM)		 DISPLAYMANAGER=$LXDM_BIN
			 XDMOPTIONS=-d
			 PIDFILE=$LXDM_PIDFILE
			 ;;
    entrance)
			 DISPLAYMANAGER=$ENTRANCE_BIN
			 PIDFILE=$ENTRANCE_PIDFILE
			 ;;
    console)		 exit 0
			 ;;
    *)			 DISPLAYMANAGER=$XDM_BIN
			 if test -x $KDM_BIN; then
				DISPLAYMANAGER=$KDM_BIN
				PIDFILE=$KDM_PIDFILE
			 elif test -x $KDM4_BIN; then
				DISPLAYMANAGER=$KDM4_BIN
				PIDFILE=$KDM_PIDFILE
			 fi 
			 ;;
esac
test ! -x "$DISPLAYMANAGER" && DISPLAYMANAGER=$XDM_BIN

rc_reset

splashcopy()
{
    local from=$1
    local to=$2
    if [ "$SPLASH" = yes ]
    then
	ver=$(sed "s/.*v\([[:digit:]]\)\.\([[:digit:]]\).*/\\1\\2/" /proc/splash)
	if [ $ver -gt 31 ]
	then
	    echo "copy $from $to" > /proc/splash
	    echo "@$to silent" > /proc/splash
	    echo "@$to show -1" > /proc/splash
	fi
    fi
}

case "$1" in
    start)
	if [ "$DISPLAYMANAGER" = "$KDM4_BIN" ] \
	    || [ "$DISPLAYMANAGER" = "$GDM_BIN" ]; then
	    splashcopy 0 6
	fi
        # Avoid duplicated messages when earlyxdm is in use
	if [ "$DISPLAYMANAGER" = "$KDM_BIN" -a -s $KDM_PIDFILE ]; then
	   /sbin/checkproc -p $KDM_PIDFILE $KDM_BIN && rc_exit 0
	elif [ "$DISPLAYMANAGER" = "$TDM_BIN" -a -s $TDM_PIDFILE ]; then
	   /sbin/checkproc -p $TDM_PIDFILE $TDM_BIN && rc_exit 0
	elif [ "$DISPLAYMANAGER" = "$KDM4_BIN" -a -s $KDM_PIDFILE ]; then
	   /sbin/checkproc -p $KDM_PIDFILE $KDM4_BIN && rc_exit 0
	elif [ "$DISPLAYMANAGER" = "$GDM_BIN" -a -s $GDM_PIDFILE ]; then
	   /sbin/checkproc -p $GDM_PIDFILE $GDM_BIN && rc_exit 0
	elif [ "$DISPLAYMANAGER" = "$ENTRANCE_BIN" -a -s $ENTRANCE_PIDFILE ]; then
	   /sbin/checkproc -p $ENTRANCE_PIDFILE $ENTRANCE_BIN && rc_exit 0
	fi

        if [ "$DISPLAYMANAGER" != "$KDM_BIN" -a \
             "$DISPLAYMANAGER" != "$TDM_BIN" -a \
             "$DISPLAYMANAGER" != "$KDM4_BIN" -a \
             "$DISPLAYMANAGER" != "$ENTRANCE_BIN" -a \
             "$DISPLAYMANAGER" != "$GDM_BIN" ]; then
           test -x /etc/X11/xdm/SuSEconfig.xdm && \
           MD5DIR="/var/adm/SuSEconfig/md5" \
              /etc/X11/xdm/SuSEconfig.xdm | \
              sed 's+\(.*\)+/etc/init.d/xdm: \1+g' | \
              /bin/logger
        fi        

	# use system keyboard as global X keyboard configuration
	if [ -x /etc/X11/xdm/keytable ]; then
	   /etc/X11/xdm/keytable
	fi

	echo -n "Starting service $DM"
	# Don't start xdm if no Xserver is configured and xdm is not 
	# configured for remote access 
	if [ ! -x /usr/bin/X -a ! -x /usr/X11R6/bin/X -a \
		"$DISPLAYMANAGER_REMOTE_ACCESS" = "no" ]; then 
			rc_status -u 
			rc_exit 
	fi
	if [ "$DISPLAYMANAGER" = "$GDM_BIN" -a \
		 "$DISPLAYMANAGER_REMOTE_ACCESS" = "yes"  -a \
		 "$DISPLAYMANAGER_STARTS_XSERVER" = "no" ]; then
		XDMOPTIONS="--no-console"
	fi
	# Graphical failsafe mode (Bug #246158).
	#
	# Needs changes in kernel commandline of "Failsafe" entry in
	# /boot/grub/menu.lst.
	#
	#  * use the same "vga" option value as in the non-"Failsafe" entry
	#  * remove "3" option (runlevel)
	#  * add "x11failsafe" option
	if cat /proc/cmdline | grep -q x11failsafe; then
            if [ -f /etc/X11/xorg.conf.install ]; then
		export XORGCONFIG=xorg.conf.install
                echo 
                echo "Using failsafe X.Org configuration /etc/X11/xorg.conf.install"
            else
                echo
                echo "The failsafe X.Org configuration /etc/X11/xorg.conf.install no longer exists."
                echo "Either move it back (if still available) or copy /etc/X11/xorg.conf to"
                echo "/etc/X11/xorg.conf.install to use the native graphics driver instead of the"
                echo "failsafe graphics driver. Of course the latter option no longer can be called"
                echo "failsafe."
                rc_status -u
                rc_exit
            fi
	fi
	startproc -p $PIDFILE $DISPLAYMANAGER $XDMOPTIONS || rc_failed
	# After a crash or a kill signal we may have
	# a wrong owner ship of /dev/xconsole
	if rc_status ; then
	    if test -x $XDMDIR/TakeDevices ; then
		$XDMDIR/TakeDevices
	    else
		chown root:tty /dev/xconsole /dev/tty0
		chmod 622      /dev/xconsole /dev/tty0
	    fi
	else
	    case "${DM}" in
	    slim|SLIM)
		test -s $PIDFILE || pgrep -f $DISPLAYMANAGER > $PIDFILE
	    esac
	fi
	rc_status -v
	;;
    stop)
        # make sure to stop the running one (Bug #306035)
	if test -s "$KDM_PIDFILE"; then
	    PIDFILE=$KDM_PIDFILE
	elif test -s "$TDM_PIDFILE"; then
	    PIDFILE=$TDM_PIDFILE
	elif test -s "$GDM_PIDFILE"; then
	    PIDFILE=$GDM_PIDFILE
	elif test -s "$XDM_PIDFILE"; then
	    PIDFILE=$XDM_PIDFILE
	elif test -s "$SLIM_PIDFILE"; then
	    PIDFILE=$SLIM_PIDFILE
	elif test -s "$LXDM_PIDFILE"; then
	    PIDFILE=$LXDM_PIDFILE
	elif test -s "$ENTRANCE_PIDFILE"; then
	    PIDFILE=$ENTRANCE_PIDFILE
	fi
	if test -s $PIDFILE; then
	    read -t 1 PID < $PIDFILE
	    if CHECKDM=$(ps ho command= -p $PID) ; then
		DISPLAYMANAGER=${CHECKDM%%[[:blank:]]*}
		DM=${DISPLAYMANAGER##*/}
	    fi
	    unset CHECKDM
	else
	    rm -f $PIDFILE
	    unset PIDFILE
	fi
	echo -n "Shutting down service $DM"

	# 
	# killproc(8) sleep upto five seconds and sends
	# SIGKILL if xdm does not terminate within
	#

	killproc ${PIDFILE:+-p ${PIDFILE}} $DISPLAYMANAGER
	rc_status -v
	;;
    restart)
	$0 stop
        $0 start
	rc_status
	;;
    reload|force-reload)
        test -x /etc/X11/xdm/SuSEconfig.xdm && \
        MD5DIR="/var/adm/SuSEconfig/md5" \
          /etc/X11/xdm/SuSEconfig.xdm | \
          sed 's+\(.*\)+/etc/init.d/xdm: \1+g' | \
          /bin/logger
	echo -n "Reload service $DM"
	killproc -p $PIDFILE $RELOADSIGNAL $DISPLAYMANAGER
	rc_status -v
	;;
    status|check)
	echo -n "Checking for service ${DM}: "
	checkproc -p $PIDFILE $DISPLAYMANAGER
	rc_status -v
	;;
    probe)
	if test $XDMDIR/xdm-config -nt $PIDFILE -o \
	        $XDMDIR/Xservers   -nt $PIDFILE
	then
	    echo reload
	fi
	;;
    try-restart|condrestart)
	$0 status
	if test $? = 0; then
	    $0 restart
	else
	    rc_reset
	fi
	rc_status
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload|force-reload|probe|try-restart}"
	exit 1
esac
rc_exit