Add ability to create users from environment variables
This commit is contained in:
parent
53ab5fdbad
commit
9f31e8d6c1
@ -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
14
entrypoint.sh
Normal 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
|
Reference in New Issue
Block a user