#!/bin/sh
# this script can be used to upload PS/PDF files to a specific server.
# You have to supply your name, password, the server's address,
# the protocol to use (ftp/http) and the target dir in $UploadURL
#
# examples: ftp://myname:mypasswd@ftp.mydomain.org/uploads
#           http://myname:mypasswd@webdav.mydomain.org/uploads
#
# read the curl documentation to enhance the functionality (eg. how to 
# bypass proxy servers or to prevent others reading your ftp password in
# ps output...)

UploadURL=ftp://myname:mypasswd@ftp.mydomain.org/uploads
CURLOptions="-s -S"

# check whether we should collect debug messages
if [ ${DEBUG} = TRUE ]; then
        exec 2>>${DEBUG_LOG}
else
        exec 2>/dev/null
fi

cd "${TARGET_DIR}"
curl ${CURLOptions} -T `basename "${TARGET_FILE}"` ${UploadURL}
status=$?
if [ ${status} = 0 ]; then
	rm "${TARGET_FILE}"
	echo "$0: upload successful" >&2
else
	echo "$0: upload failed" >&2
fi

exit 0

