You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tde-packaging/redhat/main/tdebase/xdm.oss114

350 lines
9.3 KiB

#! /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