diff --git a/Dockerfile b/Dockerfile index d3e3bfb..4adb32a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/finish.s6 b/finish.s6 new file mode 100644 index 0000000..b6531b3 --- /dev/null +++ b/finish.s6 @@ -0,0 +1,3 @@ +#!/usr/bin/execlineb -S0 + +s6-svscanctl -t /var/run/s6/services diff --git a/run.s6 b/run.s6 new file mode 100644 index 0000000..dd727c3 --- /dev/null +++ b/run.s6 @@ -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}" diff --git a/samba.s6 b/samba.s6 deleted file mode 100644 index 89faef7..0000000 --- a/samba.s6 +++ /dev/null @@ -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