Browse Source

UID

pull/5/head
Daniel Gibbs 3 years ago
parent
commit
471e6c0af6
  1. 11
      Dockerfile
  2. 65
      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}

65
entrypoint.sh

@ -1,10 +1,10 @@
#!/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
exit 0 exit 0
} }
# Exit trap # Exit trap
@ -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}"
@ -40,20 +41,20 @@ echo -e "=======================================================================
# Copy linuxgsm.sh into homedir # Copy linuxgsm.sh into homedir
if [ ! -e ~/linuxgsm.sh ]; then if [ ! -e ~/linuxgsm.sh ]; then
echo "copying linuxgsm.sh to /home/linuxgsm" echo "copying linuxgsm.sh to /home/linuxgsm"
cp /linuxgsm.sh ~/linuxgsm.sh cp /linuxgsm.sh ~/linuxgsm.sh
fi fi
# Setup game server # Setup game server
if [ ! -f "${GAMESERVER}" ]; then if [ ! -f "${GAMESERVER}" ]; then
echo "creating ./${GAMESERVER}" echo "creating ./${GAMESERVER}"
./linuxgsm.sh ${GAMESERVER} ./linuxgsm.sh ${GAMESERVER}
fi fi
# Install game server # Install game server
if [ -z "$(ls -A -- "serverfiles")" ]; then if [ -z "$(ls -A -- "serverfiles")" ]; then
echo "installing ${GAMESERVER}" echo "installing ${GAMESERVER}"
./${GAMESERVER} auto-install ./${GAMESERVER} auto-install
fi fi
echo "starting cron" echo "starting cron"
@ -74,19 +75,19 @@ tail -f log/script/*
# with no command, just spawn a running container suitable for exec's # with no command, just spawn a running container suitable for exec's
if [ $# = 0 ]; then if [ $# = 0 ]; then
tail -f /dev/null tail -f /dev/null
else else
# execute the command passed through docker # execute the command passed through docker
"$@" "$@"
# if this command was a server start cmd # if this command was a server start cmd
# to get around LinuxGSM running everything in # to get around LinuxGSM running everything in
# tmux; # tmux;
# we attempt to attach to tmux to track the server # we attempt to attach to tmux to track the server
# 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