Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ftps #8

Merged
merged 5 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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