Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add_ftps
Browse files Browse the repository at this point in the history
  • Loading branch information
cwiggs committed Aug 3, 2023
2 parents f761e97 + 90f32ca commit d316933
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
name: Create and publish a Docker image

# Configures this workflow to run every time a change is pushed to the branch called `master`.
on:
push:
branches: ['master']

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ENV MODEL="MFC-L2700DW"
ENV IPADDRESS="192.168.1.123"
ENV USERNAME="NAS"

#only set these variables, if inotify needs to be triggered (e.g., for CloudStation):
#only set these variables, if inotify needs to be triggered (e.g., for Synology Drive):
ENV SSH_USER=""
ENV SSH_PASSWORD=""
ENV SSH_HOST=""
Expand Down
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,35 @@ You can configure the tool via environment variables. The following are required
| MODEL | Model of your scanner (see Supported Models) |
| IPADDRESS | IP Address of your scanner |

You may also want to mount a directory to retrieve your data. Scanned files are stored in /root/brscan.
### Docker Example
```bash
docker run \
-d \
-v "/home/$USER/scans:/scans" \
-v "$PWD/script:/opt/brother/scanner/brscan-skey/script/" \
-e NAME="Scanner" \
-e MODEL="MFC-L2700DW" \
-e IPADDRESS="10.0.0.1" \
--net=host \
ghcr.io/philippmundhenk/brotherscannerdocker:master
```

See run.sh for example how to use environment variables and mounts.
### Docker Compose Example
```yaml
version: '3'

services:
brother-scanner:
image: ghcr.io/philippmundhenk/brotherscannerdocker:master
volumes:
- /var/docker/brotherscanner/scans:/scans
environment:
- NAME=Scanner
- MODEL=MFC-L2700DW
- IPADRESS=192.168.44.26
restart: unless-stopped
network_mode: "host"
```
## Customize
As the standard scripts are not working particularly well, you may customize them to your needs.
Expand All @@ -28,7 +54,8 @@ drivers will call these scripts. Each script corresponds to a shortcut button on
you can customize the actions running on your scanner. Hint: These scripts don't necessarily need to do
scanning tasks. You can add any shell script here.
You may mount the scripts like this:
-v $PWD/script/:/opt/brother/scanner/brscan-skey/script/
-v "$PWD/script/:/opt/brother/scanner/brscan-skey/script/"
## FTPS upload
In addition to the storage in the mounted volume, you can use FTPS (Secure FTP) Upload.
Expand Down
9 changes: 8 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
docker run -d -v /home/$USER/scans:/scans -v script:/opt/brother/scanner/brscan-skey/script/ -e "NAME=Scanner" -e "MODEL=MFC-L2700DW" -e "IPADDRESS=192.168.1.123" --net=host brother
docker run \
-d \
-v "/home/$USER/scans:/scans" \
-v "$PWD/script:/opt/brother/scanner/brscan-skey/script/" \
-e NAME="Scanner" \
-e MODEL="MFC-L2700DW" \
-e IPADDRESS="10.0.0.1" \
--net=host brother-scanner
14 changes: 7 additions & 7 deletions script/trigger_inotify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ file=$5

if [ -z "${user}" ] || [ -z "${password}" ] || [ -z "${address}" ] || [ -z "${filepath}" ]; then
echo "SSH environment variables not set, skipping inotify trigger."
exit 1
fi

if sshpass -p "$password" ssh -o StrictHostKeyChecking=no $user@$address "sed \"\" -i $filepath/$file"; then
echo "trigger inotify successful"
else
echo "trigger inotify failed"
exit 1
if sshpass -p "$password" ssh -o StrictHostKeyChecking=no $user@$address "sed \"\" -i $filepath/$file"; then
echo "trigger inotify successful"
else
echo "trigger inotify failed"
exit 1
fi
fi

0 comments on commit d316933

Please sign in to comment.