Skip to content

Commit

Permalink
initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Biepa committed Sep 11, 2024
1 parent 497cf5c commit cdadea6
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:3.12.12

RUN apk --no-cache --no-progress upgrade && \
apk --no-cache --no-progress add bash tini && \
# SMBv1 protocols were deprecated in 4.13 -> https://www.samba.org/samba/history/samba-4.13.0.html
apk --no-cache --no-progress add samba=4.12.15-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.12/main && \
file="/etc/samba/smb.conf" && \
sed -i 's|^;* *\(log file = \).*| \1/dev/stdout|' $file && \
sed -i '/Share Definitions/,$d' $file && \
echo ' ntlm auth = yes' >>$file && \
echo ' min protocol = LANMAN1' >>$file

EXPOSE 137/udp 138/udp 139 445

COPY ./setup.sh /etc/setup.sh
RUN chmod +x /etc/setup.sh
ENTRYPOINT ["/sbin/tini", "--", "/etc/setup.sh"]
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# docker-smb1
A docker container supporting "scan to share" for older scanners
# Samba container with SMB1 suppport

Some devices like my old printer/scanner (Canon MB5150) only support deprecated protocols to scan to.
This container sets up a network share that it can access.

## Install
1. Clone repo
2. Adjust username, password, share name and the local path on your system
3. Run `docker compose up -d`
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
smb1:
build:
context: .
dockerfile: Dockerfile
container_name: smb-for-scanning
environment:
SMB_USERNAME: example_username
SMB_PASSWORD: example_password
SHARE_NAME: example_sharename
ports:
- "445:445/tcp"
volumes:
- /path/to/local/directory:/share
25 changes: 25 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -o nounset
file="/etc/samba/smb.conf"

adduser -D -H "$SMB_USERNAME"&& echo User "$SMB_USERNAME" was added to the system
echo -e "$SMB_PASSWORD\n$SMB_PASSWORD" | smbpasswd -s -a "$SMB_USERNAME"
smbpasswd -e "$SMB_USERNAME" > /dev/null

if [ ! -d /share ] ; then
mkdir /share
fi
chgrp "$SMB_USERNAME" /share
chown -R "$SMB_USERNAME" /share

echo '' >>$file && \
echo " [$SHARE_NAME]" >>$file && \
echo ' path = /share' >>$file && \
echo ' browsable = yes' >>$file && \
echo ' read only = no' >>$file && \
echo ' guest ok = no' >>$file && \
echo ' veto files = /.apdisk/.DS_Store/.TemporaryItems/.Trashes/desktop.ini/ehthumbs.db/Network Trash Folder/Temporary Items/Thumbs.db/' >>$file && \
echo ' delete veto files = yes' >>$file && \
echo " valid users = $SMB_USERNAME" >>$file

smbd -FS --no-process-group && sleep infinity

0 comments on commit cdadea6

Please sign in to comment.