2015-09-17 11:21:35 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
echo "###########################################################################"
|
|
|
|
echo "# Ark Server - " `date`
|
2016-07-08 16:12:46 +02:00
|
|
|
echo "# UID $UID - GID $GID"
|
2015-09-17 11:21:35 +02:00
|
|
|
echo "###########################################################################"
|
|
|
|
[ -p /tmp/FIFO ] && rm /tmp/FIFO
|
|
|
|
mkfifo /tmp/FIFO
|
|
|
|
|
|
|
|
export TERM=linux
|
|
|
|
|
2016-03-23 15:31:28 +01:00
|
|
|
function stop {
|
2016-07-13 09:56:38 +02:00
|
|
|
if [ ${BACKUPONSTOP} -eq 1 ] && [ "$(ls -A server/ShooterGame/Saved/SavedArks)" ]; then
|
2016-03-23 15:31:28 +01:00
|
|
|
echo "[Backup on stop]"
|
|
|
|
arkmanager backup
|
|
|
|
fi
|
|
|
|
if [ ${WARNONSTOP} -eq 1 ];then
|
|
|
|
arkmanager stop --warn
|
|
|
|
else
|
|
|
|
arkmanager stop
|
|
|
|
fi
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2016-07-08 16:12:46 +02:00
|
|
|
|
2015-10-27 14:17:29 +01:00
|
|
|
|
2015-11-05 16:10:08 +01:00
|
|
|
# Change working directory to /ark to allow relative path
|
|
|
|
cd /ark
|
|
|
|
|
2015-11-05 16:02:00 +01:00
|
|
|
# Add a template directory to store the last version of config file
|
|
|
|
[ ! -d /ark/template ] && mkdir /ark/template
|
2015-11-05 16:10:08 +01:00
|
|
|
# We overwrite the template file each time
|
|
|
|
cp /home/steam/arkmanager.cfg /ark/template/arkmanager.cfg
|
|
|
|
cp /home/steam/crontab /ark/template/crontab
|
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
|
2016-03-23 15:31:28 +01:00
|
|
|
[ ! -d /ark/staging ] && mkdir /ark/staging
|
2016-07-08 16:12:46 +02:00
|
|
|
[ ! -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
|
2016-03-23 15:31:28 +01:00
|
|
|
[ ! -f /ark/crontab ] && cp /ark/template/crontab /ark/crontab
|
2015-09-17 11:21:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-24 00:31:25 +01:00
|
|
|
if [ ! -d /ark/server ] || [ ! -f /ark/server/version.txt ];then
|
2016-07-08 16:12:46 +02:00
|
|
|
echo "No game files found. Installing..."
|
2016-07-13 09:56:38 +02:00
|
|
|
mkdir -p /ark/server/ShooterGame/Saved/SavedArks
|
|
|
|
mkdir -p /ark/server/ShooterGame/Content/Mods
|
|
|
|
mkdir -p /ark/server/ShooterGame/Binaries/Linux/
|
|
|
|
touch /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer
|
2015-09-17 11:21:35 +02:00
|
|
|
arkmanager install
|
2015-10-23 11:15:44 +02:00
|
|
|
# Create mod dir
|
|
|
|
else
|
|
|
|
|
2016-07-13 09:56:38 +02:00
|
|
|
if [ ${BACKUPONSTART} -eq 1 ] && [ "$(ls -A server/ShooterGame/Saved/SavedArks/)" ]; then
|
2015-10-23 11:15:44 +02:00
|
|
|
echo "[Backup]"
|
|
|
|
arkmanager backup
|
|
|
|
fi
|
2015-09-17 11:21:35 +02:00
|
|
|
fi
|
|
|
|
|
2016-03-23 15:31:28 +01:00
|
|
|
|
2015-11-05 16:02:00 +01:00
|
|
|
# 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.
|
2015-10-27 11:19:58 +01:00
|
|
|
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
|
2015-11-05 16:02:00 +01:00
|
|
|
echo "No crontab set."
|
2015-10-27 11:19:58 +01:00
|
|
|
fi
|
|
|
|
|
2015-09-17 11:21:35 +02:00
|
|
|
# Launching ark server
|
2016-03-23 15:31:28 +01:00
|
|
|
if [ $UPDATEONSTART -eq 0 ]; then
|
|
|
|
arkmanager start -noautoupdate
|
|
|
|
else
|
|
|
|
arkmanager start
|
|
|
|
fi
|
2015-09-17 11:21:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Stop server in case of signal INT or TERM
|
|
|
|
echo "Waiting..."
|
2016-03-23 15:31:28 +01:00
|
|
|
trap stop INT
|
|
|
|
trap stop TERM
|
2015-09-17 11:21:35 +02:00
|
|
|
|
|
|
|
read < /tmp/FIFO &
|
|
|
|
wait
|