Add arkserverdir setting

On servers other than the ARK server, this should be set
to the base directory name (e.g. Citadel for the Citadel server)
This commit is contained in:
Ben Peddell 2017-08-17 01:17:19 +10:00
parent 4ec1152291
commit 19f47f244b

View File

@ -298,7 +298,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}/${arkserverdir}/Saved/${ark_AltSaveDirectoryName:-SavedArks}"
mkdir -p "${savedarksdir}" 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"
@ -307,9 +307,9 @@ checkConfig() {
if [ "$1" != "installmod" ] && [ "$1" != "installmods" ]; then if [ "$1" != "installmod" ] && [ "$1" != "installmods" ]; then
# Warn if any mods are requested but not installed # Warn if any mods are requested but not installed
if [ -n "$arkserverroot" -a -d "${arkserverroot}/ShooterGame/Content/Mods" ]; then if [ -n "$arkserverroot" -a -d "${arkserverroot}/${arkserverdir}/Content/Mods" ]; then
for modid in $(getModIds); do for modid in $(getModIds); do
if [ ! -f "${arkserverroot}/ShooterGame/Content/Mods/${modid}/mod.info" ]; then if [ ! -f "${arkserverroot}/${arkserverdir}/Content/Mods/${modid}/mod.info" ]; then
echo -e "[" "$RED" "ERROR" "$NORMAL" "]" "\tMod ${modid} is requested but not installed. Run 'arkmanager installmod ${modid}' to install this mod." echo -e "[" "$RED" "ERROR" "$NORMAL" "]" "\tMod ${modid} is requested but not installed. Run 'arkmanager installmod ${modid}' to install this mod."
fi fi
done done
@ -339,7 +339,7 @@ getArkServerSetting() {
if [ -n "${!varname}" ]; then if [ -n "${!varname}" ]; then
echo "${!varname}" echo "${!varname}"
else else
local val="$(tr -d '\0\376\377' <"${arkserverroot}/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini" | sed -n '/^\[ServerSettings\]/,/^\[.*\]/{s/^'"$1"'[[:space:]]*=[[:space:]]*//p;}' )" local val="$(tr -d '\0\376\377' <"${arkserverroot}/${arkserverdir}/Saved/Config/LinuxServer/GameUserSettings.ini" | sed -n '/^\[ServerSettings\]/,/^\[.*\]/{s/^'"$1"'[[:space:]]*=[[:space:]]*//p;}' )"
if [ -n "$val" ]; then if [ -n "$val" ]; then
echo "$val" echo "$val"
else else
@ -637,7 +637,7 @@ function getServerMapName(){
my $mapfilelen = unpack("@" . ($mapnamelen + 4) . " L<", $data); my $mapfilelen = unpack("@" . ($mapnamelen + 4) . " L<", $data);
my $mapfile = substr($data, $mapnamelen + 8, $mapfilelen - 1); my $mapfile = substr($data, $mapnamelen + 8, $mapfilelen - 1);
print $mapfile; print $mapfile;
' <"${arkserverroot}/ShooterGame/Content/Mods/${serverMapModId}/mod.info")" ' <"${arkserverroot}/${arkserverdir}/Content/Mods/${serverMapModId}/mod.info")"
fi fi
echo "${mapname##*/}" echo "${mapname##*/}"
@ -930,7 +930,7 @@ doRun() {
my $mapfilelen = unpack("@" . ($mapnamelen + 4) . " L<", $data); my $mapfilelen = unpack("@" . ($mapnamelen + 4) . " L<", $data);
my $mapfile = substr($data, $mapnamelen + 8, $mapfilelen - 1); my $mapfile = substr($data, $mapnamelen + 8, $mapfilelen - 1);
print $mapfile; print $mapfile;
' <"${arkserverroot}/ShooterGame/Content/Mods/${serverMapModId}/mod.info")" ' <"${arkserverroot}/${arkserverdir}/Content/Mods/${serverMapModId}/mod.info")"
arkserveropts="${serverMap}?MapModID=${serverMapModId}" arkserveropts="${serverMap}?MapModID=${serverMapModId}"
fi fi
@ -1471,7 +1471,7 @@ printWarnMessage(){
isUpdateCancelRequested(){ isUpdateCancelRequested(){
if [ -n "$chatCommandRestartCancel" ]; then if [ -n "$chatCommandRestartCancel" ]; then
local canceltime="$( local canceltime="$(
find "${arkserverroot}/ShooterGame/Saved/Logs" -name 'ServerGame.*.log' -mmin -5 -print0 | find "${arkserverroot}/${arkserverdir}/Saved/Logs" -name 'ServerGame.*.log' -mmin -5 -print0 |
xargs -0 grep -F -e "${chatCommandRestartCancel}" | xargs -0 grep -F -e "${chatCommandRestartCancel}" |
sed 's@^[[]\(....\)\.\(..\)\.\(..\)-\(..\)\.\(..\)\.\(..\):.*@\1-\2-\3 \4:\5:\6 UTC@' | sed 's@^[[]\(....\)\.\(..\)\.\(..\)-\(..\)\.\(..\)\.\(..\):.*@\1-\2-\3 \4:\5:\6 UTC@' |
head -n1)" head -n1)"
@ -1706,35 +1706,35 @@ doUpdate() {
appupdate=1 appupdate=1
if [ -n "${arkStagingDir}" -a "${arkStagingDir}" != "${arkserverroot}" ]; then if [ -n "${arkStagingDir}" -a "${arkStagingDir}" != "${arkserverroot}" ]; then
if [ ! -d "$arkStagingDir/ShooterGame" ]; then if [ ! -d "$arkStagingDir/${arkserverdir}" ]; then
logprint "Copying to staging directory" logprint "Copying to staging directory"
mkdir -p "$arkStagingDir" mkdir -p "$arkStagingDir"
if [ "$(stat -c "%d" "$arkserverroot")" == "$(stat -c "%d" "$arkStagingDir")" ]; then if [ "$(stat -c "%d" "$arkserverroot")" == "$(stat -c "%d" "$arkStagingDir")" ]; then
if [ -n "$useRefLinks" ]; then if [ -n "$useRefLinks" ]; then
cp -a --reflink=always "$arkserverroot/ShooterGame/." "$arkStagingDir/ShooterGame" cp -a --reflink=always "$arkserverroot/${arkserverdir}/." "$arkStagingDir/${arkserverdir}"
cp -a --reflink=always "$arkserverroot/Engine/." "$arkStagingDir/Engine" cp -a --reflink=always "$arkserverroot/Engine/." "$arkStagingDir/Engine"
cp -a --reflink=always "$arkserverroot/linux64/." "$arkStagingDir/linux64" cp -a --reflink=always "$arkserverroot/linux64/." "$arkStagingDir/linux64"
cp -a --reflink=always "$arkserverroot/ShooterGame/Content/Mods/111111111/." "$arkStagingDir/ShooterGame/Content/Mods/111111111" cp -a --reflink=always "$arkserverroot/${arkserverdir}/Content/Mods/111111111/." "$arkStagingDir/${arkserverdir}/Content/Mods/111111111"
cp --reflink=always "$arkserverroot/ShooterGame/Content/Mods/111111111.mod" "$arkStagingDir/ShooterGame/Content/Mods/111111111.mod" cp --reflink=always "$arkserverroot/${arkserverdir}/Content/Mods/111111111.mod" "$arkStagingDir/${arkserverdir}/Content/Mods/111111111.mod"
cp --reflink=always "$arkserverroot/"* "$arkStagingDir" >/dev/null 2>&1 cp --reflink=always "$arkserverroot/"* "$arkStagingDir" >/dev/null 2>&1
cp -a --reflink=always "$arkserverroot/steamapps/." "$arkStagingDir/steamapps" cp -a --reflink=always "$arkserverroot/steamapps/." "$arkStagingDir/steamapps"
else else
cp -al "$arkserverroot/ShooterGame/." "$arkStagingDir/ShooterGame" cp -al "$arkserverroot/${arkserverdir}/." "$arkStagingDir/${arkserverdir}"
cp -al "$arkserverroot/Engine/." "$arkStagingDir/Engine" cp -al "$arkserverroot/Engine/." "$arkStagingDir/Engine"
cp -al "$arkserverroot/linux64/." "$arkStagingDir/linux64" cp -al "$arkserverroot/linux64/." "$arkStagingDir/linux64"
cp -al "$arkserverroot/ShooterGame/Content/Mods/111111111/." "$arkStagingDir/ShooterGame/Content/Mods/111111111" cp -al "$arkserverroot/${arkserverdir}/Content/Mods/111111111/." "$arkStagingDir/${arkserverdir}/Content/Mods/111111111"
cp -l "$arkserverroot/ShooterGame/Content/Mods/111111111.mod" "$arkStagingDir/ShooterGame/Content/Mods/111111111.mod" cp -l "$arkserverroot/${arkserverdir}/Content/Mods/111111111.mod" "$arkStagingDir/${arkserverdir}/Content/Mods/111111111.mod"
cp -l "$arkserverroot/"* "$arkStagingDir" >/dev/null 2>&1 cp -l "$arkserverroot/"* "$arkStagingDir" >/dev/null 2>&1
cp -a "$arkserverroot/steamapps/." "$arkStagingDir/steamapps" cp -a "$arkserverroot/steamapps/." "$arkStagingDir/steamapps"
fi fi
else else
rsync -a "$arkserverroot/." "$arkStagingDir/." rsync -a "$arkserverroot/." "$arkStagingDir/."
fi fi
rm -rf "$arkStagingDir/ShooterGame/Content/Mods/"* rm -rf "$arkStagingDir/${arkserverdir}/Content/Mods/"*
rm -rf "$arkStagingDir/ShooterGame/Saved/"* rm -rf "$arkStagingDir/${arkserverdir}/Saved/"*
rm -rf "$arkStagingDir/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps" rm -rf "$arkStagingDir/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps"
fi fi
rm -f "$arkStagingDir/ShooterGame/Binaries/Linux/"*.txt rm -f "$arkStagingDir/${arkserverdir}/Binaries/Linux/"*.txt
if [ -z "$nodownload" ]; then if [ -z "$nodownload" ]; then
echo -n "Downloading ARK update" echo -n "Downloading ARK update"
@ -1790,7 +1790,7 @@ doUpdate() {
if isTheServerRunning; then if isTheServerRunning; then
if [ "$updatetype" == "safe" ]; then if [ "$updatetype" == "safe" ]; then
saverootdir="${arkserverroot}/ShooterGame/Saved" saverootdir="${arkserverroot}/${arkserverdir}/Saved"
savedir="$(getSavedArksDirectory "${saverootdir}")" savedir="$(getSavedArksDirectory "${saverootdir}")"
mapname="$(getServerMapName)" mapname="$(getServerMapName)"
maxwait=30 maxwait=30
@ -1846,13 +1846,13 @@ doUpdate() {
logprint "Applying update from staging directory" logprint "Applying update from staging directory"
if [ "$(stat -c "%d" "$arkserverroot")" == "$(stat -c "%d" "$arkStagingDir")" ]; then if [ "$(stat -c "%d" "$arkserverroot")" == "$(stat -c "%d" "$arkStagingDir")" ]; then
if [ -n "$useRefLinks" ]; then if [ -n "$useRefLinks" ]; then
cp -au --reflink=always --remove-destination "$arkStagingDir/ShooterGame/." "$arkserverroot/ShooterGame" cp -au --reflink=always --remove-destination "$arkStagingDir/${arkserverdir}/." "$arkserverroot/${arkserverdir}"
cp -au --reflink=always --remove-destination "$arkStagingDir/Engine/." "$arkserverroot/Engine" cp -au --reflink=always --remove-destination "$arkStagingDir/Engine/." "$arkserverroot/Engine"
cp -au --reflink=always --remove-destination "$arkStagingDir/linux64/." "$arkserverroot/linux64" cp -au --reflink=always --remove-destination "$arkStagingDir/linux64/." "$arkserverroot/linux64"
cp -u --reflink=always --remove-destination "$arkStagingDir/"* "$arkserverroot" >/dev/null 2>&1 cp -u --reflink=always --remove-destination "$arkStagingDir/"* "$arkserverroot" >/dev/null 2>&1
cp -au --reflink=always --remove-destination "$arkStagingDir/steamapps/." "$arkserverroot/steamapps" cp -au --reflink=always --remove-destination "$arkStagingDir/steamapps/." "$arkserverroot/steamapps"
else else
cp -alu --remove-destination "$arkStagingDir/ShooterGame/." "$arkserverroot/ShooterGame" cp -alu --remove-destination "$arkStagingDir/${arkserverdir}/." "$arkserverroot/${arkserverdir}"
cp -alu --remove-destination "$arkStagingDir/Engine/." "$arkserverroot/Engine" cp -alu --remove-destination "$arkStagingDir/Engine/." "$arkserverroot/Engine"
cp -alu --remove-destination "$arkStagingDir/linux64/." "$arkserverroot/linux64" cp -alu --remove-destination "$arkStagingDir/linux64/." "$arkserverroot/linux64"
cp -lu --remove-destination "$arkStagingDir/"* "$arkserverroot" >/dev/null 2>&1 cp -lu --remove-destination "$arkStagingDir/"* "$arkserverroot" >/dev/null 2>&1
@ -1862,8 +1862,8 @@ doUpdate() {
rsync -a "$arkStagingDir/." "$arkserverroot" rsync -a "$arkStagingDir/." "$arkserverroot"
fi fi
cd "$arkserverroot" cd "$arkserverroot"
find Engine ShooterGame linux64 -depth -print | find Engine ${arkserverdir} linux64 -depth -print |
grep -v '^\(ShooterGame/\(Saved\|Content/Mods\|Binaries/Linux/.*\.txt\)\|Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps\)' | grep -v '^\('"${arkserverdir}"'/\(Saved\|Content/Mods\|Binaries/Linux/.*\.txt\)\|Engine/Binaries/ThirdParty/SteamCMD/Linux/steamapps\)' |
while read f; do while read f; do
if [ ! -e "${arkStagingDir}/${f}" ]; then if [ ! -e "${arkStagingDir}/${f}" ]; then
if [ -f "$f" ]; then if [ -f "$f" ]; then
@ -1979,7 +1979,7 @@ checkForModUpdate(){
updateavail=1 updateavail=1
fi fi
fi fi
if [ ! -d "$arkserverroot/ShooterGame/Content/Mods/$modid" ]; then if [ ! -d "$arkserverroot/${arkserverdir}/Content/Mods/$modid" ]; then
printf "Mod %d [%s] is not installed\n" "$modid" "$modname" printf "Mod %d [%s] is not installed\n" "$modid" "$modname"
updateavail=1 updateavail=1
elif isModUpdateNeeded $modid; then elif isModUpdateNeeded $modid; then
@ -2013,7 +2013,7 @@ getModIds(){
fi fi
done done
if [ -z "$ignoreInstalledMods" ]; then if [ -z "$ignoreInstalledMods" ]; then
find "${arkserverroot}/ShooterGame/Content/Mods" -maxdepth 1 -type d -printf "%P\n" find "${arkserverroot}/${arkserverdir}/Content/Mods" -maxdepth 1 -type d -printf "%P\n"
fi fi
) | sort | uniq | grep '^[1-9][0-9]*$' | grep -v '^111111111$' ) | sort | uniq | grep '^[1-9][0-9]*$' | grep -v '^111111111$'
} }
@ -2141,7 +2141,7 @@ isModUpdateNeeded(){
local steamdataroot="${steamdataroot:-${steamcmdroot}}" local steamdataroot="${steamdataroot:-${steamcmdroot}}"
local steamworkshopdir="${steamworkshopdir:-${steamdataroot}/steamapps/workshop}" local steamworkshopdir="${steamworkshopdir:-${steamdataroot}/steamapps/workshop}"
local modsrcdir="${steamworkshopdir}/content/$mod_appid/$modid" local modsrcdir="${steamworkshopdir}/content/$mod_appid/$modid"
local moddestdir="$arkserverroot/ShooterGame/Content/Mods/$modid" local moddestdir="$arkserverroot/${arkserverdir}/Content/Mods/$modid"
local modbranch="${mod_branch:-Windows}" local modbranch="${mod_branch:-Windows}"
# Bypass the 111111111 modid used by Primitive+ # Bypass the 111111111 modid used by Primitive+
@ -2237,7 +2237,7 @@ doExtractMod(){
local steamdataroot="${steamdataroot:-${steamcmdroot}}" local steamdataroot="${steamdataroot:-${steamcmdroot}}"
local steamworkshopdir="${steamworkshopdir:-${steamdataroot}/steamapps/workshop}" local steamworkshopdir="${steamworkshopdir:-${steamdataroot}/steamapps/workshop}"
local modsrcdir="${steamworkshopdir}/content/$mod_appid/$modid" local modsrcdir="${steamworkshopdir}/content/$mod_appid/$modid"
local moddestdir="$arkserverroot/ShooterGame/Content/Mods/$modid" local moddestdir="$arkserverroot/${arkserverdir}/Content/Mods/$modid"
local modextractdir="$moddestdir" local modextractdir="$moddestdir"
local modbranch="${mod_branch:-Windows}" local modbranch="${mod_branch:-Windows}"
@ -2356,12 +2356,12 @@ doExtractMod(){
my $mapname = substr($data, 4, $mapnamelen - 1); my $mapname = substr($data, 4, $mapnamelen - 1);
my $nummaps = unpack("@" . ($mapnamelen + 4) . " L<", $data); my $nummaps = unpack("@" . ($mapnamelen + 4) . " L<", $data);
my $pos = $mapnamelen + 8; my $pos = $mapnamelen + 8;
my $modname = ($ARGV[1] || $mapname) . "\x00"; my $modname = ($ARGV[2] || $mapname) . "\x00";
my $modnamelen = length($modname); my $modnamelen = length($modname);
my $modpath = "../../../ShooterGame/Content/Mods/" . $ARGV[0] . "\x00"; my $modpath = "../../../" . $ARGV[0] . "/Content/Mods/" . $ARGV[1] . "\x00";
my $modpathlen = length($modpath); my $modpathlen = length($modpath);
print pack("L< L< L< Z$modnamelen L< Z$modpathlen L<", print pack("L< L< L< Z$modnamelen L< Z$modpathlen L<",
$ARGV[0], 0, $modnamelen, $modname, $modpathlen, $modpath, $ARGV[1], 0, $modnamelen, $modname, $modpathlen, $modpath,
$nummaps); $nummaps);
for (my $mapnum = 0; $mapnum < $nummaps; $mapnum++){ for (my $mapnum = 0; $mapnum < $nummaps; $mapnum++){
my $mapfilelen = unpack("@" . ($pos) . " L<", $data); my $mapfilelen = unpack("@" . ($pos) . " L<", $data);
@ -2370,7 +2370,7 @@ doExtractMod(){
$pos = $pos + 4 + $mapfilelen; $pos = $pos + 4 + $mapfilelen;
} }
print "\x33\xFF\x22\xFF\x02\x00\x00\x00\x01"; print "\x33\xFF\x22\xFF\x02\x00\x00\x00\x01";
' $modid "$modname" <"$modextractdir/mod.info" >"${modextractdir}.mod" ' "$arkserverdir" "$modid" "$modname" <"$modextractdir/mod.info" >"${modextractdir}.mod"
if [ -f "$modextractdir/modmeta.info" ]; then if [ -f "$modextractdir/modmeta.info" ]; then
cat "$modextractdir/modmeta.info" >>"${modextractdir}.mod" cat "$modextractdir/modmeta.info" >>"${modextractdir}.mod"
@ -2459,8 +2459,8 @@ doUninstallAllMods(){
doUninstallMod(){ doUninstallMod(){
local modid local modid
for modid in ${1//,/ }; do for modid in ${1//,/ }; do
local moddir="$arkserverroot/ShooterGame/Content/Mods/$modid" local moddir="$arkserverroot/${arkserverdir}/Content/Mods/$modid"
local modfile="$arkserverroot/ShooterGame/Content/Mods/${modid}.mod" local modfile="$arkserverroot/${arkserverdir}/Content/Mods/${modid}.mod"
if [ -d "${moddir}" ]; then if [ -d "${moddir}" ]; then
rm -rf "${moddir}" rm -rf "${moddir}"
fi fi
@ -2531,7 +2531,7 @@ doBackup(){
local daystamp=`date +"%Y-%m-%d"` local daystamp=`date +"%Y-%m-%d"`
local backupdir="${arkbackupdir}/${datestamp}" local backupdir="${arkbackupdir}/${datestamp}"
local backupdirdaily="${arkbackupdir}/${daystamp}" local backupdirdaily="${arkbackupdir}/${daystamp}"
local saverootdir="${arkserverroot}/ShooterGame/Saved" local saverootdir="${arkserverroot}/${arkserverdir}/Saved"
local savedcfgdir="${saverootdir}/Config/LinuxServer" local savedcfgdir="${saverootdir}/Config/LinuxServer"
local savedir="$(getSavedArksDirectory "${saverootdir}")" local savedir="$(getSavedArksDirectory "${saverootdir}")"
local mapname="$(getServerMapName)" local mapname="$(getServerMapName)"
@ -2918,15 +2918,16 @@ useConfig() {
echo "Error: arkserverroot not set" echo "Error: arkserverroot not set"
exit 1 exit 1
fi fi
arkautorestartfile="${arkautorestartfile:-ShooterGame/Saved/.autorestart-${1}}" arkserverdir="${arkserverdir:-ShooterGame}"
arkoldautorestartfile="ShooterGame/Saved/.autorestart" arkautorestartfile="${arkautorestartfile:-${arkserverdir}/Saved/.autorestart-${1}}"
arkserverpidfile="${arkserverpidfile:-ShooterGame/Saved/.arkserver-${1}.pid}" arkoldautorestartfile="${arkserverdir}/Saved/.autorestart"
arkserveroldpidfile="ShooterGame/Saved/.arkserver.pid" arkserverpidfile="${arkserverpidfile:-${arkserverdir}/Saved/.arkserver-${1}.pid}"
arkmanagerpidfile="${arkmanagerpidfile:-ShooterGame/Saved/.arkmanager-${1}.pid}" arkserveroldpidfile="${arkserverdir}/Saved/.arkserver.pid"
arkwarnlockfile="${arkwarnlockfile:-ShooterGame/Saved/.ark-warn-${1}.lock}" arkmanagerpidfile="${arkmanagerpidfile:-${arkserverdir}/Saved/.arkmanager-${1}.pid}"
arkwarnlockfile="${arkwarnlockfile:-${arkserverdir}/Saved/.ark-warn-${1}.lock}"
# This is linked to the directory, not to the instance # This is linked to the directory, not to the instance
arkupdatelockfile="${arkupdatelockfile:-ShooterGame/Saved/.ark-update.lock}" arkupdatelockfile="${arkupdatelockfile:-${arkserverdir}/Saved/.ark-update.lock}"
arkupdatetimefile="${arkupdatetimefile:-ShooterGame/Saved/.ark-update.time}" arkupdatetimefile="${arkupdatetimefile:-${arkserverdir}/Saved/.ark-update.time}"
} }
addArkOpt() { addArkOpt() {