#!/bin/sh
# Usage: autobuild-submit < logfile
# or:    autobuild-submit logfile ...
# Submits one or more logfiles for publication on Simon Josefsson's site.

func_submit_stdin ()
{
  netcat -w 5 autobuild.josefsson.org 6789
  result=$?
  sleep 5 # to avoid "Connection refused" in the next submit
}

if test $# = 0; then
  func_submit_stdin
  if test $result != 0; then
    echo "*** FAILED ***" 1>&2
    exit 1
  fi
else
  failed=
  for f
  do
    func_submit_stdin < "$f"
    if test $result != 0; then
      echo "FAILED: $f" 1>&2
      failed="$failed $f"
    fi
  done
  if test -n "$failed"; then
    echo "*** FAILED:$failed" 1>&2
    exit 1
  fi
fi
