Skip to content

Commit

Permalink
V1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TuRz4m committed Nov 13, 2015
2 parents f7cd4d4 + a179f36 commit 96c6a3f
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 45 deletions.
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ ENV NBPLAYERS 70
ENV UPDATEONSTART 1
# if the server is backup when start with docker start
ENV BACKUPONSTART 1
# Nb minute between auto update (warm) (-1 : no auto update)
ENV AUTOUPDATE -1
# Nb minute between auto backup (-1 : no auto backup)
ENV AUTOBACKUP -1
# branch on github for ark server tools
ENV BRANCH master
# Server PORT (you can't remap with docker, it doesn't work)
Expand All @@ -30,7 +26,7 @@ ENV STEAMPORT 7778

# Install dependencies
RUN apt-get update &&\
apt-get install -y curl lib32gcc1 lsof git
apt-get install -y curl lib32gcc1 lsof git

# Enable passwordless sudo for users under the "sudo" group
RUN sed -i.bkp -e \
Expand All @@ -48,6 +44,7 @@ RUN usermod -a -G sudo steam

# Copy & rights to folders
COPY run.sh /home/steam/run.sh
COPY crontab /home/steam/crontab
COPY arkmanager-user.cfg /home/steam/arkmanager.cfg

RUN chmod 777 /home/steam/run.sh
Expand All @@ -61,14 +58,14 @@ WORKDIR /home/steam/ark-server-tools/tools
RUN chmod +x install.sh
RUN ./install.sh steam

# Allow crontab to call arkmanager
RUN ln -s /usr/local/bin/arkmanager /usr/bin/arkmanager

# Define default config file in /ark
COPY arkmanager-system.cfg /etc/arkmanager/arkmanager.cfg


RUN chown steam -R /ark && chmod 755 -R /ark



USER steam

# download steamcmd
Expand All @@ -80,11 +77,12 @@ RUN mkdir /home/steam/steamcmd &&\
# First run is on anonymous to download the app
RUN /home/steam/steamcmd/steamcmd.sh +login anonymous +quit



EXPOSE ${STEAMPORT} 32330 ${SERVERPORT}

VOLUME /ark

# Change the working directory to /arkd
WORKDIR /ark

# Update game launch the game.
ENTRYPOINT ["/home/steam/run.sh"]
61 changes: 42 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Docker build for managing an ARK: Survival Evolved server.

This image uses [Ark Server Tools](https://github.com/FezVrasta/ark-server-tools) to manage an ark server.

*If you use an old volume, delete arkmanager.cfg to get the new configuration file.*
__Don't forger to use `docker pull turzam/ark` to get the latest version of the image__
*If you use an old volume, get the new arkmanager.cfg in the template directory.*
__Don't forget to use `docker pull turzam/ark` to get the latest version of the image__


## Features
- Easy install (no steamcmd / lib32... to install)
- Use Ark Server Tools : update/install/start/backup/rcon
- Auto update (on start or on timer)
- Auto backup (on start or on timer)
- Use Ark Server Tools : update/install/start/backup/rcon/mods
- Easy crontab configuration
- Easy access to ark config file
- Mods handling (via Ark Server Tools)
- `Docker stop` is a clean stop

Expand All @@ -22,21 +22,21 @@ Fast & Easy server setup :

You can map the ark volume to access config files :
`docker run -d -p 7778:7778 -p 7778:7778/udp -p 27015:27015 -p 27015:27015/udp -e SESSIONNAME=myserver -v /my/path/to/ark:/ark --name ark turzam/ark`
Then you can edit */my/path/to/ark/arkcmanager.cfg* (the values override GameUserSetting.ini) and */my/path/to/ark/server/ShooterGame/Saved/Config/LinuxServer/[GameUserSetting.ini/Game.ini]*
Then you can edit */my/path/to/ark/arkmanager.cfg* (the values override GameUserSetting.ini) and */my/path/to/ark/[GameUserSetting.ini/Game.ini]*

You can manager your server with rcon if you map the rcon port (you can rebind the rcon port with docker):
`docker run -d -p 7778:7778 -p 7778:7778/udp -p 27015:27015 -p 27015:27015/udp -p 32330:32330 -e SESSIONNAME=myserver --name ark turzam/ark`

You can define a server that updates itself every 2 hours (with 1 hour warning) and backups itself every hours:
`docker run -d -p 7778:7778 -p 7778:7778/udp -p 27015:27015 -p 27015:27015/udp -e SESSIONNAME=myserver -e AUTOBACKUP=60 -e AUTOUPDATE=120 -e WARNMINUTE=60 --name ark turzam/ark`

You can change server and steam port to allow multiple servers on same host:
*(You can't just rebind the port with docker. It won't work, you need to change STEAMPORT & SERVERPORT variable)*
`docker run -d -p 7779:7779 -p 7779:7779/udp -p 27016:27016 -p 27016:27016/udp -p 32331:32330 -e SESSIONNAME=myserver2 -e SERVERPORT=27016 -e STEAMPORT=7779 --name ark2 turzam/ark`

You can check your server with :
`docker exec ark arkmanager status`

You can manually update your mods:
`docker exec ark arkmanager update --update-mods`

You can manually update your server:
`docker exec ark arkmanager update --force`

Expand All @@ -55,13 +55,28 @@ You can use rcon command via docker :

__You can check all available command for arkmanager__ [here](https://github.com/FezVrasta/ark-server-tools/blob/master/README.md)

You can easily configure automatic update and backup.
If you edit the file `/my/path/to/ark/crontab` you can add your crontab job.
For example :
`# Update the server every hours`
`0 * * * * arkmanager update --warn --update-mods >> /ark/log/crontab.log 2&>1`
`# Backup the server each day at 00:00 `
`0 0 * * * arkmanager backup >> /ark/log/crontab.log 2&>1`
*You can check [this website](http://www.unix.com/man-page/linux/5/crontab/) for more information on cron.*

To add mods, you only need to change the variable ark_GameModIds in *arkmanager.cfg* with a list of your modIds (like this `ark_GameModIds="987654321,1234568"`). If UPDATEONSTART is enable, just restart your docker or use `docker exec ark arkmanager update --update-mods`.

---

## Recommended Usage
- First run
`docker run -it -p 7778:7778 -p 7778:7778/udp -p 27015:27015 -p 27015:27015/udp -p 32330:32330 -e SESSIONNAME=myserver -e ADMINPASSWORD="mypasswordadmin" -e AUTOUPDATE=120 -e AUTOBACKUP=60 -e WARNMINUTE=30 -v /my/path/to/ark:/ark --name ark turzam/ark`
- Wait for ark to be downloaded installed and launched, then Ctrl+C to stop the server.
- Modify */my/path/to/ark/server/ShooterGame/Saved/Config/LinuxServer/GameUserSetting.ini and Game.ini*
- Edit */my/path/to/ark/GameUserSetting.ini and Game.ini*
- Edit */my/path/to/ark/arkserver.cfg* to add mods and configure warning time.
- Add auto update every day and autobackup by editing */my/path/to/ark/crontab* with this lines :
`0 0 * * * arkmanager update --warn --update-mods >> /ark/log/crontab.log 2&>1`
`0 0 * * * arkmanager backup >> /ark/log/crontab.log 2&>1`
- `docker start ark`
- Check your server with :
`docker exec ark arkmanager status`
Expand All @@ -84,14 +99,9 @@ Steam server port (can't rebind with docker, it doesn't work) (default : 7778)
+ __BACKUPONSTART__
1 : Backup the server when the container is started. 0: no backup (default : 1)
+ __UPDATEPONSTART__
1 : Update the server when the container is started. 0: no update (default : 1)
+ __AUTOUPDATE__
Number of minute between each check for une newer version (-1 disable auto update) (default : -1)
Auto update is set to --warn and warn the players 30 minutes before update (default, can be changed in /ark/arkmanager.cfg).
+ __AUTOBACKUP__
Number of minute between each backup (-1 disable auto backup) (default : -1)
+ __WARNMINUTE__
Number of minute to warn the players when auto-update (default : 30)
1 : Update the server when the container is started. 0: no update (default : 1)
+ __TZ__
Time Zone : Set the container timezone (for crontab). (You can get your timezone posix format with the command `tzselect`. For example, France is "Europe/Paris").


---
Expand All @@ -101,7 +111,13 @@ Number of minute to warn the players when auto-update (default : 30)
+ /ark/server : Server files and data.
+ /ark/log : logs
+ /ark/backup : backups
+ /ark/arkmanager.cfg : config file
+ /ark/arkmanager.cfg : config file for Ark Server Tools
+ /ark/crontab : crontab config file
+ /ark/Game.ini : ark game.ini config file
+ /ark/GameUserSetting.ini : ark gameusersetting.ini config file
+ /ark/template : Default config files
+ /ark/template/arkmanager.cfg : default config file for Ark Server Tools
+ /ark/template/crontab : default config file for crontab

---

Expand All @@ -123,4 +139,11 @@ Number of minute to warn the players when auto-update (default : 30)
+ 1.1 :
- Works with Ark Server Tools 1.4 [See changelog here](https://github.com/FezVrasta/ark-server-tools/releases/tag/v1.4)
- Handle mods && auto update mods
+ 1.2 :
- Remove variable AUTOBACKUP & AUTOUPDATE
- Remove variable WARNMINUTE (can now be find in arkmanager.cfg)
- Add crontab support
- You can now config crontab with the file /your/ark/path/crontab
- Add template directory with default config files.
- Add documentation on TZ variable.

1 change: 0 additions & 1 deletion arkmanager-system.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ steamcmd_appinfocache="/home/steam/Steam/appcache/appinfo.vdf" # cache of t
arkserverroot="/ark/server" # path of your ARK server files (default ~/ARK)
arkserverexec="ShooterGame/Binaries/Linux/ShooterGameServer" # name of ARK server executable
arkbackupdir="/ark/backup" # path to backup directory
arkwarnminutes="30" # number of minutes to warn players when using update --warn
arkautorestartfile="ShooterGame/Saved/.autorestart" # path to autorestart file

# config Service
Expand Down
1 change: 1 addition & 0 deletions arkmanager-user.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ mod_branch=Windows
msgWarnUpdateMinutes="This ARK server will shutdown for an update in %d minutes"
msgWarnUpdateSeconds="This ARK server will shutdown for an update in %d seconds"
arkBackupPreUpdate="false" # set this to true if you want to perform a backup before updating
arkwarnminutes="30" # number of minutes to warn players when using update --warn
16 changes: 16 additions & 0 deletions crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user command to be executed
# Example : update every hour
# 0 * * * * arkmanager update
# Example : backup every 15min
# */15 * * * * arkmanager backup
# Example : backup every day at midnight
# 0 0 * * * arkmanager backup
# WARNING : the container timezone is maybe not your current timezone
# You can sync them with option -v /etc/localtime:/etc/localtime:ro or -e "TZ=UTC"
45 changes: 30 additions & 15 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,29 @@ mkfifo /tmp/FIFO

export TERM=linux

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

# Add a template directory to store the last version of config file
[ ! -d /ark/template ] && mkdir /ark/template
# We overwrite the template file each time
cp /home/steam/arkmanager.cfg /ark/template/arkmanager.cfg
cp /home/steam/crontab /ark/template/crontab
# Creating directory tree && symbolic link
[ ! -f /ark/arkmanager.cfg ] && cp /home/steam/arkmanager.cfg /ark/arkmanager.cfg
[ ! -d /ark/log ] && mkdir /ark/log
[ ! -d /ark/backup ] && mkdir /ark/backup
[ ! -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

#echo "Upgrade Ark server tools..."
#arkmanager upgrade-tools


if [ ! -d "/ark/server" ] && [ ! -f "/ark/server/arkversion" ];then
echo "Install ark..."
if [ ! -d "/ark/server" ] || [ ! -f "/ark/server/arkversion" ];then
arkmanager install
# Create mod dir
mkdir /ark/server/ShooterGame/Content/Mods
Expand All @@ -33,24 +46,26 @@ else
fi
fi

# If there is uncommented line in the file
CRONNUMBER=`grep -v "^#" /ark/crontab | wc -l`
if [ $CRONNUMBER -gt 0 ]; then
echo "Loading crontab..."
# We load the crontab file if it exist.
crontab /ark/crontab
# Cron is attached to this process
sudo cron -f &
else
echo "No crontab set."
fi

# Launching ark server
arkmanager start


# Stop server in case of signal INT or TERM
echo "Waiting..."
trap 'arkmanager stop' INT
trap 'arkmanager stop;' INT
trap 'arkmanager stop' TERM

# Auto update every $AUTOUPDATE minutes
if [ $AUTOUPDATE -gt 0 ]; then
while :; do sleep $(($AUTOUPDATE * 60)); echo "[`date +'%y/%m/%d %H:%M'`] [Auto-Update]"; arkmanager update --warn --update-mods --backup ; done &
fi

# Auto backup every $AUTOBACKUP minutes
if [ $AUTOBACKUP -gt 0 ]; then
while :; do sleep $(($AUTOBACKUP * 60)); echo "[`date +'%Y/%m/%d %H:%M'`] [Auto-Backup]"; arkmanager backup ; done &
fi

read < /tmp/FIFO &
wait

0 comments on commit 96c6a3f

Please sign in to comment.