aboutsummaryrefslogtreecommitdiffstats
path: root/prefdm
blob: 2b5584ed560a8011ea0a33aba3187fbd87536953 (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
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin

# shut down any graphical boot that might exist
if [ -x /usr/bin/rhgb-client ]; then
    /usr/bin/rhgb-client -quit
fi

# We need to source this so that the login screens get translated
[ -f /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh

# Run preferred X display manager
preferred=
if [ -f /etc/sysconfig/desktop ]; then
	. /etc/sysconfig/desktop
	if [ "$DISPLAYMANAGER" = GNOME ]; then
		preferred=gdm
	elif [ "$DISPLAYMANAGER" = KDE ]; then
		preferred=kdm
	elif [ "$DISPLAYMANAGER" = XDM ]; then
	        preferred=xdm
        elif [ -n "$DISPLAYMANAGER" ]; then
		preferred=$DISPLAYMANAGER
	fi
fi

shopt -s execfail

# If we're in early-login mode and something is running, bail out
if grep -q early-login /proc/cmdline 2> /dev/null ; then
	if [ -n "$preferred" ]; then
		pidof $preferred >/dev/null 2>&1 && exit 0
	fi
	pidof gdm-binary >/dev/null 2>&1 && exit 0
	pidof kdm >/dev/null 2>&1 && exit 0
	pidof xdm >/dev/null 2>&1 && exit 0
fi

if [ -n "$preferred" ]; then
	$preferred "$@" >/dev/null 2>&1
	if [ $? -ne 127 ]; then
		exec $0 "$@"
		exit $?
	fi
fi

# Fallbacks, in order
gdm "$@" >/dev/null 2>&1
if [ $? -ne 127 ]; then
	exec $0 "$@"
	exit $?
fi
kdm "$@" >/dev/null 2>&1
if [ $? -ne 127 ]; then
	exec $0 "$@"
	exit $?
fi
xdm "$@" >/dev/null 2>&1
if [ $? -ne 127 ]; then
	exec $0 "$@"
	exit $?
fi

# catch all exit error
exit 1