2015-09-17 11:21:35 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
echo "###########################################################################"
|
|
|
|
echo "# Ark Server - " `date`
|
|
|
|
echo "###########################################################################"
|
|
|
|
[ -p /tmp/FIFO ] && rm /tmp/FIFO
|
|
|
|
mkfifo /tmp/FIFO
|
|
|
|
|
|
|
|
export TERM=linux
|
|
|
|
|
2015-10-27 14:17:29 +01:00
|
|
|
if [ ! -w /ark ]; then
|
|
|
|
echo "[Error] Can't access ark directory. Check permissions on your mapped directory with /ark"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-10-27 10:55:32 +01:00
|
|
|
# Creating directory tree && symbolic link
|
2015-09-17 11:21:35 +02:00
|
|
|
[ ! -f /ark/arkmanager.cfg ] && cp /home/steam/arkmanager.cfg /ark/arkmanager.cfg
|
|
|
|
[ ! -d /ark/log ] && mkdir /ark/log
|
|
|
|
[ ! -d /ark/backup ] && mkdir /ark/backup
|
2015-10-27 10:55:32 +01:00
|
|
|
[ ! -f /ark/Game.ini ] && ln -s /ark/server/ShooterGame/Saved/Config/Game.ini /ark/Game.ini
|
2015-11-05 14:50:09 +01:00
|
|
|
[ ! -f /ark/GameUserSettings.ini ] && ln -s /ark/server/ShooterGame/Saved/Config/GameUserSetting.ini /ark/GameUserSettings.ini
|
2015-09-17 11:21:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-27 10:55:32 +01:00
|
|
|
if [ ! -d "/ark/server" ] || [ ! -f "/ark/server/arkversion" ];then
|
2015-09-17 11:21:35 +02:00
|
|
|
arkmanager install
|
2015-10-23 11:15:44 +02:00
|
|
|
# Create mod dir
|
|
|
|
mkdir /ark/server/ShooterGame/Content/Mods
|
|
|
|
else
|
|
|
|
|
|
|
|
if [ ${BACKUPONSTART} -eq 1 ]; then
|
|
|
|
echo "[Backup]"
|
|
|
|
arkmanager backup
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${UPDATEONSTART} -eq 1 ]; then
|
|
|
|
echo "[Update]"
|
|
|
|
arkmanager update --update-mods
|
|
|
|
fi
|
2015-09-17 11:21:35 +02:00
|
|
|
fi
|
|
|
|
|
2015-10-27 11:19:58 +01:00
|
|
|
# We load the crontab file if it exist.
|
|
|
|
if [ -f /ark/crontab ]; then
|
|
|
|
crontab /ark/crontab
|
2015-10-27 13:42:32 +01:00
|
|
|
# Cron is attached to this process
|
|
|
|
sudo cron -f &
|
2015-10-27 11:19:58 +01:00
|
|
|
else
|
|
|
|
cat <<EOT >> /ark/crontab
|
2015-10-27 11:39:58 +01:00
|
|
|
# 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
|
2015-10-27 11:19:58 +01:00
|
|
|
# Example : update every hour
|
|
|
|
# 0 * * * * arkmanager update
|
|
|
|
# Example : backup every 15min
|
|
|
|
# */15 * * * * arkmanager backup
|
|
|
|
# Example : backup every day at midnight
|
|
|
|
# 0 0 * * * arkmanager backup
|
2015-10-27 13:42:32 +01:00
|
|
|
# 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"
|
2015-10-27 11:33:50 +01:00
|
|
|
EOT
|
2015-10-27 11:19:58 +01:00
|
|
|
fi
|
|
|
|
|
2015-09-17 11:21:35 +02:00
|
|
|
# Launching ark server
|
|
|
|
arkmanager start
|
|
|
|
|
|
|
|
|
|
|
|
# Stop server in case of signal INT or TERM
|
|
|
|
echo "Waiting..."
|
2015-10-27 13:42:32 +01:00
|
|
|
trap 'arkmanager stop;' INT
|
2015-09-17 11:21:35 +02:00
|
|
|
trap 'arkmanager stop' TERM
|
|
|
|
|
|
|
|
read < /tmp/FIFO &
|
|
|
|
wait
|