initial commit
This commit is contained in:
commit
93abf65efb
15
Dockerfile
Normal file
15
Dockerfile
Normal 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
14
README.md
Normal 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
6
shares.txt
Normal file
@ -0,0 +1,6 @@
|
||||
[tmp]
|
||||
path = /tmp
|
||||
valid users = dave
|
||||
guest ok = no
|
||||
writeable = yes
|
||||
create mask = 0775
|
22
start
Executable file
22
start
Executable 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
2
supervisor.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
3
supervisor_smb.conf
Normal file
3
supervisor_smb.conf
Normal file
@ -0,0 +1,3 @@
|
||||
[program:smbd]
|
||||
command=/usr/sbin/smbd --foreground
|
||||
autorestart=true
|
Loading…
Reference in New Issue
Block a user