1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2025-04-08 13:33:00 +02:00

Force steamcmd keepalive

This commit is contained in:
aclist 2022-06-17 16:12:30 +09:00 committed by GitHub
parent 788ee990a2
commit 6a9e4f547d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eo pipefail
version=0.3.4 version=0.4.0
release_url="https://raw.githubusercontent.com/aclist/dztui/main/dztui.sh" release_url="https://raw.githubusercontent.com/aclist/dztui/main/dztui.sh"
aid=221100 aid=221100
game="dayz" game="dayz"
@ -171,13 +171,13 @@ launch_fav(){
} }
manual_mod_install(){ manual_mod_install(){
printf "[ERROR] Missing mods. Open these links and subscribe to each one, then reconnect\n" printf "[ERROR] Missing mods. Open these links and subscribe to each one, then reconnect\n"
for i in $diff; do for i in $(diff); do
printf "%s%s\n" "$workshop" $i printf "%s%s\n" "$workshop" $i
done done
} }
steamcmd_modlist(){ steamcmd_modlist(){
for i in $diff; do for i in $(diff); do
printf "+workshop_download_item %s %s " $aid $i printf "+workshop_download_item %s %s validate " $aid $i
done done
} }
move_files(){ move_files(){
@ -186,8 +186,14 @@ move_files(){
rm -r "$staging_dir"/steamapps rm -r "$staging_dir"/steamapps
} }
auto_mod_download(){ auto_mod_download(){
sudo chown -R $USER:$gid "$staging_dir"/steamapps
rm -r "$staging_dir"/steamapps
until [[ -z $(diff) ]]; do
printf "[INFO] Downloading missing mods\n"
sudo -iu steam bash -c "$steamcmd_path +force_install_dir $staging_dir +login $steam_username $(steamcmd_modlist) +quit" $steamcmd_user sudo -iu steam bash -c "$steamcmd_path +force_install_dir $staging_dir +login $steam_username $(steamcmd_modlist) +quit" $steamcmd_user
printf "\n"
[[ "$(ls -A $staging_dir/steamapps)" ]] && move_files || return 1 [[ "$(ls -A $staging_dir/steamapps)" ]] && move_files || return 1
done
} }
find_steam_cmd(){ find_steam_cmd(){
for i in "/home/steam" "/usr/share" "/usr/bin" "/"; do for i in "/home/steam" "/usr/share" "/usr/bin" "/"; do
@ -215,12 +221,11 @@ auto_mod_install(){
if [[ $? -eq 1 ]]; then if [[ $? -eq 1 ]]; then
err "steamcmd not found. See: https://developer.valvesoftware.com/wiki/SteamCMD" err "steamcmd not found. See: https://developer.valvesoftware.com/wiki/SteamCMD"
else else
printf "[INFO] Downloading mods\n"
revert_msg="Something went wrong. Reverting to manual mode" revert_msg="Something went wrong. Reverting to manual mode"
auto_mod_download auto_mod_download
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
printf "\n" printf "\n"
init_table passed_mod_check
else else
err "$revert_msg" err "$revert_msg"
fi fi
@ -228,6 +233,13 @@ auto_mod_install(){
} }
failed_mod_check(){ failed_mod_check(){
disksize=$(df $staging_dir --output=avail | tail -n1)
bytewise=$((disksize * 1024))
hr=$(echo $(numfmt --to=iec --format "%8.1f" $bytewise $totalmodsize) | sed 's/ /\//')
if [[ $totalmodsize -gt $bytewise ]]; then
printf "[ERROR] Not enough space to install mods: %s\n" $hr
return
fi
[[ $auto_install_mods -eq 1 ]] && auto_mod_install || manual_mod_install [[ $auto_install_mods -eq 1 ]] && auto_mod_install || manual_mod_install
} }
passed_mod_check(){ passed_mod_check(){
@ -253,7 +265,9 @@ query_defunct(){
post(){ post(){
curl -s -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "$(payload)" 'https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?format=json' curl -s -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "$(payload)" 'https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?format=json'
} }
readarray -t newlist <<< $(post | jq -r '.[].publishedfiledetails[] | select(.result==1) .publishedfileid') result=$(post | jq -r '.[].publishedfiledetails[] | select(.result==1) | "\(.file_size) \(.publishedfileid)"')
readarray -t newlist <<< $(echo -e "$result" | awk '{print $2}')
totalmodsize=$(echo -e "$result" | awk '{s+=$1}END{print s}')
} }
validate_mods(){ validate_mods(){
url="https://steamcommunity.com/sharedfiles/filedetails/?id=" url="https://steamcommunity.com/sharedfiles/filedetails/?id="
@ -268,14 +282,16 @@ server_modlist(){
printf "$i\n" printf "$i\n"
done done
} }
diff(){
comm -23 <(server_modlist | sort) <(installed_mods | sort)
}
compare(){ compare(){
fetch_mods fetch_mods
validate_mods validate_mods
diff=$(comm -23 <(server_modlist | sort) <(installed_mods | sort))
} }
connect(){ connect(){
compare compare
if [[ -n $diff ]]; then if [[ -n $(diff) ]]; then
failed_mod_check failed_mod_check
else else
passed_mod_check passed_mod_check