Browse Source

UID

pull/5/head
Daniel Gibbs 3 years ago
parent
commit
471e6c0af6
  1. 11
      Dockerfile
  2. 25
      entrypoint.sh

11
Dockerfile

@ -73,16 +73,15 @@ RUN echo "**** Install GameDig ****" \
&& npm install -g gamedig && npm install -g gamedig
ARG USERNAME=linuxgsm ARG USERNAME=linuxgsm
ARG USER_UID=1000 ARG UID=1000
ARG USER_GID=${USER_UID} ARG GID=1000
## Add linuxgsm user ## Add linuxgsm user
RUN echo "**** Add linuxgsm user ****" \ RUN echo "**** Add linuxgsm user ****" \
# Create the user # Create the user
&& groupadd --gid ${USER_GID} ${USERNAME} \ && groupadd --gid ${GID} ${USERNAME} \
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \ && useradd --uid ${UID} --gid ${GID} -m ${USERNAME} \
# && usermod --shell /bin/bash ${USERNAME} \
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \ && echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME} \ && chmod 0440 /etc/sudoers.d/${USERNAME} \
&& chown ${USERNAME}:${USERNAME} /home/${USERNAME} && chown ${USERNAME}:${USERNAME} /home/${USERNAME}

25
entrypoint.sh

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
exit_handler () { exit_handler() {
# Execute the shutdown commands # Execute the shutdown commands
echo "recieved SIGTERM stopping ${GAMESERVER}" echo "recieved SIGTERM stopping ${GAMESERVER}"
./${GAMESERVER} stop ./${GAMESERVER} stop
@ -12,23 +12,24 @@ echo "loading exit trap"
trap exit_handler SIGTERM trap exit_handler SIGTERM
echo "update permissions for linuxgsm" echo "update permissions for linuxgsm"
if [ -z "${USER_UID}" ]; then if [ -z "${UID}" ]; then
USER_UID=1000 UID=1000
fi fi
if [ -z "${USER_GID}" ]; then if [ -z "${GID}" ]; then
USER_GID=1000 GID=1000
fi fi
usermod -u ${USER_UID} linuxgsm sudo usermod -u ${UID} linuxgsm
groupmod -g ${USER_GID} linuxgsm sudo groupmod -g ${GID} linuxgsm
sudo chown -R ${USER_UID}:${USER_GID} /home/linuxgsm sudo chown -R ${UID}:${GID} /home/linuxgsm
reset
echo -e "Welcome to the LinuxGSM Docker" echo -e "Welcome to the LinuxGSM Docker"
echo -e "================================================================================" echo -e "================================================================================"
echo -e "GAMESERVER: ${GAMESERVER}" echo -e "GAMESERVER: ${GAMESERVER}"
echo -e "" echo -e ""
echo -e "USER: $USERNAME" echo -e "USER: ${USERNAME}"
echo -e "UID: ${USER_UID}" echo -e "UID: ${UID}"
echo -e "GID: ${USER_GID}" echo -e "GID: ${GID}"
echo -e "" echo -e ""
echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}"
echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}"
@ -86,7 +87,7 @@ else
# this keeps the container running # this keeps the container running
# when invoked via docker run # when invoked via docker run
# but requires -it or at least -t # but requires -it or at least -t
tmux set -g status off && tmux attach 2> /dev/null tmux set -g status off && tmux attach 2>/dev/null
fi fi
exec "$@" exec "$@"

Loading…
Cancel
Save