#!/bin/sh


WWWUTIL="/var/lib/WWWutil"
WWWDBS="/var/lib/WWWutil/qdDBs"
WWWDB=$WWWDBS/WWWutil
WWWPROJECT=Staffroom

QBIN="/usr/local/qddb/bin"
QUERY=$QBIN/query

IFCONFIG=/sbin/ifconfig
RSH=/usr/bin/rsh

echo Content-type: text/html
echo

HEADER="`$QUERY $WWWDB -sep ' ' Name $WWWPROJECT -print Header`"
FOOTER="`$QUERY $WWWDB -sep ' ' Name $WWWPROJECT -print Footer`"
TITLE="Interface configuration"

if [ -x $IFCONFIG ]; then
  if [ $# = 0 ]; then
    printf "$HEADER" "$TITLE" "$TITLE"
    cat <<-EOM

    This is a form for viewing the interface configuration of a host on 
    the local network.
    <P>

    <ISINDEX>

    Enter host or host.dom.ain in your browser's search dialog to view the
    interface configuration at that host.
    <P>
EOM
    printf "$FOOTER"
  else
    host="$1"
    here=`hostname`
    TITLE="$TITLE at $host"
    printf "$HEADER" "$TITLE" "$TITLE"
    echo "<PRE>"
    if [ "$here" = "$host" ]; then
      $IFCONFIG
    else
      $RSH $host $IFCONFIG
    fi
    echo "</PRE>"
    echo "<P>"
    printf "$FOOTER"
  fi
fi
