Skip to content

Commit

Permalink
Merge pull request #8 from cwiggs/add_ftps
Browse files Browse the repository at this point in the history
Add ftps
  • Loading branch information
PhilippMundhenk authored Aug 5, 2023
2 parents 90f32ca + d316933 commit 367e06f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion script/scanRear.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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"
) &
) &
) &
) &
8 changes: 7 additions & 1 deletion script/scantofile-0.2.4-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
echo "conversion process for $date is running in PID: "$(cat scan_pid)
7 changes: 7 additions & 0 deletions script/scantoimage-0.2.4-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 7 additions & 0 deletions script/scantoocr-0.2.4-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
28 changes: 28 additions & 0 deletions script/sendtoftps.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 367e06f

Please sign in to comment.