1

Add ability to create users from environment variables

This commit is contained in:
Vladimir Hodakov 2020-04-18 17:41:46 +04:00
parent 53ab5fdbad
commit 9f31e8d6c1
Signed by: Vladimir Hodakov
GPG Key ID: 673980B6882F82C6
2 changed files with 20 additions and 2 deletions

View File

@ -1,7 +1,11 @@
FROM alpine FROM alpine
MAINTAINER Vladimir Hodakov <vladimir@hodakov.me> MAINTAINER Vladimir Hodakov <vladimir@hodakov.me>
RUN apk add --no-cache samba-common-tools samba-server RUN apk add --no-cache tini bash samba-common-tools samba-server
COPY entrypoint.sh /usr/local/bin/entrypoint
RUN ["chmod", "+x", "/usr/local/bin/entrypoint"]
VOLUME /etc/samba \ VOLUME /etc/samba \
/var/lib/samba \ /var/lib/samba \
@ -12,4 +16,4 @@ EXPOSE 137/udp \
139/tcp \ 139/tcp \
445/tcp 445/tcp
CMD nmbd -D && smbd -FS --no-process-group CMD ["/sbin/tini", "--", "/usr/local/bin/entrypoint"]

14
entrypoint.sh Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
while IFS='=' read -r name value ; do
if [[ $name == 'USER'* ]]; then
IFS=';'
read -ra userParams <<< "${!name}"
echo "Adding user ${userParams[0]}"
adduser --no-create-home --uid "${userParams[2]}" --ingroup "${userParams[1]}" \
--disabled-password "${userParams[0]}"
fi
done < <(env)
nmbd -D
smbd -FS --no-process-group