diff --git a/Dockerfile b/Dockerfile index 7e8d580..74bf6af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,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 diff --git a/crontab b/crontab new file mode 100644 index 0000000..91e388f --- /dev/null +++ b/crontab @@ -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" diff --git a/run.sh b/run.sh index cd58072..8d0bdb2 100644 --- a/run.sh +++ b/run.sh @@ -12,12 +12,16 @@ if [ ! -w /ark ]; then exit 1 fi +# Add a template directory to store the last version of config file +[ ! -d /ark/template ] && mkdir /ark/template +[ -f /ark/arkmanager.cfg ] && cp /home/steam/arkmanager.cfg /ark/template/arkmanager.cfg +[ -f /ark/crontab ] && 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 /ark/server/ShooterGame/Saved/Config/Game.ini /ark/Game.ini -[ ! -f /ark/GameUserSettings.ini ] && ln -s /ark/server/ShooterGame/Saved/Config/GameUserSetting.ini /ark/GameUserSettings.ini +[ ! -f /ark/Game.ini ] && ln -s /ark/server/ShooterGame/Saved/Config/LinuxServer/Game.ini /ark/Game.ini +[ ! -f /ark/GameUserSettings.ini ] && ln -s /ark/server/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini /ark/GameUserSettings.ini @@ -38,30 +42,16 @@ else fi fi -# We load the crontab file if it exist. -if [ -f /ark/crontab ]; then +# 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 - cat <> /ark/crontab -# 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" -EOT + echo "No crontab set." fi # Launching ark server