home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
TEDdesk
/
reloc.8
/
$TED_DIR
/
bin
/
Xsession
< prev
Wrap
Text File
|
1998-08-19
|
18KB
|
702 lines
#!/bin/ksh
# ###########################################################################
#
# Xsession
#
# TriTeal Enterprise Desktop (TED)
#
# Configuration script for the Login Manager
#
# (c) Copyright 1994 TriTeal Corporation
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
# ************** DO NOT EDIT THIS FILE **************
#
# /usr/dt/bin/Xsession is a factory-default file and will
# be unconditionally overwritten upon subsequent installation.
# Modification is discouraged.
#
# $XConsortium: Xsession.src /main/cde1_maint/7 1995/11/17 14:43:10 gtsang $
#
# @(#)TED Version: TED 4.2 Alpha 99-4200-00
# @(#)TED FileVersion: Xsession: $Id: Xsession.src,v 1.6 1997/11/26 19:37:07 marye Exp $
#
# ###########################################################################
# ###########################################################################
#
#
# This script starts the user's session. It searches for one of three
# types of startup mechanisms, in the following order:
#
# DT existence of CDE DT Session Manager on the system
# XDM "$HOME/.xsession" (executable)
# xinit "$HOME/.x11start" (executable)
#
# If none of these startup mechanisms exist, a default window manager
# and terminal emulator client are started.
#
# ##########################################################################
#
# Variables must be explicitly exported
#
set +a
# ###########################################################################
#
# Initialize session startup logging
#
# ##########################################################################
#
# send startlog setup errors to a temporary log file so problems are easier
# to debug. the file is /var/dt/tmp/<username>_DISPLAY=<display>.
# this works when there are only one or two users obtaining a session from a
# host, but there is a potential to fill up /var (or even use all inodes) if
# there are, say, two hundred users with X terminals trying to obtain
# sessions. so if the file doesn't contain anything, we will remove it below,
# after the startlog has been setup.
#
exec >/var/dt/${USER}_DISPLAY=${DISPLAY} 2>&1
LOGDIR=$HOME/.dt
LOGFILENAME=$LOGDIR/startlog
if [ ! -d $LOGDIR ]; then
\mkdir $LOGDIR
if [ -d $LOGDIR ]; then
\chmod 755 $LOGDIR
fi
fi
[ -f $LOGFILENAME.older ] && \rm -f $LOGFILENAME.older
[ -f $LOGFILENAME.old ] && \mv -f $LOGFILENAME.old $LOGFILENAME.older
[ -f $LOGFILENAME ] && \mv -f $LOGFILENAME $LOGFILENAME.old
\touch $LOGFILENAME
if [ -w $LOGFILENAME ]; then
\exec >>$LOGFILENAME 2>&1
fi
#
# remove the temporary log file used to track startlog setup errors, if and
# only if it is empty.
#
if [ ! -s /var/dt/${USER}_DISPLAY=${DISPLAY} ]
then
\rm /var/dt/${USER}_DISPLAY=${DISPLAY}
fi
Log()
{
echo "--- $1" >>$LOGFILENAME 2>&1
}
Log "$(date)"
Log "$0 starting..."
# ###########################################################################
#
# Global environment section
#
# DT pre-sets the following environment variables for each user.
#
# (internal)
#
# DISPLAY set to the value of the first field in the Xservers file.
# HOME set to the user's home directory (from /etc/passwd)
# LANG set to the display's current NLS language (if any)
# LC_ALL set to the value of $LANG
# LOGNAME set to the user name
# PATH set to the value of the Dtlogin "userPath" resource
# USER set to the user name
# SHELL set to the user's default shell (from /etc/passwd)
# TZ set to the value of the Dtlogin "timeZone" resource
#
#
# (Xsession)
#
# TERM set to xterm
# EDITOR set to the default editor
# KBD_LANG set to the value of $LANG for certain languages
# MAIL set to "/var/mail/$USER"
#
#
# Three methods are available to modify or add to this list depending
# on the desired scope of the resulting environment variable.
#
# 1. X server and/or all users on a display (Xconfig file)
# 2. all users on a display (Xsession file)
# 3. individual users (.dtprofile file)
#
# See DT on-line help, the DT Users Guide, or the Dtlogin(1X) man
# page for details on setting environment variables.
#
#
#
# ###########################################################################
[ -z "$EDITOR" ] && EDITOR=/usr/dt/bin/dtpad
[ -z "$LANG" ] && LANG="C"
TERM=dtterm
set `LANG=C LC_ALL=C /usr/bin/id`
if [ $1 != "uid=0(root)" ]; then
export PATH=/sbin:$PATH
fi
SESSION_SVR=`uname -n`
export PATH EDITOR MAIL TERM SESSION_SVR LANG
if [ -z "$XFILESEARCHPATH" ]
then
XFILESEARCHPATH=/usr/lib/X11/locale/%L/%T/%N%C%S:/usr/lib/X11/locale/%l/%T/%N%C%S:/usr/lib/X11/locale/%L/%T/%N%S:/usr/lib/X11/locale/%l/%T/%N%S:/usr/lib/X11/%L/%T/%N%C%S:/usr/lib/X11/%l/%T/%N%C%S:/usr/lib/X11/%T/%N%C%S:/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%S:/usr/lib/X11/locale/C/%T/%N%C%S:/usr/lib/X11/locale/C/%T/%N%S
export XFILESEARCHPATH
fi
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/X/lib export LD_LIBRARY_PATH
XWINHOME=/usr/X export XWINHOME
DT=no export DT
#
# check if network is configured. If not, set environment variable
# so that tooltalk will use localhost/loopback rather than system
# name
status="1"
netstat -i | awk ' \
{ \
if ( NR > 1 && NF > 1 ) \
{ \
if ( $3 != "loopback" ) \
{ \
if ( ( $3 == "none" && $4 == "none" ) || \
( $3 == "0" && $4 == "0.0.0.0" ) ) \
{ \
#Network is not connected \
exit 0 \
} \
else \
{ \
#Network is connected \
exit 1 \
} \
} \
} \
}'
status=$?
if [ "$status" = "0" ]
then
export DTNONETWORK=true
fi
#
# Locate configuration file directories
#
XDIR="/usr/bin/X11"
DT_BINPATH=/usr/dt/bin
DT_INSTALL_CONFIG=/usr/dt/config
DT_CONFIG=/etc/dt/config
DT_CONFIG_PATH="$DT_CONFIG $DT_INSTALL_CONFIG"
# ###########################################################################
#
# Default desktop component configuration variable settings
#
# This section sets the default value for variables controlling
# some desktop components.
#
# ###########################################################################
#
# Input method server startup
#
if [ -z "$DTSTARTIMS" ]; then
DTSTARTIMS=True
fi
if [ "$DTSTARTIMS" = "False" ]; then
unset DTSTARTIMS
fi
#
# Default desktop screen saver action list
#
export DTSCREENSAVERLIST="StartDtscreenSwarm StartDtscreenQix \
StartDtscreenFlame StartDtscreenHop StartDtscreenImage StartDtscreenLife \
StartDtscreenRotor StartDtscreenPyro StartDtscreenWorm StartDtscreenBlank"
#
# Session startup clients and args
#
if [ "$SESSIONTYPE" = "altDt" ]; then
dtstart_session[0]="$SDT_ALT_SESSION"
dtstart_hello[0]="$SDT_ALT_HELLO"
else
dtstart_session[0]="$DT_BINPATH/dtsession"
dtstart_hello[0]="$DT_BINPATH/dthello &"
fi
dtstart_session[1]="$HOME/.xsession"
dtstart_session[2]="$HOME/.x11start"
dtstart_session[3]="$XBIN/xterm -geometry 80x24+10+10"
dtstart_hello[1]="$XDIR/xsetroot -default &"
dtstart_searchpath="$DT_BINPATH/dtsearchpath -ksh"
dtstart_ttsession="$DT_BINPATH/ttsession -s"
dtstart_dtdbcache="$DT_BINPATH/dtdbcache -init"
dtdbcacherm="rm -f /tmp/dtdbcache_$DISPLAY"
dtstart_appgather="$DT_BINPATH/dtappgather &"
dtstart_dsdm="$DT_BINPATH/dsdm &"
xdmstart_session[0]="$HOME/.xsession"
xdmstart_session[1]="/usr/lib/X11/xdm/Xsession"
xdmstart_session[2]="xterm -geometry 80x24+10+10 -ls"
xdmstart_hello="$XDIR/xsetroot -default &"
SESSIONLOGDIR=$LOGDIR/sessionlogs
SESSIONLOGFILENAME="$SESSIONLOGDIR/$SESSION_SVR"_DISPLAY=$DISPLAY
if [ ! -d $SESSIONLOGDIR ]; then
\mkdir $SESSIONLOGDIR
if [ -d $SESSIONLOGDIR ]; then
\chmod 755 $SESSIONLOGDIR
fi
fi
touch $SESSIONLOGFILENAME
if [ -w $SESSIONLOGFILENAME ]; then
dtstart_sessionlogfile="$SESSIONLOGFILENAME"
else
dtstart_sessionlogfile="/dev/null"
fi
rm -f $SESSIONLOGFILENAME
#
# Determine Xsession parent
#
pexec=$(LC_TIME=C ps -p $PPID | awk 'NR==2 {print $6}')
Log "Xsession started by $pexec"
# ###########################################################################
#
# Append desktop font aliases to font path
#
# ###########################################################################
if [ "${pexec##*/}" != "dtlogin" ]; then
#
# If Xsession launched by dtlogin, it is assumed that the desktop
# font path has already been added by Xsetup, so no need to add it here.
#
$XDIR/xset fp default
#
# Append desktop font paths. Note: these directories should be
# accessable by the X server. The file precedence is:
#
# /etc/dt/config/xfonts/C
# /usr/dt/config/xfonts/C
# /etc/dt/config/xfonts/$LANG
# /usr/dt/config/xfonts/$LANG
#
Log "setting font path..."
if [ "$DTXSERVERLOCATION" != "remote" ]; then
#
# Since X server is local, optimize by checking local desktop
# font directories and making one call to xset.
#
if [ -f /etc/dt/config/xfonts/C/fonts.dir ]; then
fontpath=/etc/dt/config/xfonts/C
fi
if [ -f /usr/dt/config/xfonts/C/fonts.dir ]; then
if [ -z "$fontpath" ]; then
fontpath=/usr/dt/config/xfonts/C
else
fontpath=$fontpath,/usr/dt/config/xfonts/C
fi
fi
if [ "$LANG" != "C" ]; then
if [ -f /etc/dt/config/xfonts/$LANG/fonts.dir ]; then
if [ -z "$fontpath" ]; then
fontpath=/etc/dt/config/xfonts/$LANG
else
fontpath=$fontpath,/etc/dt/config/xfonts/$LANG
fi
fi
fi
if [ "$LANG" != "C" ]; then
if [ -f /usr/dt/config/xfonts/$LANG/fonts.dir ]; then
if [ -z "$fontpath" ]; then
fontpath=/usr/dt/config/xfonts/$LANG
else
fontpath=$fontpath,/usr/dt/config/xfonts/$LANG
fi
fi
fi
if [ ! -z "$fontpath" ]; then
$XDIR/xset fp+ $fontpath
fi
else
#
# Since X server not local, we don't know if the desktop font
# directories exist on the X server machine, so we have to
# set them one at a time.
#
$XDIR/xset fp+ /etc/dt/config/xfonts/C 1>/dev/null
$XDIR/xset fp+ /usr/dt/config/xfonts/C 1>/dev/null
if [ "$LANG" != "C" ]; then
$XDIR/xset fp+ /etc/dt/config/xfonts/$LANG 1>/dev/null
fi
if [ "$LANG" != "C" ]; then
$XDIR/xset fp+ /usr/dt/config/xfonts/$LANG 1>/dev/null
fi
fi
fi
# ###########################################################################
#
# Source user's desktop profile
#
# This section determines if the user has a desktop profile in their
# home directory. If not, the desktop default profile is copied to
# the home directory. The desktop profile is then sourced. The purpose
# is to incorporate any per-user/per-session environment customizations
# and thereby propagate them to applications and desktop components.
#
# ###########################################################################
DTSYSPROFILE=sys.dtprofile
DTPROFILE=.dtprofile
if [ ! -f $HOME/$DTPROFILE ]; then
for i in $DT_CONFIG_PATH
do
if [ -f $i/$DTSYSPROFILE ]; then
/usr/bin/awk '
BEGIN {printit=1}
/SYSPROFILE COMMENT START/ {printit=0; next}
/SYSPROFILE COMMENT END/ {printit=1; next}
printit==1 {print}' <$i/$DTSYSPROFILE >$HOME/$DTPROFILE
/bin/chmod 755 $HOME/$DTPROFILE
break
fi
done
fi
#
# source the .dtprofile.
#
if [ -f $HOME/$DTPROFILE ]; then
Log "sourcing $HOME/$DTPROFILE..."
. $HOME/$DTPROFILE
fi
# ###########################################################################
#
# External Xsession processing section
#
# This section searches the Xsession.d subdirectory and sources
# the files contained therein. The purpose is to set up any
# per-user/per-session environment customizations and thereby propagate
# them to applications and desktop components.
#
# ##########################################################################
DT_XSESSION_DIR=Xsession.d
for i in $DT_CONFIG_PATH
do
if [[ -d $i/$DT_XSESSION_DIR ]]; then
#
# Run custom Xsession scripts for this session.
#
for SCRIPT in $(ls $i/$DT_XSESSION_DIR); do
if [ -x $i/$DT_XSESSION_DIR/$SCRIPT -a \
\( ! -d $i/$DT_XSESSION_DIR/$SCRIPT \) ]; then
Log "sourcing $i/$DT_XSESSION_DIR/$SCRIPT..."
. $i/$DT_XSESSION_DIR/$SCRIPT
fi
done
fi
done
# ###########################################################################
#
# Startup section.
#
# Note: The ksh syntax ${parameter%% *} is used when appropriate to
# remove any command line options that may have been included
# in the definition of a DT executable below.
#
# ###########################################################################
#
# Return first command in array named by $1 that is executable
#
GetFirst()
{
let i=0
while true; do
eval "cmd=\${$1[$i]}"
[ -z "$cmd" ] && break
[ -x "${cmd%% *}" ] && echo "$cmd" && break
Log "could not start $cmd"
let i=$i+1
done
}
#
# Start first command in array named by $1 that is executable. If
# $2 is 'eval', command result will be 'eval'ed.
#
StartFirst()
{
first=$(GetFirst $1)
if [ ! -z "$first" ]; then
Log "starting $first"
if [ "$2" = "eval" ]; then
eval `eval "PATH=$DT_BINPATH:$PATH $first"`
else
eval "PATH=$DT_BINPATH:$PATH $first"
fi
fi
}
#
# Prepare for session startup
#
if [ "$DTSOURCEPROFILE" = "true" ]
then
case ${SHELL##*/} in
sh | ksh | dtksh) shellprofile="$HOME/.profile";;
bash) shellprofile="$HOME/.bash_profile";;
csh | tcsh) shellprofile="$HOME/.login";;
*) Log "non-standard shell $SHELL"
esac
fi
if [ "$shellprofile" -a ! -f "$shellprofile" ]
then
Log "could not read $shellprofile"
unset shellprofile
fi
if [ "$SESSIONTYPE" = "xdm" ]; then
startup=$(GetFirst xdmstart_session) # get xdm session client
StartFirst xdmstart_hello # start xdm hello client
else
startup=$(GetFirst dtstart_session) # get desktop session client
StartFirst dtstart_hello # start desktop hello client
StartFirst dtstart_searchpath eval # setup desktop search paths
_MANPATH=$MANPATH
. /etc/default/man
MANPATH=$MANPATH:$_MANPATH
export MANPATH
tooltalk=$(GetFirst dtstart_ttsession) # get tooltalk client
dtdbcache=$(GetFirst dtstart_dtdbcache) # get dtdbcache client
if [ -z "$SDT_NO_DSDM" ]; then
StartFirst dtstart_dsdm # start drag and drop proxy
fi
StartFirst dtstart_appgather # setup session applications
fi
#
# Start the session.
#
if [ $shellprofile ]; then
Log "execing $startup using $shellprofile..."
source_profile=". $shellprofile"
source_login="source $shellprofile"
else
Log "execing $startup..."
source_profile="echo 'not sourcing $HOME/.profile (see $HOME/.dtprofile)'"
source_login="echo 'not sourcing $HOME/.login (see $HOME/.dtprofile)'"
fi
if [ -z "$dtdbcache" ]; then
dtdbcache="echo could not start $dtstart_dtdbcache"
fi
export DT=true;
case ${SHELL##*/} in
sh | bash) $SHELL -c "$source_profile; \
unset DT; \
$dtdbcache; \
PATH=/usr/dt/bin:\$PATH $tooltalk; \
$startup > $dtstart_sessionlogfile 2>&1" ;;
ksh | dtksh) $SHELL -c "$source_profile; \
unset DT; \
$dtdbcache; \
PATH=/usr/dt/bin:\$PATH $tooltalk;\
$startup >| $dtstart_sessionlogfile 2>&1" ;;
csh | tcsh) $SHELL -c "unsetenv _ PWD; \
$source_login; \
unsetenv DT; \
$dtdbcache; \
(set path = ( $DT_BINPATH \$path ); $tooltalk ); \
$startup >&! $dtstart_sessionlogfile" ;;
*) unset DT
$dtdbcache
StartFirst dtstart_ttsession
$startup >| $dtstart_sessionlogfile 2>&1 ;;
esac
$dtdbcacherm # remove the actions/datatypes cachefile
# #################### eof #################################