From 77acdcdf2611ef92b18de872ba53fff58975da84 Mon Sep 17 00:00:00 2001 From: Wanjohi <71614375+wanjohiryan@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:37:59 +0300 Subject: [PATCH] Fix user password error on boot (#111) --- docker/base/Dockerfile | 14 +++++--------- docker/base/entrypoint.sh | 9 ++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 7fe8809..f6457cf 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -55,8 +55,7 @@ ENV LC_ALL en_US.UTF-8 ENV TZ UTC ARG USERNAME=admin -ARG USER_UID=1000 -ARG USER_GID=${USER_UID} +ENV PASSWD=admin # # Add dependencies @@ -110,9 +109,8 @@ RUN apt-get update; \ # #create a non-root user # - groupadd --gid ${USER_GID} ${USERNAME}; \ - useradd --uid ${USER_UID} --gid ${USERNAME} --shell /bin/bash --create-home ${USERNAME};\ - usermod -a -G adm,audio,input,pulse-access,sudo,tape,tty,video,ffmpeg ${USERNAME} ;\ + useradd --create-home --shell /bin/bash ${USERNAME};\ + usermod -a -G adm,audio,input,pulse-access,sudo,tape,tty,video,ffmpeg ${USERNAME};\ # #Remove sudo password echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; \ @@ -121,9 +119,7 @@ RUN apt-get update; \ # mkdir -p /certs /scripts /media;\ chmod 1777 /certs /scripts /media; \ - chown ${USERNAME} /certs /media /scripts; \ - chown -R $USERNAME:$USERNAME /home/${USERNAME} ;\ - ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone + chown ${USERNAME} /certs /media /scripts # # Disable systemd services/units that are unnecessary within a container. @@ -145,7 +141,7 @@ RUN apt-get update -y && apt-get install -y curl; \ # Add user "admin" to the Docker group # groupadd docker; \ - usermod -a -G docker $USERNAME; \ + usermod -a -G docker ${USERNAME}; \ newgrp docker ADD https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker /etc/bash_completion.d/docker.sh diff --git a/docker/base/entrypoint.sh b/docker/base/entrypoint.sh index fa9c680..f7f6115 100644 --- a/docker/base/entrypoint.sh +++ b/docker/base/entrypoint.sh @@ -1,6 +1,13 @@ #!/bin/bash -#Create directories for selkies-js-interposer +# Make user directory owned by the user in case it is not +chown -R $USER:$USER /home/$USER + +# Change operating system password to environment variable +echo "$USER:$PASSWD" | sudo chpasswd + +# Change time zone from environment variable +sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone > /dev/null export DISPLAY="${DISPLAY:-:0}"