Improve steamcmd directory autodetection

This commit is contained in:
Ben Peddell 2021-08-06 21:50:10 +10:00
parent a5fb3dcb53
commit 804c37b304

View File

@ -474,65 +474,95 @@ getQueryPort(){
# Determine SteamCMD data directory # Determine SteamCMD data directory
# #
getSteamWorkshopDir(){ getSteamWorkshopDir(){
if [[ -d "${steamworkshopdir}" && -f "${steamworkshopdir}/appworkshop_${mod_appid}.acf" ]]; then
echo "${steamworkshopdir}"
return
fi
if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then
steamcmdhome="${HOME}" steamcmdhome="${HOME}"
fi fi
for d in "$steamworkshopdir" \ local wsfile="$(
"$steamcmdhome/.steam/SteamApps/workshop" \ for d in "$steamcmdhome/.steam/steam" "$steamcmdhome/.steam" "$steamcmdhome/Steam"; do
"$steamcmdhome/.steam/steamapps/workshop" \ for d2 in "${d}/steamapps/workshop" "${d}/SteamApps/workshop"; do
"$steamcmdhome/Steam/SteamApps/workshop" \ if [[ -d "${d2}" && -f "${d2}/appworkshop_${mod_appid}.acf" ]]; then
"$steamcmdhome/Steam/steamapps/workshop" \ stat -c "%Y %n" "${d2}/appworkshop_${mod_appid}.acf"
"${steamdataroot:-$steamcmdroot}/steamapps/workshop"; do fi
if [[ -d "${d}" && -f "${d}/appworkshop_${mod_appid}.acf" ]]; then done
echo "$d" done |
return sort -n |
fi tail -n1 |
done cut -d' ' -f2-
# default )"
echo "$steamcmdhome/Steam/steamapps/workshop"
if [[ -n "$wsfile" && -f "$wsfile" ]]; then
echo "${wsfile%/*}"
else
echo "$steamcmdhome/Steam/steamapps/workshop"
fi
} }
# #
# Determine SteamCMD data directory # Determine SteamCMD data directory
# #
getSteamAppInfoCache(){ getSteamAppInfoCache(){
if [[ -n "${steamcmd_appinfocache}" && -f "${steamcmd_appinfocache}" ]]; then
echo "${steamcmd_appinfocache}"
return
fi
if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then
steamcmdhome="${HOME}" steamcmdhome="${HOME}"
fi fi
for d in "${steamcmd_appinfocache}" \ local appcachefile="$(
"$steamcmdhome/.steam/appcache/appinfo.vdf" \ for d in "$steamcmdhome/.steam/steam" "$steamcmdhome/.steam" "$steamcmdhome/Steam"; do
"$steamcmdhome/Steam/appcache/appinfo.vdf" \ if [[ -d "${d}" && -f "${d}/appcache/appinfo.vdf" ]]; then
"${steamdataroot:-$steamcmdroot}/appcache/appinfo.vdf"; do stat -c "%Y %n" "${d}/appcache/appinfo.vdf"
if [[ -f "${d}" ]]; then fi
echo "$d" done |
return sort -n
fi tail -n1 |
done cut -d' ' -f2-
# default )"
echo "${steamcmd_appinfocache:-$steamcmdhome/Steam/appcache/appinfo.vdf}"
if [[ -n "$appcachefile" && -f "$appcachefile" ]]; then
echo "${appcachefile}"
else
echo "${steamcmd_appinfocache:-$steamcmdhome/Steam/appcache/appinfo.vdf}"
fi
} }
# #
# Determine SteamCMD data directory # Determine SteamCMD data directory
# #
getSteamWorkshopLog(){ getSteamWorkshopLog(){
if [[ -n "${steamcmd_workshoplog}" && -f "${steamcmd_workshoplog}" ]]; then
echo "${steamcmd_workshoplog}"
fi
if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then
steamcmdhome="${HOME}" steamcmdhome="${HOME}"
fi fi
for d in "${steamcmd_workshoplog}" \
"$steamcmdhome/.steam/logs/workshop_log.txt" \ local wslogfile="$(
"$steamcmdhome/Steam/logs/workshop_log.txt" \ for d in "$steamcmdhome/.steam/steam" "$steamcmdhome/.steam" "$steamcmdhome/Steam"; do
"${steamdataroot:-$steamcmdroot}/logs/workshop_log.txt"; do if [[ -d "${d}" && -f "${d}/logs/workshop_log.txt" ]]; then
if [[ -f "${d}" ]]; then stat -c "%Y %n" "${d}/logs/workshop_log.txt"
echo "$d" fi
return done |
fi sort -n |
done tail -n1 |
# default cut -d' ' -f2-
echo "${steamcmd_workshoplog:-$steamcmdhome/logs/workshop_log.txt}" )"
if [[ -n "$wslogfile" && -f "$wslogfile" ]]; then
echo "${wslogfile}"
else
echo "${steamcmd_workshoplog:-$steamcmdhome/Steam/logs/workshop_log.txt}"
fi
} }
# #