Parse output of download_workshop_item command

This commit is contained in:
Ben Peddell 2016-05-16 17:38:08 +10:00
parent 103c3abcf9
commit e9b2c9b21f

View File

@ -158,6 +158,7 @@ else
install_datadir="${install_datadir:-${install_bindir%/*}/share/arkmanager}"
fi
declare -A modsrcdirs
#---------------------
# functions
@ -366,8 +367,11 @@ function runSteamCMD(){
function runSteamCMDspinner(){
if [ -n "$verbose" ]; then
echo
runSteamCMD "$@"
if command >&3; then
runSteamCMD "$@" | tee /dev/fd/3
else
runSteamCMD "$@"
fi
return $?
else
if [ -z "$progressDisplayType" ]; then
@ -377,7 +381,11 @@ function runSteamCMDspinner(){
progressDisplayType=dots
fi
fi
runSteamCMD "$@" >/dev/null 2>&1 &
if command >&3; then
runSteamCMD "$@" >&3 &
else
runSteamCMD "$@" >/dev/null &
fi
local scpid=$!
local pos=0
local spinner=( '\b-' '\b/' '\b|' '\b\\' )
@ -396,6 +404,12 @@ function runSteamCMDspinner(){
fi
}
function runSteamCMDspinnerSubst(){
local fd="$1"
shift
runSteamCMDspinner "$@" 3>&1 >/dev/fd/${fd}
}
#
# Check if a new version is available but not apply it
#
@ -1223,9 +1237,10 @@ doDownloadMod(){
while true; do
echo -n "Downloading mod $modid"
runSteamCMDspinner +workshop_download_item $mod_appid $modid
local output=$(runSteamCMDspinnerSubst 5 +workshop_download_item $mod_appid $modid) 5>&1
result=$?
if [ $result -eq 0 ]; then
modsrcdir="$(echo "$output" | sed -n 's@^Success. Downloaded item [0-9][0-9]* to "\([^"]*\)" .*@\1@p')"
break
else
echo
@ -1243,6 +1258,7 @@ doDownloadMod(){
if [ -f "$modsrcdir/mod.info" ]; then
echo "Mod $modid downloaded"
modsrcdirs[$modid]="$modsrcdir"
return 0
else
echo "Mod $modid was not successfully downloaded"
@ -1268,6 +1284,10 @@ isModUpdateNeeded(){
local moddestdir="$arkserverroot/ShooterGame/Content/Mods/$modid"
local modbranch="${mod_branch:-Windows}"
if [ -n "${modsrcdirs[$modid]}" ]; then
modsrcdir="${modsrcdirs[$modid]}"
fi
for varname in "${!mod_branch_@}"; do
if [ "mod_branch_$modid" == "$varname" ]; then
modbranch="${!varname}"
@ -1315,6 +1335,10 @@ doExtractMod(){
local moddestdir="$arkserverroot/ShooterGame/Content/Mods/$modid"
local modbranch="${mod_branch:-Windows}"
if [ -n "${modsrcdirs[$modid]}" ]; then
modsrcdir="${modsrcdirs[$modid]}"
fi
for varname in "${!mod_branch_@}"; do
if [ "mod_branch_$modid" == "$varname" ]; then
modbranch="${!varname}"