Improve service configuration

This commit is contained in:
Joe Biellik 2016-05-17 18:32:07 +01:00
parent acc75afb87
commit 04411993d7
4 changed files with 19 additions and 12 deletions

View file

@ -5,6 +5,7 @@ ENV USERNAME samba
ENV GID 1000
ENV GROUP samba
ENV PASSWORD password
ENV CONFIG /config/smb.conf
RUN set -xe \
&& apk add --update --no-progress samba-common-tools samba-server openssl \
@ -22,10 +23,8 @@ RUN set -xe \
&& apk del gpg \
&& rm -rf /tmp/s6-overlay-amd64.tar.gz /tmp/s6-overlay-amd64.tar.gz.sig /root/.gnupg /var/cache/apk/*
COPY samba.s6 /etc/services.d/samba/run
RUN mkdir /config
VOLUME ["/config"]
COPY run.s6 /etc/services.d/samba/run
COPY finish.s6 /etc/services.d/samba/finish
EXPOSE 137/udp 138/udp 139/tcp 445/tcp

3
finish.s6 Normal file
View file

@ -0,0 +1,3 @@
#!/usr/bin/execlineb -S0
s6-svscanctl -t /var/run/s6/services

13
run.s6 Normal file
View file

@ -0,0 +1,13 @@
#!/usr/bin/with-contenv sh
if [ ! -f "${CONFIG}" ]; then
echo "ERROR: You must pass though a Samba config file at \"${CONFIG}\" or change \$CONFIG to the config file path"
exit 1
fi
addgroup -g ${GID} ${GROUP} > /dev/null 2&>1
adduser -S -G ${GROUP} -u ${UID} -H -D ${USERNAME}
echo "${PASSWORD}" | tee - | smbpasswd -s -c "${CONFIG}" -a ${USERNAME}
nmbd --foreground --log-stdout --configfile="${CONFIG}" &
smbd --foreground --log-stdout --configfile="${CONFIG}"

View file

@ -1,8 +0,0 @@
#!/usr/bin/with-contenv sh
addgroup -g ${GID} ${GROUP}
adduser -S -G ${GROUP} -u ${UID} -H -D ${USERNAME}
echo "${PASSWORD}" | tee - | smbpasswd -s -c /config/smb.conf -a ${USERNAME}
nmbd --foreground --log-stdout --configfile=/config/smb.conf &
smbd --foreground --log-stdout --configfile=/config/smb.conf