#!/bin/sh
#
# generate a scheduler configuration by parsing the ITWM legacy
# thin client configuration files
#
# $Id:$
# $URL:$
#
# CHP, 2007-12-20
#

DOMAIN=.itwm.fhg.de
S400_CONFIG=/p/slg/slg_priv/SLG-Verwaltung/s400_server.txt

TIMESTAMP=`date +"%Y-%m-%d %H:%M:%S"`

echo "# xdm scheduler configuration"
echo "# generated $TIMESTAMP by $0"
echo " "

echo "# S400 configuration"

# convert exported S400 thin client configuration:
# - replace (duplicate) blank characters by a single space
# - remove windows carriage return characters
# - swap arguments ("server client" -> "client,server")
# - check generated lines for valid syntax
cat $S400_CONFIG | sed "s#$DOMAIN##g" | tr -s '[:blank:]' ' ' | tr -d '\r' | awk '{ print $2 "," $1 }' - | grep -e '^[[:alnum:]]\+,[[:alnum:]]\+$'
