mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-22 22:48:29 +00:00
commit
d71df7f308
@ -149,6 +149,11 @@ instances.
|
|||||||
`--noautoupdate`;;
|
`--noautoupdate`;;
|
||||||
Disables automatic updating on startup if it is enabled
|
Disables automatic updating on startup if it is enabled
|
||||||
|
|
||||||
|
`--alwaysrestart`;;
|
||||||
|
Enable automatically restarting the server even if it crashes
|
||||||
|
without becoming ready for player connections.
|
||||||
|
|
||||||
|
|
||||||
`stop`::
|
`stop`::
|
||||||
Stops the server if it is running
|
Stops the server if it is running
|
||||||
|
|
||||||
@ -257,6 +262,9 @@ instances.
|
|||||||
as well as the following options. In order to specify an
|
as well as the following options. In order to specify an
|
||||||
argument to the command (e.g. to the `broadcast` command),
|
argument to the command (e.g. to the `broadcast` command),
|
||||||
use the `--arg=<arg>` option.
|
use the `--arg=<arg>` option.
|
||||||
|
Please read your `man 5 crontab` manpage to determine what
|
||||||
|
minute and hour values are valid, as some implementations
|
||||||
|
may not accept e.g. the `*/n` minute / hour specification.
|
||||||
|
|
||||||
`--daily`;;
|
`--daily`;;
|
||||||
The command should be executed daily
|
The command should be executed daily
|
||||||
@ -267,10 +275,16 @@ instances.
|
|||||||
`--hour=<hour>`;;
|
`--hour=<hour>`;;
|
||||||
Specifies one or more hours when the command should execute.
|
Specifies one or more hours when the command should execute.
|
||||||
This is the hour field of the cron job.
|
This is the hour field of the cron job.
|
||||||
|
If you want to have the command execute every n hours, then
|
||||||
|
use `--hour='*/n'`
|
||||||
|
Default: `*` (i.e. all hours)
|
||||||
|
|
||||||
`--minute=<minute>`;;
|
`--minute=<minute>`;;
|
||||||
Specifies one or more minutes of the hour when the command
|
Specifies one or more minutes of the hour when the command
|
||||||
should execute. This is the minute field of the cron job.
|
should execute. This is the minute field of the cron job.
|
||||||
|
If you want to have the command execute every n minutes,
|
||||||
|
then use `--minute='*/n'`
|
||||||
|
Default: `0` (i.e. the first minute of the hour)
|
||||||
|
|
||||||
`--enable-output`;;
|
`--enable-output`;;
|
||||||
Enables the output from the command - the cron daemon usually
|
Enables the output from the command - the cron daemon usually
|
||||||
@ -343,6 +357,12 @@ The following options can be overridden on a per-instance basis:
|
|||||||
The relative path within an ARK server install to place the
|
The relative path within an ARK server install to place the
|
||||||
autorestart lock file
|
autorestart lock file
|
||||||
|
|
||||||
|
`arkAlwaysRestartOnCrash`::
|
||||||
|
Set to `true` to enable automatically restarting even when the
|
||||||
|
server has not become ready for player connections.
|
||||||
|
Be aware that this may cause the server to enter an endless
|
||||||
|
crash-restart loop if the cause of the crash is not resolved.
|
||||||
|
|
||||||
`arkAutoUpdateOnStart`::
|
`arkAutoUpdateOnStart`::
|
||||||
Set to `true` to enable updating before server startup
|
Set to `true` to enable updating before server startup
|
||||||
|
|
||||||
|
|||||||
241
tools/arkmanager
241
tools/arkmanager
@ -151,6 +151,8 @@ arkserverLog="arkserver.log" # here is logged the output of ShooterGameServer
|
|||||||
appid="${appid:-376030}"
|
appid="${appid:-376030}"
|
||||||
mod_appid="${mod_appid:-346110}"
|
mod_appid="${mod_appid:-346110}"
|
||||||
arkautorestartfile="${arkautorestartfile:-ShooterGame/Saved/.autorestart}"
|
arkautorestartfile="${arkautorestartfile:-ShooterGame/Saved/.autorestart}"
|
||||||
|
arkserverpidfile="${arkserverpidfile:-ShooterGame/Saved/.arkserver.pid}"
|
||||||
|
arkmanagerpidfile="${arkmanagerpidfile:-ShooterGame/Saved/.arkmanager.pid}"
|
||||||
install_bindir="${install_bindir:-${0%/*}}"
|
install_bindir="${install_bindir:-${0%/*}}"
|
||||||
install_libexecdir="${install_libexecdir:-${install_bindir%/*}/libexec/arkmanager}"
|
install_libexecdir="${install_libexecdir:-${install_bindir%/*}/libexec/arkmanager}"
|
||||||
|
|
||||||
@ -202,6 +204,7 @@ checkConfig() {
|
|||||||
# SavedArks directory
|
# SavedArks directory
|
||||||
if [ -n "$arkserverroot" ]; then
|
if [ -n "$arkserverroot" ]; then
|
||||||
local savedarksdir="${arkserverroot}/ShooterGame/Saved/${ark_AltSaveDirectoryName:-SavedArks}"
|
local savedarksdir="${arkserverroot}/ShooterGame/Saved/${ark_AltSaveDirectoryName:-SavedArks}"
|
||||||
|
mkdir -p "${savedarksdir}"
|
||||||
if [ ! -w "${savedarksdir}" ]; then
|
if [ ! -w "${savedarksdir}" ]; then
|
||||||
echo -e "[" "$RED" "ERROR" "$NORMAL" "]" "\tThe ARK SavedArks directory is not writable, and saveworld will fail"
|
echo -e "[" "$RED" "ERROR" "$NORMAL" "]" "\tThe ARK SavedArks directory is not writable, and saveworld will fail"
|
||||||
fi
|
fi
|
||||||
@ -506,6 +509,13 @@ function getAvailableVersion(){
|
|||||||
# Get the PID of the server process
|
# Get the PID of the server process
|
||||||
#
|
#
|
||||||
function getServerPID(){
|
function getServerPID(){
|
||||||
|
if [ -f "${arkserverroot}/${arkserverpidfile}" ]; then
|
||||||
|
serverpid="$(<"${arkserverroot}/${arkserverpidfile}")"
|
||||||
|
if kill -0 "$serverpid" >/dev/null 2>&1; then
|
||||||
|
echo $serverpid
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'
|
ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,25 +599,54 @@ function isTheServerOnline(){
|
|||||||
# Check if anybody is connected to the server
|
# Check if anybody is connected to the server
|
||||||
#
|
#
|
||||||
function numPlayersConnected(){
|
function numPlayersConnected(){
|
||||||
perl -MSocket -e '
|
if [ -n "$arkUsePlayerList" ]; then
|
||||||
my $port = int($ARGV[0]);
|
perl -MSocket -e '
|
||||||
socket(my $socket, PF_INET, SOCK_DGRAM, 0);
|
my $port = int($ARGV[0]);
|
||||||
setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack("i4", 1, 0, 0, 0));
|
socket(my $socket, PF_INET, SOCK_DGRAM, 0);
|
||||||
my $sockaddr = pack_sockaddr_in($port, inet_aton($ARGV[1]));
|
setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack("i4", 1, 0, 0, 0));
|
||||||
send($socket, "\xff\xff\xff\xffTSource Engine Query\x00", 0, $sockaddr);
|
my $sockaddr = pack_sockaddr_in($port, inet_aton($ARGV[1]));
|
||||||
my $data = "";
|
send($socket, "\xff\xff\xff\xff\x55\xff\xff\xff\xff", 0, $sockaddr);
|
||||||
recv($socket, $data, 1400, 0) or (print "-1" and exit(1));
|
my $data = "";
|
||||||
my ($servername, $mapname, $game, $fullname, $rest) = split(/\x00/, substr($data, 6), 5);
|
recv($socket, $data, 1400, 0) or (print "-1" and exit(1));
|
||||||
my $players = ord(substr($rest, 2, 1));
|
if (ord(substr($data, 4, 1)) == 0x41) {
|
||||||
print "$players\n";
|
my $chal = substr($data, 5);
|
||||||
' "$(getQueryPort)" "${ark_MultiHome:-127.0.0.1}"
|
send($socket, "\xff\xff\xff\xff\x55" . $chal, 0, $sockaddr);
|
||||||
|
$data = "";
|
||||||
|
recv($socket, $data, 1400, 0) or (print "-1" and exit(1));
|
||||||
|
}
|
||||||
|
ord(substr($data, 4, 1)) != 0x44 and (print "-1" and exit(1));
|
||||||
|
my $players = ord(substr($data, 5, 1));
|
||||||
|
print "$players\n";
|
||||||
|
' "$(getQueryPort)" "${ark_MultiHome:-127.0.0.1}"
|
||||||
|
else
|
||||||
|
perl -MSocket -e '
|
||||||
|
my $port = int($ARGV[0]);
|
||||||
|
socket(my $socket, PF_INET, SOCK_DGRAM, 0);
|
||||||
|
setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack("i4", 1, 0, 0, 0));
|
||||||
|
my $sockaddr = pack_sockaddr_in($port, inet_aton($ARGV[1]));
|
||||||
|
send($socket, "\xff\xff\xff\xffTSource Engine Query\x00", 0, $sockaddr);
|
||||||
|
my $data = "";
|
||||||
|
recv($socket, $data, 1400, 0) or (print "-1" and exit(1));
|
||||||
|
my ($servername, $mapname, $game, $fullname, $rest) = split(/\x00/, substr($data, 6), 5);
|
||||||
|
my $players = ord(substr($rest, 2, 1));
|
||||||
|
print "$players\n";
|
||||||
|
' "$(getQueryPort)" "${ark_MultiHome:-127.0.0.1}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# run function
|
# run function
|
||||||
#
|
#
|
||||||
doRun() {
|
doRun() {
|
||||||
cd "$arkserverroot"
|
cd "${arkserverroot}/${arkserverexec%/*}"
|
||||||
|
|
||||||
|
if isTheServerRunning; then
|
||||||
|
echo "Error: another server instance is running from the same directory"
|
||||||
|
echo "Aborting - two servers MUST NOT run from the same directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$$" >"${arkserverroot}/${arkmanagerpidfile}"
|
||||||
|
|
||||||
arkserveropts="$serverMap"
|
arkserveropts="$serverMap"
|
||||||
|
|
||||||
@ -703,6 +742,14 @@ doRun() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ " ${arkextraopts[*]} " =~ " -automanagedmods " ]]; then
|
||||||
|
if [ ! -f "${arkserverroot}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd.sh" ]; then
|
||||||
|
mkdir -p "${arkserverroot}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
|
||||||
|
curl -s "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" -o "${arkserverroot}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd_linux.tar.gz"
|
||||||
|
tar -xzf "${arkserverroot}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd_linux.tar.gz" -C "${arkserverroot}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
arkserveropts="${arkserveropts}?listen"
|
arkserveropts="${arkserveropts}?listen"
|
||||||
# run the server in background
|
# run the server in background
|
||||||
echo "`timestamp`: start"
|
echo "`timestamp`: start"
|
||||||
@ -713,10 +760,11 @@ doRun() {
|
|||||||
# Shutdown the server when we are terminated
|
# Shutdown the server when we are terminated
|
||||||
shutdown_server(){
|
shutdown_server(){
|
||||||
restartserver=0
|
restartserver=0
|
||||||
rm "$arkserverroot/$arkautorestartfile"
|
rm -f "$arkserverroot/$arkautorestartfile"
|
||||||
if [ "$serverpid" -ne 0 ]; then
|
if [ "$serverpid" -ne 0 ]; then
|
||||||
kill -INT $serverpid
|
kill -INT $serverpid >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
trap shutdown_server INT TERM
|
trap shutdown_server INT TERM
|
||||||
@ -730,10 +778,15 @@ doRun() {
|
|||||||
"$arkserverroot/$arkserverexec" "$arkserveropts" "${arkextraopts[@]}" &
|
"$arkserverroot/$arkserverexec" "$arkserveropts" "${arkextraopts[@]}" &
|
||||||
# Grab the server PID
|
# Grab the server PID
|
||||||
serverpid=$!
|
serverpid=$!
|
||||||
|
echo "$serverpid" >"${arkserverroot}/${arkserverpidfile}"
|
||||||
echo "`timestamp`: Server PID: $serverpid"
|
echo "`timestamp`: Server PID: $serverpid"
|
||||||
# Disable auto-restart so we don't get caught in a restart loop
|
# Disable auto-restart so we don't get caught in a restart loop
|
||||||
rm -f "$arkserverroot/$arkautorestartfile"
|
rm -f "$arkserverroot/$arkautorestartfile"
|
||||||
restartserver=0
|
restartserver=0
|
||||||
|
if [ -n "$arkAlwaysRestartOnCrash" ]; then
|
||||||
|
restartserver=1
|
||||||
|
touch "$arkserverroot/$arkautorestartfile"
|
||||||
|
fi
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
@ -768,6 +821,7 @@ doRun() {
|
|||||||
# doStop will remove the autorestart file
|
# doStop will remove the autorestart file
|
||||||
if [ ! -f "$arkserverroot/$arkautorestartfile" ]; then
|
if [ ! -f "$arkserverroot/$arkautorestartfile" ]; then
|
||||||
restartserver=0
|
restartserver=0
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$restartserver" -ne 0 ]; then
|
if [ "$restartserver" -ne 0 ]; then
|
||||||
@ -789,6 +843,10 @@ doStart() {
|
|||||||
doUpdate --update-mods
|
doUpdate --update-mods
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ " $* " =~ " --alwaysrestart " ]]; then
|
||||||
|
arkAlwaysRestartOnCrash=true
|
||||||
|
fi
|
||||||
tput sc
|
tput sc
|
||||||
echo "The server is starting..."
|
echo "The server is starting..."
|
||||||
|
|
||||||
@ -828,7 +886,7 @@ doStop() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--warn) dowarn=1; ;;
|
--warn) dowarn=1; ;;
|
||||||
--warnreason=*) warnreason="${arg#*=}"; ;;
|
--warnreason=*) warnreason="${arg#--warnreason=}"; dowarn=1; ;;
|
||||||
--saveworld) dosave=1; ;;
|
--saveworld) dosave=1; ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -862,6 +920,13 @@ doStop() {
|
|||||||
kill -KILL $PID
|
kill -KILL $PID
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "${arkserverroot}/${arkmanagerpidfile}" ]; then
|
||||||
|
PID="$(<"${arkserverroot}/${arkmanagerpidfile}")"
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
kill $PID
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
tput rc; tput ed;
|
tput rc; tput ed;
|
||||||
echo "The server has been stopped"
|
echo "The server has been stopped"
|
||||||
echo "`timestamp`: stopped" >> "$logdir/$arkmanagerLog"
|
echo "`timestamp`: stopped" >> "$logdir/$arkmanagerLog"
|
||||||
@ -951,7 +1016,13 @@ printWarnMessage(){
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
msg="${msgWarnReason//\{time\}/$msgtime}"
|
msg="${msgWarnReason//\{time\}/$msgtime}"
|
||||||
if [ "$1" == "update" ]; then
|
if [ -n "$warnreason" ]; then
|
||||||
|
local v="warnreason_$warnreason"
|
||||||
|
reason="${!v}"
|
||||||
|
if [ -z "$reason" ]; then
|
||||||
|
reason="$warnreason"
|
||||||
|
fi
|
||||||
|
elif [ "$1" == "update" ]; then
|
||||||
if [ -n "$appupdate" ]; then
|
if [ -n "$appupdate" ]; then
|
||||||
if [ -n "$modupdate" ]; then
|
if [ -n "$modupdate" ]; then
|
||||||
if [ -n "$msgReasonUpdateAppMod" ]; then
|
if [ -n "$msgReasonUpdateAppMod" ]; then
|
||||||
@ -991,7 +1062,6 @@ printWarnMessage(){
|
|||||||
reason="${reason//\{time\}/${msgtime}}"
|
reason="${reason//\{time\}/${msgtime}}"
|
||||||
reason="${reason//\{modnamesupdated\}/${modnamesupdated}}"
|
reason="${reason//\{modnamesupdated\}/${modnamesupdated}}"
|
||||||
msg="${msg//\{reason\}/${reason}}"
|
msg="${msg//\{reason\}/${reason}}"
|
||||||
printf "%s\n" "$msg"
|
|
||||||
else
|
else
|
||||||
if [ "$1" == "update" ]; then
|
if [ "$1" == "update" ]; then
|
||||||
if [ "$3" == "minutes" ]; then
|
if [ "$3" == "minutes" ]; then
|
||||||
@ -1041,6 +1111,28 @@ printWarnMessage(){
|
|||||||
doBroadcastWithEcho "$msg"
|
doBroadcastWithEcho "$msg"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Checks if a player has requested an update cancel in the last 5 minutes
|
||||||
|
#
|
||||||
|
isUpdateCancelRequested(){
|
||||||
|
if [ -n "$chatCommandRestartCancel" ]; then
|
||||||
|
local canceltime="$(
|
||||||
|
find ~/ARK/server1/ShooterGame/Saved/Logs -name 'ServerGame.*.log' -mmin -5 -print0 |
|
||||||
|
xargs -0 grep -F -e "${chatCommandRestartCancel}" |
|
||||||
|
sed 's@^[[]\(....\)\.\(..\)\.\(..\)-\(..\)\.\(..\)\.\(..\):.*@\1-\2-\3 \4:\5:\6 UTC@' |
|
||||||
|
head -n1)"
|
||||||
|
if [ -n canceltime ]; then
|
||||||
|
canceltime="$(date +%s --date="${canceltime}")"
|
||||||
|
local timenow="$(date +%s --date="now - 5 minutes")"
|
||||||
|
if (( canceltime > timenow )); then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Waits for a configurable number of minutes before updating the server
|
# Waits for a configurable number of minutes before updating the server
|
||||||
#
|
#
|
||||||
@ -1103,11 +1195,18 @@ doWarn(){
|
|||||||
for (( min = warnminutes; min >= warninterval; min-- )); do
|
for (( min = warnminutes; min >= warninterval; min-- )); do
|
||||||
numplayers=$(numPlayersConnected)
|
numplayers=$(numPlayersConnected)
|
||||||
echo "There are ${numplayers} players connected"
|
echo "There are ${numplayers} players connected"
|
||||||
if (( (numplayers + 0) == 0 )); then
|
if [[ "numplayers" == "-1" ]]; then
|
||||||
|
echo "Server is not running. Shutting down immediately"
|
||||||
|
return 0
|
||||||
|
elif (( (numplayers + 0) == 0 )); then
|
||||||
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/.ark-warn.lock"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
if isUpdateCancelRequested; then
|
||||||
|
doBroadcastWithEcho "Restart cancelled by player request"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
wait $sleeppid
|
wait $sleeppid
|
||||||
if (( $min > $warninterval )); then
|
if (( $min > $warninterval )); then
|
||||||
sleep 1m &
|
sleep 1m &
|
||||||
@ -1132,11 +1231,18 @@ doWarn(){
|
|||||||
if (( warnseconds >= 20 )); then
|
if (( warnseconds >= 20 )); then
|
||||||
numplayers=$(numPlayersConnected)
|
numplayers=$(numPlayersConnected)
|
||||||
echo "There are ${numplayers} players connected"
|
echo "There are ${numplayers} players connected"
|
||||||
if (( (numplayers + 0) == 0 )); then
|
if [[ "numplayers" == "-1" ]]; then
|
||||||
|
echo "Server is not running. Shutting down immediately"
|
||||||
|
return 0
|
||||||
|
elif (( (numplayers + 0) == 0 )); then
|
||||||
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/.ark-warn.lock"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
if isUpdateCancelRequested; then
|
||||||
|
doBroadcastWithEcho "Restart cancelled by player request"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
wait $sleeppid
|
wait $sleeppid
|
||||||
warnseconds=$warninterval
|
warnseconds=$warninterval
|
||||||
@ -1169,34 +1275,24 @@ doUpdate() {
|
|||||||
local nodownload=
|
local nodownload=
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ "$arg" == "--force" ]; then
|
case "$arg" in
|
||||||
appupdate=1
|
--force) appupdate=1; ;;
|
||||||
elif [ "$arg" == "--safe" ]; then
|
--safe) updatetype=safe; ;;
|
||||||
updatetype=safe
|
--warn) updatetype=warn; ;;
|
||||||
elif [ "$arg" == "--warn" ]; then
|
--ifempty) updatetype=ifempty; ;;
|
||||||
updatetype=warn
|
--warnreason=*) warnreason="${arg#--warnreason=}"; updatetype=warn; ;;
|
||||||
elif [ "$arg" == "--ifempty" ]; then
|
--validate) validate=validate; appupdate=1; ;;
|
||||||
updatetype=ifempty
|
--saveworld) saveworld=1; ;;
|
||||||
elif [ "$arg" == "--validate" ]; then
|
--update-mods) modupdate=1; ;;
|
||||||
validate=validate
|
--backup) arkBackupPreUpdate=true; ;;
|
||||||
appupdate=1
|
--stagingdir=*) arkStagingDir="${arg#--stagingdir=}"; ;;
|
||||||
elif [ "$arg" == "--saveworld" ]; then
|
--downloadonly) downloadonly=1; ;;
|
||||||
saveworld=1
|
--no-download) nodownload=1; ;;
|
||||||
elif [ "$arg" == "--update-mods" ]; then
|
*)
|
||||||
modupdate=1
|
echo "Unrecognized option $arg"
|
||||||
elif [ "$arg" == "--backup" ]; then
|
echo "Try 'arkmanager -h' or 'arkmanager --help' for more information."
|
||||||
arkBackupPreUpdate=true
|
exit 1
|
||||||
elif [[ "$arg" =~ "^--stagingdir=" ]]; then
|
esac
|
||||||
arkStagingDir="${ark#--stagingdir=}"
|
|
||||||
elif [ "$arg" == "--downloadonly" ]; then
|
|
||||||
downloadonly=1
|
|
||||||
elif [ "$arg" == "--no-download" ]; then
|
|
||||||
nodownload=1
|
|
||||||
else
|
|
||||||
echo "Unrecognized option $arg"
|
|
||||||
echo "Try 'arkmanager -h' or 'arkmanager --help' for more information."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$$" >"${arkserverroot}/.ark-update.lock.$$" 2>/dev/null
|
echo "$$" >"${arkserverroot}/.ark-update.lock.$$" 2>/dev/null
|
||||||
@ -1247,6 +1343,7 @@ doUpdate() {
|
|||||||
fi
|
fi
|
||||||
rm -rf "$arkStagingDir/ShooterGame/Content/Mods/"*
|
rm -rf "$arkStagingDir/ShooterGame/Content/Mods/"*
|
||||||
rm -rf "$arkStagingDir/ShooterGame/Saved/"*
|
rm -rf "$arkStagingDir/ShooterGame/Saved/"*
|
||||||
|
rm -rf "$arkStagingDir/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$nodownload" ]; then
|
if [ -z "$nodownload" ]; then
|
||||||
@ -1347,7 +1444,7 @@ doUpdate() {
|
|||||||
echo "`timestamp`: update to $instver complete" >> "$logdir/update.log"
|
echo "`timestamp`: update to $instver complete" >> "$logdir/update.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$modupdate" ]; then
|
if [ -n "$modupdate" ] && [ -z "$arkflag_automanagedmods" ]; then
|
||||||
for modid in $(getModIds); do
|
for modid in $(getModIds); do
|
||||||
if isModUpdateNeeded $modid; then
|
if isModUpdateNeeded $modid; then
|
||||||
echo "Updating mod $modid"
|
echo "Updating mod $modid"
|
||||||
@ -1386,6 +1483,10 @@ getModIds(){
|
|||||||
#
|
#
|
||||||
doDownloadMod(){
|
doDownloadMod(){
|
||||||
local modid=$1
|
local modid=$1
|
||||||
|
local steamcmdroot="$steamcmdroot"
|
||||||
|
if [ -n "$arkflag_automanagedmods" ]; then
|
||||||
|
steamcmdroot="$arkserverroot/Engine/Binaries/ThirdParty/SteamCMD/Linux"
|
||||||
|
fi
|
||||||
local modsrcdir="$steamcmdroot/steamapps/workshop/content/$mod_appid/$modid"
|
local modsrcdir="$steamcmdroot/steamapps/workshop/content/$mod_appid/$modid"
|
||||||
local moddldir="$steamcmdroot/steamapps/workshop/downloads/$mod_appid"
|
local moddldir="$steamcmdroot/steamapps/workshop/downloads/$mod_appid"
|
||||||
cd "$steamcmdroot"
|
cd "$steamcmdroot"
|
||||||
@ -1904,6 +2005,7 @@ doInstallCronJob(){
|
|||||||
cmdopts="${arkCronExtraOpts}"
|
cmdopts="${arkCronExtraOpts}"
|
||||||
cmdargs=""
|
cmdargs=""
|
||||||
output=">/dev/null 2>&1"
|
output=">/dev/null 2>&1"
|
||||||
|
arkmanagerpath="${0}"
|
||||||
command="$1"
|
command="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
@ -1924,7 +2026,7 @@ doInstallCronJob(){
|
|||||||
output=
|
output=
|
||||||
;;
|
;;
|
||||||
--arg=*)
|
--arg=*)
|
||||||
cmdargs="${cmdargs} $(printf "%q" "${opt#--opt=}")"
|
cmdargs="${cmdargs} $(printf "%q" "${opt#--arg=}")"
|
||||||
;;
|
;;
|
||||||
--*)
|
--*)
|
||||||
cmdopts="${cmdopts} $(printf "%q" "${opt}")"
|
cmdopts="${cmdopts} $(printf "%q" "${opt}")"
|
||||||
@ -1935,10 +2037,10 @@ doInstallCronJob(){
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
cronjob="${minute} ${hour} * * * arkmanager --cronjob ${command} @${instance} ${cmdopts} --args ${cmdargs} -- ${output}"
|
cronjob="${minute} ${hour} * * * ${arkmanagerpath} --cronjob ${command} @${instance} ${cmdopts} --args ${cmdargs} -- ${output}"
|
||||||
|
|
||||||
(crontab -l | \
|
(crontab -l | \
|
||||||
sed -e "/ [*] [*] [*] arkmanager --cronjob ${command} @${instance} /d";
|
sed -e "\\# [*] [*] [*] ${arkmanagerpath} --cronjob ${command} @${instance} #d";
|
||||||
echo "${cronjob}" ) | \
|
echo "${cronjob}" ) | \
|
||||||
crontab -
|
crontab -
|
||||||
}
|
}
|
||||||
@ -1947,10 +2049,11 @@ doInstallCronJob(){
|
|||||||
# Removes an installed cron job
|
# Removes an installed cron job
|
||||||
#
|
#
|
||||||
doRemoveCronJob(){
|
doRemoveCronJob(){
|
||||||
|
arkmanagerpath="${0}"
|
||||||
command="$1"
|
command="$1"
|
||||||
|
|
||||||
crontab -l | \
|
crontab -l | \
|
||||||
sed -e "/ [*] [*] [*] arkmanager --cronjob ${command} @${instance} /d" | \
|
sed -e "\\# [*] [*] [*] ${arkmanagerpath} --cronjob ${command} @${instance} #d" | \
|
||||||
crontab -
|
crontab -
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1981,6 +2084,18 @@ printStatus(){
|
|||||||
my $maxplayers = ord(substr($rest, 3, 1));
|
my $maxplayers = ord(substr($rest, 3, 1));
|
||||||
print "Server Name: $servername\n";
|
print "Server Name: $servername\n";
|
||||||
print "Players: $players / $maxplayers\n";
|
print "Players: $players / $maxplayers\n";
|
||||||
|
send($socket, "\xff\xff\xff\xff\x55\xff\xff\xff\xff", 0, $sockaddr);
|
||||||
|
$data = "";
|
||||||
|
recv($socket, $data, 1400, 0) or (print "Challenge request failed" and exit(1));
|
||||||
|
if (ord(substr($data, 4, 1)) == 0x41) {
|
||||||
|
my $chal = substr($data, 5);
|
||||||
|
send($socket, "\xff\xff\xff\xff\x55" . $chal, 0, $sockaddr);
|
||||||
|
$data = "";
|
||||||
|
recv($socket, $data, 1400, 0) or (print "A2S_PLAYERS request failed" and exit(1));
|
||||||
|
}
|
||||||
|
ord(substr($data, 4, 1)) != 0x44 and (print ("A2S_PLAYERS Response: : " . unpack("H*", $data)) and exit(1));
|
||||||
|
my $players = ord(substr($data, 5, 1));
|
||||||
|
print "Active Players: $players\n";
|
||||||
' "$(getQueryPort)" "${ark_MultiHome:-127.0.0.1}"
|
' "$(getQueryPort)" "${ark_MultiHome:-127.0.0.1}"
|
||||||
|
|
||||||
if isTheServerOnline; then
|
if isTheServerOnline; then
|
||||||
@ -2034,6 +2149,23 @@ doListAllInstances(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doPrintConfig(){
|
||||||
|
declare -A vars
|
||||||
|
declare -A vals
|
||||||
|
for v in $(eval echo \$\{\!{a..z}\*\} \$\{\!{A..Z}\*\} \$\{\!_\*\}); do
|
||||||
|
vals["$v"]="${!v}"
|
||||||
|
done
|
||||||
|
for cfgfile in "$configfile" "$HOME/.arkmanager.cfg" "/etc/arkmanager/arkmanager.cfg"; do
|
||||||
|
while read v; do
|
||||||
|
val="$(source "$cfgfile"; echo "${!v}")"
|
||||||
|
if [[ "$val" = "${vals[$v]}" && -z "${vars[$v]}" ]]; then
|
||||||
|
vars["$v"]="$cfgfile"
|
||||||
|
echo "${cfgfile} => ${v}"
|
||||||
|
fi
|
||||||
|
done < <(sed -n 's/^[[:space:]]*\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' <"$cfgfile")
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
useConfig() {
|
useConfig() {
|
||||||
configfile=
|
configfile=
|
||||||
if [ -f "/etc/arkmanager/instances/${1}.cfg" ]; then
|
if [ -f "/etc/arkmanager/instances/${1}.cfg" ]; then
|
||||||
@ -2323,6 +2455,9 @@ main(){
|
|||||||
rconcmd)
|
rconcmd)
|
||||||
rconcmd "${args[@]}"
|
rconcmd "${args[@]}"
|
||||||
;;
|
;;
|
||||||
|
printconfig)
|
||||||
|
doPrintConfig
|
||||||
|
;;
|
||||||
status)
|
status)
|
||||||
printStatus
|
printStatus
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -32,6 +32,10 @@ msgWarnRestartMinutes="This ARK server will shutdown for a restart in %d minutes
|
|||||||
msgWarnRestartSeconds="This ARK server will shutdown for a restart in %d seconds"
|
msgWarnRestartSeconds="This ARK server will shutdown for a restart in %d seconds"
|
||||||
msgWarnShutdownMinutes="This ARK server will shutdown in %d minutes"
|
msgWarnShutdownMinutes="This ARK server will shutdown in %d minutes"
|
||||||
msgWarnShutdownSeconds="This ARK server will shutdown in %d seconds"
|
msgWarnShutdownSeconds="This ARK server will shutdown in %d seconds"
|
||||||
|
msgWarnCancelled="Restart cancelled by player request"
|
||||||
|
|
||||||
|
# Restart cancel chat command
|
||||||
|
#chatCommandRestartCancel="/cancelupdate"
|
||||||
|
|
||||||
# ARK server common options - use ark_<optionname>=<value>
|
# ARK server common options - use ark_<optionname>=<value>
|
||||||
# comment out these values if you want to define them
|
# comment out these values if you want to define them
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
userinstall=no
|
userinstall=no
|
||||||
steamcmd_user=
|
steamcmd_user=
|
||||||
showusage=no
|
showusage=no
|
||||||
|
migrateconfig=no
|
||||||
|
|
||||||
while [ -n "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -63,6 +64,9 @@ while [ -n "$1" ]; do
|
|||||||
DATADIR="$2"
|
DATADIR="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--migrate-config)
|
||||||
|
migrateconfig=yes
|
||||||
|
;;
|
||||||
-*)
|
-*)
|
||||||
echo "Invalid option '$1'"
|
echo "Invalid option '$1'"
|
||||||
showusage=yes
|
showusage=yes
|
||||||
@ -169,7 +173,7 @@ if [ "$userinstall" == "yes" ]; then
|
|||||||
"${INSTALL_ROOT}${INSTANCEDIR}/instance.cfg.example"
|
"${INSTALL_ROOT}${INSTANCEDIR}/instance.cfg.example"
|
||||||
|
|
||||||
# Copy arkmanager.cfg to ~/.arkmanager.cfg.NEW
|
# Copy arkmanager.cfg to ~/.arkmanager.cfg.NEW
|
||||||
cp arkmanager.cfg "${INSTALL_ROOT}${CONFIGFILE}.NEW"
|
cp arkmanager.cfg "${INSTALL_ROOT}${CONFIGFILE}.example"
|
||||||
# Change the defaults in the new config file
|
# Change the defaults in the new config file
|
||||||
sed -i -e "s|^steamcmd_user=\"steam\"|steamcmd_user=\"--me\"|" \
|
sed -i -e "s|^steamcmd_user=\"steam\"|steamcmd_user=\"--me\"|" \
|
||||||
-e "s|\"/home/steam|\"${PREFIX}|" \
|
-e "s|\"/home/steam|\"${PREFIX}|" \
|
||||||
@ -177,18 +181,24 @@ if [ "$userinstall" == "yes" ]; then
|
|||||||
-e "s|^install_bindir=.*|install_bindir=\"${BINDIR}\"|" \
|
-e "s|^install_bindir=.*|install_bindir=\"${BINDIR}\"|" \
|
||||||
-e "s|^install_libexecdir=.*|install_libexecdir=\"${LIBEXECDIR}\"|" \
|
-e "s|^install_libexecdir=.*|install_libexecdir=\"${LIBEXECDIR}\"|" \
|
||||||
-e "s|^install_datadir=.*|install_datadir=\"${DATADIR}\"|" \
|
-e "s|^install_datadir=.*|install_datadir=\"${DATADIR}\"|" \
|
||||||
"${INSTALL_ROOT}${CONFIGFILE}.NEW"
|
"${INSTALL_ROOT}${CONFIGFILE}.example"
|
||||||
|
|
||||||
# Copy arkmanager.cfg to ~/.arkmanager.cfg if it doesn't already exist
|
# Copy arkmanager.cfg to ~/.arkmanager.cfg if it doesn't already exist
|
||||||
if [ -f "${INSTALL_ROOT}${CONFIGFILE}" ]; then
|
if [ -f "${INSTALL_ROOT}${CONFIGFILE}" ]; then
|
||||||
bash ./migrate-config.sh "${INSTALL_ROOT}${CONFIGFILE}"
|
SUFFIX=
|
||||||
bash ./migrate-main-instance.sh "${INSTALL_ROOT}${CONFIGFILE}" "${INSTALL_ROOT}${INSTANCEDIR}/main.cfg"
|
if [ "$migrateconfig" = "no" ]; then
|
||||||
|
SUFFIX=".NEW"
|
||||||
|
cp "${INSTALL_ROOT}${CONFIGFILE}" "${INSTALL_ROOT}${CONFIGFILE}${SUFFIX}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash ./migrate-config.sh "${INSTALL_ROOT}${CONFIGFILE}${SUFFIX}"
|
||||||
|
bash ./migrate-main-instance.sh "${INSTALL_ROOT}${CONFIGFILE}${SUFFIX}" "${INSTALL_ROOT}${INSTANCEDIR}/main.cfg${SUFFIX}"
|
||||||
|
|
||||||
echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it."
|
echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it."
|
||||||
echo "A copy of the new configuration file was included in '${CONFIGFILE}.NEW'. Make sure to review any changes and update your config accordingly!"
|
echo "A copy of the new configuration file was included in '${CONFIGFILE}.NEW'. Make sure to review any changes and update your config accordingly!"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
mv -n "${INSTALL_ROOT}${CONFIGFILE}.NEW" "${INSTALL_ROOT}${CONFIGFILE}"
|
cp -n "${INSTALL_ROOT}${CONFIGFILE}.example" "${INSTALL_ROOT}${CONFIGFILE}"
|
||||||
cp -n "${INSTALL_ROOT}/${INSTANCEDIR}/instance.cfg.example" "${INSTALL_ROOT}/${INSTANCEDIR}/main.cfg"
|
cp -n "${INSTALL_ROOT}/${INSTANCEDIR}/instance.cfg.example" "${INSTALL_ROOT}/${INSTANCEDIR}/main.cfg"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -301,24 +311,30 @@ else
|
|||||||
# Copy arkmanager.cfg inside linux configuation folder if it doesn't already exists
|
# Copy arkmanager.cfg inside linux configuation folder if it doesn't already exists
|
||||||
mkdir -p "${INSTALL_ROOT}/etc/arkmanager"
|
mkdir -p "${INSTALL_ROOT}/etc/arkmanager"
|
||||||
chown "$steamcmd_user" "${INSTALL_ROOT}/etc/arkmanager"
|
chown "$steamcmd_user" "${INSTALL_ROOT}/etc/arkmanager"
|
||||||
cp arkmanager.cfg "${INSTALL_ROOT}${CONFIGFILE}.NEW"
|
cp arkmanager.cfg "${INSTALL_ROOT}${CONFIGFILE}.example"
|
||||||
chown "$steamcmd_user" "${INSTALL_ROOT}${CONFIGFILE}.NEW"
|
chown "$steamcmd_user" "${INSTALL_ROOT}${CONFIGFILE}.example"
|
||||||
sed -i -e "s|^steamcmd_user=\"steam\"|steamcmd_user=\"$steamcmd_user\"|" \
|
sed -i -e "s|^steamcmd_user=\"steam\"|steamcmd_user=\"$steamcmd_user\"|" \
|
||||||
-e "s|\"/home/steam|\"/home/$steamcmd_user|" \
|
-e "s|\"/home/steam|\"/home/$steamcmd_user|" \
|
||||||
-e "s|^install_bindir=.*|install_bindir=\"${BINDIR}\"|" \
|
-e "s|^install_bindir=.*|install_bindir=\"${BINDIR}\"|" \
|
||||||
-e "s|^install_libexecdir=.*|install_libexecdir=\"${LIBEXECDIR}\"|" \
|
-e "s|^install_libexecdir=.*|install_libexecdir=\"${LIBEXECDIR}\"|" \
|
||||||
-e "s|^install_datadir=.*|install_datadir=\"${DATADIR}\"|" \
|
-e "s|^install_datadir=.*|install_datadir=\"${DATADIR}\"|" \
|
||||||
"${INSTALL_ROOT}${CONFIGFILE}.NEW"
|
"${INSTALL_ROOT}${CONFIGFILE}.example"
|
||||||
|
|
||||||
if [ -f "${INSTALL_ROOT}${CONFIGFILE}" ]; then
|
if [ -f "${INSTALL_ROOT}${CONFIGFILE}" ]; then
|
||||||
bash ./migrate-config.sh "${INSTALL_ROOT}${CONFIGFILE}"
|
SUFFIX=
|
||||||
bash ./migrate-main-instance.sh "${INSTALL_ROOT}${CONFIGFILE}" "${INSTALL_ROOT}${INSTANCEDIR}/main.cfg"
|
if [ "$migrateconfig" = "no" ]; then
|
||||||
|
SUFFIX=".NEW"
|
||||||
|
cp "${INSTALL_ROOT}${CONFIGFILE}" "${INSTALL_ROOT}${CONFIGFILE}${SUFFIX}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash ./migrate-config.sh "${INSTALL_ROOT}${CONFIGFILE}${SUFFIX}"
|
||||||
|
bash ./migrate-main-instance.sh "${INSTALL_ROOT}${CONFIGFILE}${SUFFIX}" "${INSTALL_ROOT}${INSTANCEDIR}/main.cfg${SUFFIX}"
|
||||||
|
|
||||||
echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it."
|
echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it."
|
||||||
echo "A copy of the new configuration file was included in /etc/arkmanager. Make sure to review any changes and update your config accordingly!"
|
echo "A copy of the new configuration file was included in /etc/arkmanager. Make sure to review any changes and update your config accordingly!"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
mv -n "${INSTALL_ROOT}${CONFIGFILE}.NEW" "${INSTALL_ROOT}${CONFIGFILE}"
|
cp -n "${INSTALL_ROOT}${CONFIGFILE}.example" "${INSTALL_ROOT}${CONFIGFILE}"
|
||||||
cp -n "${INSTALL_ROOT}/${INSTANCEDIR}/instance.cfg.example" "${INSTALL_ROOT}/${INSTANCEDIR}/main.cfg"
|
cp -n "${INSTALL_ROOT}/${INSTANCEDIR}/instance.cfg.example" "${INSTALL_ROOT}/${INSTANCEDIR}/main.cfg"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -5,7 +5,8 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/libexec/arkmanager/arkmanager.init start
|
ExecStart=/usr/libexec/arkmanager/arkmanager.init start
|
||||||
ExecStop=/usr/libexec/arkmanager/arkmanager.init stop
|
ExecStop=/usr/libexec/arkmanager/arkmanager.init stop
|
||||||
Type=oneshot
|
Type=forking
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user