diff --git a/Dockerfile b/Dockerfile index 108a536..71e8887 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,16 +73,15 @@ RUN echo "**** Install GameDig ****" \ && npm install -g gamedig ARG USERNAME=linuxgsm -ARG USER_UID=1000 -ARG USER_GID=${USER_UID} +ARG UID=1000 +ARG GID=1000 ## Add linuxgsm user RUN echo "**** Add linuxgsm user ****" \ # Create the user - && groupadd --gid ${USER_GID} ${USERNAME} \ - && useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \ - # - # [Optional] Add sudo support. Omit if you don't need to install software after connecting. + && groupadd --gid ${GID} ${USERNAME} \ + && useradd --uid ${UID} --gid ${GID} -m ${USERNAME} \ + && usermod --shell /bin/bash ${USERNAME} \ && echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \ && chmod 0440 /etc/sudoers.d/${USERNAME} \ && chown ${USERNAME}:${USERNAME} /home/${USERNAME} diff --git a/entrypoint.sh b/entrypoint.sh index 1861a74..ff374aa 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,10 @@ #!/bin/bash -exit_handler () { - # Execute the shutdown commands - echo "recieved SIGTERM stopping ${GAMESERVER}" - ./${GAMESERVER} stop - exit 0 +exit_handler() { + # Execute the shutdown commands + echo "recieved SIGTERM stopping ${GAMESERVER}" + ./${GAMESERVER} stop + exit 0 } # Exit trap @@ -12,23 +12,24 @@ echo "loading exit trap" trap exit_handler SIGTERM echo "update permissions for linuxgsm" -if [ -z "${USER_UID}" ]; then - USER_UID=1000 +if [ -z "${UID}" ]; then + UID=1000 fi -if [ -z "${USER_GID}" ]; then - USER_GID=1000 +if [ -z "${GID}" ]; then + GID=1000 fi -usermod -u ${USER_UID} linuxgsm -groupmod -g ${USER_GID} linuxgsm -sudo chown -R ${USER_UID}:${USER_GID} /home/linuxgsm +sudo usermod -u ${UID} linuxgsm +sudo groupmod -g ${GID} linuxgsm +sudo chown -R ${UID}:${GID} /home/linuxgsm +reset echo -e "Welcome to the LinuxGSM Docker" echo -e "================================================================================" echo -e "GAMESERVER: ${GAMESERVER}" echo -e "" -echo -e "USER: $USERNAME" -echo -e "UID: ${USER_UID}" -echo -e "GID: ${USER_GID}" +echo -e "USER: ${USERNAME}" +echo -e "UID: ${UID}" +echo -e "GID: ${GID}" echo -e "" echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" @@ -40,20 +41,20 @@ echo -e "======================================================================= # Copy linuxgsm.sh into homedir if [ ! -e ~/linuxgsm.sh ]; then - echo "copying linuxgsm.sh to /home/linuxgsm" - cp /linuxgsm.sh ~/linuxgsm.sh + echo "copying linuxgsm.sh to /home/linuxgsm" + cp /linuxgsm.sh ~/linuxgsm.sh fi # Setup game server if [ ! -f "${GAMESERVER}" ]; then - echo "creating ./${GAMESERVER}" - ./linuxgsm.sh ${GAMESERVER} + echo "creating ./${GAMESERVER}" + ./linuxgsm.sh ${GAMESERVER} fi # Install game server if [ -z "$(ls -A -- "serverfiles")" ]; then - echo "installing ${GAMESERVER}" - ./${GAMESERVER} auto-install + echo "installing ${GAMESERVER}" + ./${GAMESERVER} auto-install fi echo "starting cron" @@ -74,19 +75,19 @@ tail -f log/script/* # with no command, just spawn a running container suitable for exec's if [ $# = 0 ]; then - tail -f /dev/null + tail -f /dev/null else - # execute the command passed through docker - "$@" + # execute the command passed through docker + "$@" - # if this command was a server start cmd - # to get around LinuxGSM running everything in - # tmux; - # we attempt to attach to tmux to track the server - # this keeps the container running - # when invoked via docker run - # but requires -it or at least -t - tmux set -g status off && tmux attach 2> /dev/null + # if this command was a server start cmd + # to get around LinuxGSM running everything in + # tmux; + # we attempt to attach to tmux to track the server + # this keeps the container running + # when invoked via docker run + # but requires -it or at least -t + tmux set -g status off && tmux attach 2>/dev/null fi exec "$@"