mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
Docker: create UNIX group on demand
This commit is contained in:
parent
4004496e89
commit
4c42851c53
@ -158,7 +158,7 @@ RUN export LATEST="$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packe
|
|||||||
|
|
||||||
# Allow password-less 'sudo' for all users in group 'sudo'
|
# Allow password-less 'sudo' for all users in group 'sudo'
|
||||||
RUN sed "s/^%sudo.*/%sudo\tALL=(ALL) NOPASSWD:ALL/g" -i /etc/sudoers && \
|
RUN sed "s/^%sudo.*/%sudo\tALL=(ALL) NOPASSWD:ALL/g" -i /etc/sudoers && \
|
||||||
chmod a+s /usr/sbin/useradd /usr/sbin/gosu /usr/sbin/usermod
|
chmod a+s /usr/sbin/useradd /usr/sbin/groupadd /usr/sbin/gosu /usr/sbin/usermod
|
||||||
|
|
||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
|||||||
@ -18,8 +18,13 @@ fi
|
|||||||
# Notify user about selected UID/GID
|
# Notify user about selected UID/GID
|
||||||
echo "Current UID/GID: $NEW_UID/$NEW_GID"
|
echo "Current UID/GID: $NEW_UID/$NEW_GID"
|
||||||
|
|
||||||
useradd --shell /bin/bash -u $NEW_UID -g $NEW_GID -o -m $USER_NAME
|
# Create UNIX group on the fly if it does not exist
|
||||||
usermod -aG sudo $USER_NAME
|
if ! grep -q $NEW_GID /etc/group; then
|
||||||
|
groupadd --gid $NEW_GID $USER_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
useradd --shell /bin/bash --uid $NEW_UID --gid $NEW_GID --non-unique --create-home $USER_NAME
|
||||||
|
usermod --append --groups sudo $USER_NAME
|
||||||
sudo chown $NEW_UID:$NEW_GID /home/$USER_NAME
|
sudo chown $NEW_UID:$NEW_GID /home/$USER_NAME
|
||||||
export HOME=/home/$USER_NAME
|
export HOME=/home/$USER_NAME
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user