#!/bin/bash
#
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: scripts/Create-ParaStatus
# Copyright (C) 2004 - 2005 The T2 SDE Project
# Copyright (C) 1998 - 2003 ROCK Linux Project
# 
# More information can be found in the files COPYING and README.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---

config=default
 
while [ "$1" ] ; do
        case "$1" in
                -cfg)   config=$2 ; shift ; shift ;;
                *)      echo "Usage: $0 [ -cfg config ]" ; exit 1 ;;
        esac
done    

. scripts/parse-config
qdir="$base/build/$SDECFG_ID/TOOLCHAIN/queue"

if [ ! -d $qdir ] ; then
        echo
        echo "$qdir:"
        echo "Queue not found! Please start 'Build-Target -cfg $config'"
        echo "first on the master node ..."
        echo
        exit 1
fi

date '+%H:%M %Y-%m-%d:%t--- current status ---' | expand -t20
cat $qdir/*.stat $qdir/*.lock 2> /dev/null | expand -t30
if [ -f $qdir/queue.txt ] ; then
	while read line ; do
		set $line ; cat $qdir/$1-$6.todo 2> /dev/null
	done < $qdir/queue.txt | expand -t30
else
	echo -e 'Queue file not found!\tDisplaying' \
		'all prepared jobs:' | expand -t30
	cat $qdir/*.todo 2> /dev/null | sort -n -r -k9 | expand -t30
fi
date '+%H:%M %Y-%m-%d:%t----------------------' | expand -t20

