1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2025-04-05 12:03:00 +02:00

Automod versioning

This commit is contained in:
aclist 2022-10-26 09:22:19 +09:00
parent 76c7ab16d8
commit 6c3542c93b
2 changed files with 84 additions and 8 deletions

View file

@ -5,6 +5,10 @@
- Custom query API - Custom query API
- Standardize dialogs - Standardize dialogs
## [3.1.0-rc.5] 2022-10-25
### Added
- Versioning for automods
## [3.1.0-rc.4] 2022-10-23 ## [3.1.0-rc.4] 2022-10-23
### Added ### Added
- Automod v.2 method - Automod v.2 method

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -o pipefail set -o pipefail
version=3.1.0-rc.4 version=3.1.0-rc.5
aid=221100 aid=221100
game="dayz" game="dayz"
@ -34,6 +34,7 @@ scmd_url="$testing_url/helpers/scmd.sh"
notify_url="$testing_url/helpers/d.html" notify_url="$testing_url/helpers/d.html"
notify_img_url="$testing_url/helpers/d.webp" notify_img_url="$testing_url/helpers/d.webp"
forum_url="https://github.com/aclist/dztui/discussions" forum_url="https://github.com/aclist/dztui/discussions"
version_file="$config_path/versions"
update_last_seen(){ update_last_seen(){
mv $config_file ${config_path}dztuirc.old mv $config_file ${config_path}dztuirc.old
@ -448,6 +449,7 @@ manual_mod_install(){
steam_deck_mods steam_deck_mods
else else
local ex="/tmp/dzc.tmp" local ex="/tmp/dzc.tmp"
[[ -f $ex ]] && rm $ex
watcher(){ watcher(){
readarray -t stage_mods <<< "$diff" readarray -t stage_mods <<< "$diff"
for((i=0;i<${#stage_mods[@]};i++)); do for((i=0;i<${#stage_mods[@]};i++)); do
@ -459,6 +461,7 @@ manual_mod_install(){
sleep 1s sleep 1s
foreground foreground
until [[ -d $downloads_dir/${stage_mods[$i]} ]]; do until [[ -d $downloads_dir/${stage_mods[$i]} ]]; do
[[ -f $ex ]] && return 1
sleep 0.1s sleep 0.1s
if [[ -d $workshop_dir/${stage_mods[$i]} ]]; then if [[ -d $workshop_dir/${stage_mods[$i]} ]]; then
break break
@ -467,6 +470,7 @@ manual_mod_install(){
foreground foreground
echo "# Steam is downloading ${stage_mods[$i]} (mod $((i+1)) of ${#stage_mods[@]})" echo "# Steam is downloading ${stage_mods[$i]} (mod $((i+1)) of ${#stage_mods[@]})"
until [[ -d $workshop_dir/${stage_mods[$i]} ]]; do until [[ -d $workshop_dir/${stage_mods[$i]} ]]; do
[[ -f $ex ]] && return 1
sleep 0.1s sleep 0.1s
done done
foreground foreground
@ -543,7 +547,7 @@ auto_mod_install(){
done done
until [[ ! -d $staging_dir/app_$aid ]]; do until [[ ! -d $staging_dir/app_$aid ]]; do
until [[ "$fmt_size" == "$total_size" ]]; do until [[ "$fmt_size" == "$total_size" ]]; do
local cur_size=$(du -sb "$staging_dir/app_$aid" | awk '{print $1}') local cur_size=$(du -s -B1 "$staging_dir/app_$aid" | awk '{print $1}')
local fmt_size=$(numfmt --to=iec $cur_size) local fmt_size=$(numfmt --to=iec $cur_size)
sleep 0.1s sleep 0.1s
[[ ${#modids[@]} -gt 1 ]] && s=s [[ ${#modids[@]} -gt 1 ]] && s=s
@ -553,6 +557,7 @@ auto_mod_install(){
done | zenity --progress --pulsate --text="Downloading mods" --auto-close --no-cancel --width=500 --title=DZGUI 2>/dev/null done | zenity --progress --pulsate --text="Downloading mods" --auto-close --no-cancel --width=500 --title=DZGUI 2>/dev/null
compare compare
if [[ -z $diff ]]; then if [[ -z $diff ]]; then
check_timestamps
passed_mod_check > >(zenity --pulsate --progress --title=DZGUI --auto-close --width=500 2>/dev/null) passed_mod_check > >(zenity --pulsate --progress --title=DZGUI --auto-close --width=500 2>/dev/null)
launch launch
else else
@ -562,6 +567,64 @@ auto_mod_install(){
manual_mod_install manual_mod_install
fi fi
} }
get_local_stamps(){
concat(){
for ((i=0;i<$max;i++)); do
echo "publishedfileids[$i]=${local_modlist[$i]}&"
done | awk '{print}' ORS=''
}
payload(){
echo -e "itemcount=${max}&$(concat)"
}
post(){
curl -s -X POST -H "Content-Type:application/x-www-form-urlencoded" \
-d "$(payload)" 'https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?format=json'
}
post
}
update_stamps(){
for((i=0;i<${#local_modlist[@]};i++)); do
mod=${local_modlist[$i]}
stamp=${stamps[$i]}
printf "%s\t%s\n" "$mod" "$stamp" >> $version_file
done
}
check_timestamps(){
readarray -t local_modlist < <(ls -1 $workshop_dir)
max=${#local_modlist[@]}
readarray -t stamps < <(get_local_stamps | jq -r '.response.publishedfiledetails[].time_updated')
if [[ ! -f $version_file ]]; then
update_stamps
return
else
needs_update=()
for((i=0;i<${#local_modlist[@]};i++)); do
mod=${local_modlist[$i]}
stamp=${stamps[$i]}
if [[ ! $(awk -v var=$mod '$1 == var' $version_file) ]]; then
echo -e "$mod\t$stamp" >> $version_file
elif [[ $(awk -v var=$mod -v var2=$stamp '$1 == var && $2 == var2' $version_file) ]]; then
:
else
awk -v var=$mod -v var2=$stamp '$1 == var {$2=var2;print $1"\t"$2; next;};{print}' $version_file > $version_file.new
mv $version_file.new $version_file
needs_update+=($mod)
fi
done
fi
}
merge_modlists(){
check_timestamps
if [[ -z "$diff" ]] && [[ ${#needs_update[@]} -gt 0 ]]; then
diff=$(printf "%s\n" "${needs_update[@]}")
elif [[ -z "$diff" ]] && [[ ${#needs_update[@]} -eq 0 ]]; then
diff=
elif [[ -n "$diff" ]] && [[ ${#needs_update[@]} -eq 0 ]]; then
:
else
diff="$(echo -e "$diff\n${needs_update[@]}")"
fi
}
connect(){ connect(){
#TODO: sanitize/validate input #TODO: sanitize/validate input
readarray -t qport_arr <<< "$qport_list" readarray -t qport_arr <<< "$qport_list"
@ -584,6 +647,7 @@ connect(){
rc=$? rc=$?
[[ $rc -eq 1 ]] && return [[ $rc -eq 1 ]] && return
compare compare
merge_modlists
if [[ -n $diff ]]; then if [[ -n $diff ]]; then
if [[ $auto_install -eq 1 ]]; then if [[ $auto_install -eq 1 ]]; then
headless_mod_install "$diff" headless_mod_install "$diff"
@ -1030,7 +1094,8 @@ depot_watcher(){
readarray -t modids <<< "$@" readarray -t modids <<< "$@"
echo "[DZGUI] Moving mods" echo "[DZGUI] Moving mods"
for i in "${modids[@]}"; do for i in "${modids[@]}"; do
mv $staging_dir/app_$aid/item_$i "$workshop_dir/$i" rsync -a --delete "$staging_dir/app_$aid/item_$i/" "$workshop_dir/$i/" &&
rm -rf "$staging_dir/app_$aid/item_$i"
done done
echo "[DZGUI] Cleanup" echo "[DZGUI] Cleanup"
rmdir $staging_dir/app_$aid rmdir $staging_dir/app_$aid
@ -1050,11 +1115,18 @@ console_dl(){
} }
find_default_path(){ find_default_path(){
[[ -n $default_steam_path ]] && return [[ -n $default_steam_path ]] && return
if [[ $is_steam_deck -eq 1 ]]; then
default_steam_path="$HOME/.local/share/Steam"
else
if [[ -d "$HOME/.local/share/Steam" ]]; then
default_steam_path="$HOME/.local/share/Steam"
else
default_steam_path=$(find / -type d \( -path "/proc" -o -path "*/timeshift" -o -path \ default_steam_path=$(find / -type d \( -path "/proc" -o -path "*/timeshift" -o -path \
"/tmp" -o -path "/usr" -o -path "/boot" -o -path "/proc" -o -path "/root" \ "/tmp" -o -path "/usr" -o -path "/boot" -o -path "/run" -o -path "/proc" -o -path "/root" \
-o -path "/sys" -o -path "/etc" -o -path "/var" -o -path "/lost+found" \) -prune \ -o -path "/sys" -o -path "/etc" -o -path "/var" -o -path "/lost+found" \) -prune \
-o -regex ".*/Steam/ubuntu12_32$" -print -quit 2>/dev/null | sed 's@/ubuntu12_32@@') -o -regex ".*/Steam/ubuntu12_32$" -print -quit 2>/dev/null | sed 's@/ubuntu12_32@@')
echo "$default_steam_path" >> logs fi
fi
default_steam_path="default_steam_path=\"$default_steam_path\"" default_steam_path="default_steam_path=\"$default_steam_path\""
mv $config_file ${config_path}dztuirc.old mv $config_file ${config_path}dztuirc.old
local nr=$(awk '/default_steam_path=/ {print NR}' ${config_path}dztuirc.old) local nr=$(awk '/default_steam_path=/ {print NR}' ${config_path}dztuirc.old)