#!/bin/sh
# Script to copy release files to wes-haze for subsequent upload
# to our ftp server.

PROGRAM_NAME=`basename $0`
HOST_NAME=`hostname`

# Strip the domain name off
HOST_NAME=${HOST_NAME%%.*}
echo "host=${HOST_NAME}"

usage()
{
    echo "Try \`$PROGRAM_NAME --help' for more information." 1>&2
    exit 1
}

# First try IRIS, then try RDA
for RELEASE_DIR in /usr/sigmet/releases/iris-current \
    /usr/sigmet/releases/rda-current \
    ; do

  if [ -r ${RELEASE_DIR} ] ; then
      echo "Copying files from $RELEASE_DIR"
      COPY_PATHS=`find ${RELEASE_DIR} -type f -follow -print`
      for COPY_PATH in ${COPY_PATHS} ; do
	  echo "Copying: ${COPY_PATH}"
	  COPY_FILE=${COPY_PATH##*/}
	  /usr/sigmet/config_template/pipes/sig_ftp "${COPY_PATH}" /home/operator/uploads/${HOST_NAME}/${COPY_FILE} wes-haze operator xxxxxx
      done
  fi

done

exit 0
