diff --git a/Dockerfile b/Dockerfile index 7fc0e18..d542eea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,10 +27,11 @@ ENV SSH_HOST="" ENV SSH_PATH="" #only set these variables, if you need FTP upload: -ENV FTP_USER="scanner" -ENV FTP_PASSWORD="scanner" -ENV FTP_HOST="ftp.mydomain.com" -ENV FTP_PATH="/" +ENV FTP_USER="" +ENV FTP_PASSWORD="" +ENV FTP_HOST="" +# Make sure this ends in a slash. +ENV FTP_PATH="/scans/" EXPOSE 54925 EXPOSE 54921 diff --git a/script/scanRear.sh b/script/scanRear.sh old mode 100644 new mode 100755 index a524d36..bb5c61f --- a/script/scanRear.sh +++ b/script/scanRear.sh @@ -71,6 +71,13 @@ fi ( curl -F "userfile=@/scans/$date.pdf" -H "Expect:" -o /scans/$date-ocr.pdf localhost:32800/ocr.php /opt/brother/scanner/brscan-skey/script/trigger_inotify.sh $SSH_USER $SSH_PASSWORD $SSH_HOST $SSH_PATH $date-ocr.pdf + + /opt/brother/scanner/brscan-skey/script/sendtoftps.sh \ + "${FTP_USER}" \ + "${FTP_PASSWORD}" \ + "${FTP_HOST}" \ + "${FTP_PATH}" \ + "${date}.pdf" ) & ) & -) & \ No newline at end of file +) & diff --git a/script/scantofile-0.2.4-1.sh b/script/scantofile-0.2.4-1.sh index ffa0bc5..fdd74a5 100755 --- a/script/scantofile-0.2.4-1.sh +++ b/script/scantofile-0.2.4-1.sh @@ -53,8 +53,14 @@ fi ( curl -F "userfile=@/scans/$date.pdf" -H "Expect:" -o /scans/$date-ocr.pdf localhost:32800/ocr.php /opt/brother/scanner/brscan-skey/script/trigger_inotify.sh $SSH_USER $SSH_PASSWORD $SSH_HOST $SSH_PATH $date-ocr.pdf + /opt/brother/scanner/brscan-skey/script/sendtoftps.sh \ + "${FTP_USER}" \ + "${FTP_PASSWORD}" \ + "${FTP_HOST}" \ + "${FTP_PATH}" \ + "${date}.pdf" ) & ) & ) & echo $! > scan_pid -echo "conversion process for $date is running in PID: "$(cat scan_pid) \ No newline at end of file +echo "conversion process for $date is running in PID: "$(cat scan_pid) diff --git a/script/scantoimage-0.2.4-1.sh b/script/scantoimage-0.2.4-1.sh index 90443ba..97a7939 100755 --- a/script/scantoimage-0.2.4-1.sh +++ b/script/scantoimage-0.2.4-1.sh @@ -32,3 +32,10 @@ gm convert /scans/$date-page*.pnm /scans/$date.pdf rm /scans/$date-page*.pnm /opt/brother/scanner/brscan-skey/script/trigger_inotify.sh $SSH_USER $SSH_PASSWORD $SSH_HOST $SSH_PATH $date.pdf + +/opt/brother/scanner/brscan-skey/script/sendtoftps.sh \ + "${FTP_USER}" \ + "${FTP_PASSWORD}" \ + "${FTP_HOST}" \ + "${FTP_PATH}" \ + "${date}.pdf" diff --git a/script/scantoocr-0.2.4-1.sh b/script/scantoocr-0.2.4-1.sh index a0a7725..b21486a 100755 --- a/script/scantoocr-0.2.4-1.sh +++ b/script/scantoocr-0.2.4-1.sh @@ -32,3 +32,10 @@ gm convert /scans/$date-page*.pnm /scans/$date.pdf rm /scans/$date-page*.pnm /opt/brother/scanner/brscan-skey/script/trigger_inotify.sh "${SSH_USER}" "${SSH_PASSWORD}" "${SSH_HOST}" "${SSH_PATH}" "${date}.pdf" + +/opt/brother/scanner/brscan-skey/script/sendtoftps.sh \ + "${FTP_USER}" \ + "${FTP_PASSWORD}" \ + "${FTP_HOST}" \ + "${FTP_PATH}" \ + "${date}.pdf" diff --git a/script/sendtoftps.sh b/script/sendtoftps.sh new file mode 100755 index 0000000..f2106ec --- /dev/null +++ b/script/sendtoftps.sh @@ -0,0 +1,28 @@ +user=$1 +password=$2 +address=$3 +filepath=$4 +file=$5 + +cd /scans + +if [ -z "${user}" ] || [ -z "${password}" ] || [ -z "${address}" ] || [ -z "${filepath}" ] || [ -z "${file}" ]; then + echo "FTP environment variables not set, skipping inotify trigger." +else + if curl --silent \ + --show-error \ + --ssl-reqd \ + --user "${user}:${password}" \ + --upload-file "${file}" \ + "ftp://${address}${filepath}" ; then + echo "Uploading to ftp server ${address} successful." + else + echo "Uploading to ftp failed while using curl" + echo "user: ${user}" + echo "address: ${address}" + echo "filepath: ${filepath}" + echo "file: ${file}" + exit 1 + fi +fi +