mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-26 00:08:28 +00:00
Add mod update timestamp
This commit is contained in:
parent
f9cb25e1f2
commit
41556ffe9e
@ -2155,6 +2155,7 @@ checkForModUpdate(){
|
|||||||
local cancheckmodavail=1
|
local cancheckmodavail=1
|
||||||
local modmissing=
|
local modmissing=
|
||||||
local revstatcode=
|
local revstatcode=
|
||||||
|
local alluptodate=1
|
||||||
|
|
||||||
if [[ " $* " =~ " --revstatus " ]]; then
|
if [[ " $* " =~ " --revstatus " ]]; then
|
||||||
revstatcode=1
|
revstatcode=1
|
||||||
@ -2172,35 +2173,50 @@ checkForModUpdate(){
|
|||||||
|
|
||||||
for modid in $(getModIds); do
|
for modid in $(getModIds); do
|
||||||
availupd="$(getAvailModLastUpdated "$modid")"
|
availupd="$(getAvailModLastUpdated "$modid")"
|
||||||
|
instupd="$(getInstalledModLastUpdated "$modid")"
|
||||||
modname="$(getModName $modid)"
|
modname="$(getModName $modid)"
|
||||||
if [ -z "$availupd" ]; then
|
if [ -z "$availupd" ]; then
|
||||||
printf "Mod %d doesn't exist in the steam workshop\n" "$modid"
|
printf "Mod %d doesn't exist in the steam workshop\n" "$modid"
|
||||||
modmissing=1
|
modmissing=1
|
||||||
elif [ -n "$cancheckmodavail" ]; then
|
elif [ "$instupd" != "$availupd" ]; then
|
||||||
instupd="$(getLocalModLastUpdated "$modid")"
|
alluptodate=
|
||||||
if [ -z "$instupd" ]; then
|
if [ -n "$cancheckmodavail" ]; then
|
||||||
printf "Mod %d [%s] has not been downloaded\n" "$modid" "$modname"
|
localupd="$(getLocalModLastUpdated "$modid")"
|
||||||
updateavail=1
|
if [ -z "$localupd" ]; then
|
||||||
elif [ "$availupd" != "$instupd" ]; then
|
printf "Mod %d [%s] has not been downloaded\n" "$modid" "$modname"
|
||||||
printf "Mod %d [%s] has been updated on the Steam workshop\n" "$modid" "$modname"
|
updateavail=1
|
||||||
printf "Local last updated: %s\nSteam last updated: %s\n" "$(date --date="@$instupd")" "$(date --date="@$availupd")"
|
elif [ "$availupd" != "$localupd" ]; then
|
||||||
updateavail=1
|
printf "Mod %d [%s] has been updated on the Steam workshop\n" "$modid" "$modname"
|
||||||
|
printf "Local last updated: %s\nSteam last updated: %s\n" "$(date --date="@$localupd")" "$(date --date="@$availupd")"
|
||||||
|
updateavail=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$arkserverroot/${arkserverdir}/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 [ "$instupd" != "$availupd" ]; then
|
||||||
printf "Mod %d [%s] update needs to be applied\n" "$modid" "$modname"
|
if isModUpdateNeeded $modid; then
|
||||||
updateavail=1
|
printf "Mod %d [%s] update needs to be applied\n" "$modid" "$modname"
|
||||||
|
updateavail=1
|
||||||
|
elif [ -z "$cancheckmodavail" ]; then
|
||||||
|
printf "Mod %d [%s] update needs to be downloaded and applied\n" "$modid" "$modname"
|
||||||
|
updateavail=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$updateavail" ]; then
|
if [ -n "$updateavail" ]; then
|
||||||
|
echo "One or more updates are available"
|
||||||
if [ -n "$revstatcode" ]; then return 1; else return 0; fi
|
if [ -n "$revstatcode" ]; then return 1; else return 0; fi
|
||||||
|
elif [ -n "$alluptodate" ]; then
|
||||||
|
echo "All mods are up to date"
|
||||||
|
if [ -n "$revstatcode" ]; then return 0; else return 1; fi
|
||||||
elif [ -z "$cancheckmodavail" ]; then
|
elif [ -z "$cancheckmodavail" ]; then
|
||||||
|
echo "Cannot check if mods are up to date"
|
||||||
if [ -n "$revstatcode" ]; then return 3; else return 0; fi
|
if [ -n "$revstatcode" ]; then return 3; else return 0; fi
|
||||||
elif [ -n "$modmissing" ]; then
|
elif [ -n "$modmissing" ]; then
|
||||||
|
echo "One or more mods are unavailable"
|
||||||
return 2
|
return 2
|
||||||
else
|
else
|
||||||
echo "All mods are up to date"
|
echo "All mods are up to date"
|
||||||
@ -2264,7 +2280,20 @@ listMods(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Gets local mod manifest ID
|
# Gets installed mod last update timestamp
|
||||||
|
#
|
||||||
|
getInstalledModLastUpdated(){
|
||||||
|
local modid="$1"
|
||||||
|
if [ ! -f "${arkserverroot}/${arkserverdir}/Content/Mods/${modid}.mod" ]; then return 0; fi
|
||||||
|
if [ -f "${arkserverroot}/${arkserverdir}/Content/Mods/${modid}/__modversion__.info" ]; then
|
||||||
|
cat "${arkserverroot}/${arkserverdir}/Content/Mods/${modid}/__modversion__.info"
|
||||||
|
else
|
||||||
|
stat -c "%Y" "${arkserverroot}/${arkserverdir}/Content/Mods/${modid}.mod"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Gets local mod last update timestamp
|
||||||
#
|
#
|
||||||
getLocalModLastUpdated(){
|
getLocalModLastUpdated(){
|
||||||
local modid="$1"
|
local modid="$1"
|
||||||
@ -2275,7 +2304,7 @@ getLocalModLastUpdated(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Gets available mod manifest ID
|
# Gets available mod last update timestamp
|
||||||
#
|
#
|
||||||
getAvailModLastUpdated(){
|
getAvailModLastUpdated(){
|
||||||
local modid="$1"
|
local modid="$1"
|
||||||
@ -2291,11 +2320,17 @@ getAvailModLastUpdated(){
|
|||||||
# Checks if a mod update is available before trying to download it
|
# Checks if a mod update is available before trying to download it
|
||||||
isModUpdateAvailable(){
|
isModUpdateAvailable(){
|
||||||
local modid="$1"
|
local modid="$1"
|
||||||
local instupd="$(getLocalModLastUpdated "$modid")"
|
local localupd="$(getLocalModLastUpdated "$modid")"
|
||||||
local remupd="$(getAvailModLastUpdated "$modid")"
|
local remupd="$(getAvailModLastUpdated "$modid")"
|
||||||
|
local instupd="$(getInstalledModLastUpdated "$modid")"
|
||||||
|
|
||||||
|
if [[ -n "$remupd" && "$instupd" == "$remupd" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
local steamworkshopdir="$(getSteamWorkshopDir)"
|
local steamworkshopdir="$(getSteamWorkshopDir)"
|
||||||
if [ ! -f "${steamworkshopdir}/appworkshop_${mod_appid}.acf" ]; then return 0; fi
|
if [ ! -f "${steamworkshopdir}/appworkshop_${mod_appid}.acf" ]; then return 0; fi
|
||||||
if [[ -n "${remupd}" && "${instupd}" != "${remupd}" ]]; then
|
if [[ -n "${remupd}" && "${localupd}" != "${remupd}" ]]; then
|
||||||
return 0 # true
|
return 0 # true
|
||||||
fi
|
fi
|
||||||
return 1 # false
|
return 1 # false
|
||||||
@ -2440,7 +2475,7 @@ getModName(){
|
|||||||
modsrcdir="${modsrcdirs[$modid]}"
|
modsrcdir="${modsrcdirs[$modid]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
modname="$(curl -s "http://steamcommunity.com/sharedfiles/filedetails/?id=${modid}" | sed -n 's|^.*<div class="workshopItemTitle">\([^<]*\)</div>.*|\1|p')"
|
modname="$(curl -s "https://steamcommunity.com/sharedfiles/filedetails/?id=${modid}" | sed -n 's|^.*<div class="workshopItemTitle">\([^<]*\)</div>.*|\1|p')"
|
||||||
|
|
||||||
if [ -n "$modname" ]; then
|
if [ -n "$modname" ]; then
|
||||||
echo "$modname"
|
echo "$modname"
|
||||||
@ -2513,6 +2548,8 @@ doExtractMod(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$modsrcdir/mod.info" ]; then
|
if [ -f "$modsrcdir/mod.info" ]; then
|
||||||
|
local modupdatetime="$(getLocalModLastUpdated "$modid")"
|
||||||
|
|
||||||
echo "Copying files to $modextractdir"
|
echo "Copying files to $modextractdir"
|
||||||
|
|
||||||
if [ -f "$modsrcdir/${modbranch}NoEditor/mod.info" ]; then
|
if [ -f "$modsrcdir/${modbranch}NoEditor/mod.info" ]; then
|
||||||
@ -2622,6 +2659,11 @@ doExtractMod(){
|
|||||||
echo -ne '\x01\x00\x00\x00\x08\x00\x00\x00ModType\x00\x02\x00\x00\x001\x00' >>"${modextractdir}.mod"
|
echo -ne '\x01\x00\x00\x00\x08\x00\x00\x00ModType\x00\x02\x00\x00\x001\x00' >>"${modextractdir}.mod"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${modupdatetime}" ]; then
|
||||||
|
touch -c --date="@${modupdatetime}" -- "${modextractdir}.mod"
|
||||||
|
echo "${modupdatetime}" >"${modextractdir}/__modversion__.info"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$modbranch" >"$modextractdir/__arkmanager_modbranch__.info"
|
echo "$modbranch" >"$modextractdir/__arkmanager_modbranch__.info"
|
||||||
|
|
||||||
if [[ "$modextractdir" != "$moddestdir" ]]; then
|
if [[ "$modextractdir" != "$moddestdir" ]]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user