#11 : add UID & GID.

This commit is contained in:
TuRz4m 2016-07-08 16:12:46 +02:00
parent 50db7b51b9
commit 142c15a438
3 changed files with 36 additions and 10 deletions

View file

@ -27,6 +27,10 @@ ENV STEAMPORT 7778
ENV BACKUPONSTOP 0
# If the server warn the players before stopping
ENV WARNONSTOP 0
# UID of the user steam
ENV UID 1000
# GID of the user steam
ENV GID 1000
# Install dependencies
RUN apt-get update &&\
@ -48,10 +52,13 @@ RUN usermod -a -G sudo steam
# Copy & rights to folders
COPY run.sh /home/steam/run.sh
COPY user.sh /home/steam/user.sh
COPY crontab /home/steam/crontab
COPY arkmanager-user.cfg /home/steam/arkmanager.cfg
RUN touch /root/.bash_profile
RUN chmod 777 /home/steam/run.sh
RUN chmod 777 /home/steam/user.sh
RUN mkdir /ark
@ -75,7 +82,7 @@ COPY instance.cfg /etc/arkmanager/instances/main.cfg
RUN chown steam -R /ark && chmod 755 -R /ark
USER steam
#USER steam
# download steamcmd
RUN mkdir /home/steam/steamcmd &&\
@ -96,4 +103,4 @@ VOLUME /ark
WORKDIR /ark
# Update game launch the game.
ENTRYPOINT ["/home/steam/run.sh"]
ENTRYPOINT ["/home/steam/user.sh"]

14
run.sh
View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
echo "###########################################################################"
echo "# Ark Server - " `date`
echo "# UID $UID - GID $GID"
echo "###########################################################################"
[ -p /tmp/FIFO ] && rm /tmp/FIFO
mkfifo /tmp/FIFO
@ -20,10 +21,7 @@ function stop {
exit
}
if [ ! -w /ark ]; then
echo "[Error] Can't access ark directory. Check permissions on your mapped directory with /ark"
exit 1
fi
# Change working directory to /ark to allow relative path
cd /ark
@ -38,14 +36,14 @@ cp /home/steam/crontab /ark/template/crontab
[ ! -d /ark/log ] && mkdir /ark/log
[ ! -d /ark/backup ] && mkdir /ark/backup
[ ! -d /ark/staging ] && mkdir /ark/staging
[ ! -f /ark/Game.ini ] && ln -s server/ShooterGame/Saved/Config/LinuxServer/Game.ini Game.ini
[ ! -f /ark/GameUserSettings.ini ] && ln -s server/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini GameUserSettings.ini
[ ! -L /ark/Game.ini ] && ln -s server/ShooterGame/Saved/Config/LinuxServer/Game.ini Game.ini
[ ! -L /ark/GameUserSettings.ini ] && ln -s server/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini GameUserSettings.ini
[ ! -f /ark/crontab ] && cp /ark/template/crontab /ark/crontab
if [ ! -d "/ark/server" ] || [ ! -f "/ark/server/arkversion" ];then
mkdir /ark/server
if [ ! -d /ark/server ] || [ ! -f /ark/server/arkversion ];then
echo "No game files found. Installing..."
arkmanager install
# Create mod dir
mkdir /ark/server/ShooterGame/Content/Mods

21
user.sh Normal file
View file

@ -0,0 +1,21 @@
#!/bin/sh
# Change the UID if needed
if [ ! "$(id -u steam)" -eq "$UID" ]; then
echo "Changing steam uid to $UID."
usermod -o -u "$UID" steam ;
fi
# Change gid if needed
if [ ! "$(id -g steam)" -eq "$GID" ]; then
echo "Changing steam gid to $GID."
groupmod -o -g "$GID" steam ;
fi
# Put steam owner of directories (if the uid changed, then it's needed)
chown -R steam:steam /ark /home/steam
# avoid error message when su -p (we need to read the /root/.bash_rc )
chmod -R 777 /root/
# Launch run.sh with user steam (-p allow to keep env variables)
su -p - steam -c /home/steam/run.sh