gdmdynamic revision 17862
16742N/A#!/bin/ksh -p
16742N/A
16742N/Ausage () {
16742N/A echo "$0 [options]"
16742N/A echo " -h, --help Display this help"
16742N/A echo " -a display Add a new Sun Ray display"
16742N/A echo " -d display Delete a Sun Ray display"
16742N/A echo " -l List all Sun Ray displays"
16742N/A exit 1
16742N/A}
16742N/A
16742N/AAWK="/usr/gnu/bin/awk"
16742N/ASED="/usr/gnu/bin/sed"
16742N/ASEAT_TOOL="/usr/sbin/ck-seat-tool"
16742N/ALIST_TOOL="/usr/bin/ck-list-sessions"
16742N/AHIST_TOOL="/usr/bin/ck-history"
16742N/A
16742N/Aoptype=""
16742N/Aoparg=""
16742N/A
16742N/Afor i in "$@"
16742N/Ado
16742N/A if [ ! "x$optype" = "x" ]; then
16742N/A oparg=$i
16742N/A break
16742N/A fi
16742N/A if [ "x$i" = "x-h" -o "x$i" = "x--help" ]; then
16742N/A break
16742N/A fi
16742N/A if [ "x$i" = "x-a" ]; then
16742N/A optype="add"
16742N/A continue
16742N/A fi
16742N/A if [ "x$i" = "x-d" ]; then
16742N/A optype="delete"
16742N/A continue
16742N/A fi
16742N/A if [ "x$i" = "x-l" ]; then
16742N/A optype="list"
16742N/A break
16742N/A fi
16742N/Adone
16742N/A
16742N/Acase $optype in
16742N/A add)
16742N/A# gdmdynamic -a 10=/usr/X11/bin/Xorg
oparg=`echo $oparg | awk -F\= '{print $1}'`
seatid=`$HIST_TOOL --last | $AWK -v disp=":$oparg" '{if ($6 == disp) print $N0}' | head -1 | $AWK '{print $4}'`
if [ "x$seatid" = x ]; then
seatid="SunraySeat$oparg"
fi
$SEAT_TOOL -a --display-type=Sunray --seat-id=$seatid display=:$oparg
;;
delete)
# gdmdynamic -d 10
ssid=`$LIST_TOOL -f session-id,x11-display,display-type | grep Sunray | $SED -e s/\'//g | $AWK -v disp=:$oparg '{if ($2 == disp) print $1}'`
if [ ! "x$ssid" = "x" ]; then
$SEAT_TOOL -d --session-id=$ssid
fi
;;
list)
# gdmdynamic -l
sessions=`$LIST_TOOL -f session-id,x11-display,display-type | grep Sunray | $AWK '{print $2}' | $SED -e s/\'//g`
dyps=""
for i in $sessions
do
if [ ! "x$i" = "x" ]; then
dyps="$i;$dyps"
fi
done
echo $dyps
;;
* )
usage
;;
esac