commit 93abf65efbf36c72b398e86b306cfe1548aacdda Author: Dave Pedu Date: Wed Jan 20 20:40:16 2016 -0800 initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..012e8e3 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d7871c --- /dev/null +++ b/README.md @@ -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. diff --git a/shares.txt b/shares.txt new file mode 100644 index 0000000..9d8b54b --- /dev/null +++ b/shares.txt @@ -0,0 +1,6 @@ +[tmp] + path = /tmp + valid users = dave + guest ok = no + writeable = yes + create mask = 0775 diff --git a/start b/start new file mode 100755 index 0000000..d694efd --- /dev/null +++ b/start @@ -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) diff --git a/supervisor.conf b/supervisor.conf new file mode 100644 index 0000000..54296b8 --- /dev/null +++ b/supervisor.conf @@ -0,0 +1,2 @@ +[supervisord] +nodaemon=true diff --git a/supervisor_smb.conf b/supervisor_smb.conf new file mode 100644 index 0000000..707140d --- /dev/null +++ b/supervisor_smb.conf @@ -0,0 +1,3 @@ +[program:smbd] +command=/usr/sbin/smbd --foreground +autorestart=true diff --git a/users.txt b/users.txt new file mode 100644 index 0000000..028be08 --- /dev/null +++ b/users.txt @@ -0,0 +1 @@ +dave:hello \ No newline at end of file