initial commit

This commit is contained in:
Dave Pedu 2016-01-20 20:40:16 -08:00
commit 93abf65efb
7 changed files with 63 additions and 0 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM ubuntu:trusty
RUN apt-get update && \
apt-get install -y samba supervisor && \
groupadd smbusers
ADD start /start
ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf
ADD supervisor_smb.conf /etc/supervisor/conf.d/smb.conf
ADD shares.txt /shares.txt
ADD users.txt /users.txt
EXPOSE 445
ENTRYPOINT ["/start"]

14
README.md Normal file
View File

@ -0,0 +1,14 @@
docker-samba
============
Smbd (for file shares) in a docker container.
* Build: `docker build -t smbd .`
* Run: `docker run -v /host/users.txt:/users.txt -v /host/shares.txt:shares.txt -v /host/sharedir:/mnt/share -p 445 smbd`
Config
------
For users, users.txt should contain colon separated username:password pairs. This file must end with a newline!
For shares, shares.txt is appended to the end of smb.conf at runtime. Shares should be defined here.

6
shares.txt Normal file
View File

@ -0,0 +1,6 @@
[tmp]
path = /tmp
valid users = dave
guest ok = no
writeable = yes
create mask = 0775

22
start Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
trap 'kill $(jobs -p)' EXIT
# append shares to smb conf
cat /shares.txt >> /etc/samba/smb.conf
supervisord &
sleep 5
cat /users.txt | while read line ; do
USER=$(echo $line | cut -d ':' -f 1)
PASS=$(echo $line | cut -d ':' -f 2)
useradd "$USER"
usermod -aG smbusers "$USER"
(echo "$PASS" ; echo "$PASS") | smbpasswd -s -a "$USER"
done
echo "Waiting for $(jobs -p)..."
wait $(jobs -p)

2
supervisor.conf Normal file
View File

@ -0,0 +1,2 @@
[supervisord]
nodaemon=true

3
supervisor_smb.conf Normal file
View File

@ -0,0 +1,3 @@
[program:smbd]
command=/usr/sbin/smbd --foreground
autorestart=true

1
users.txt Normal file
View File

@ -0,0 +1 @@
dave:hello