From eaf9d5ad3ee7b7a418fb5d6228a85ce35bcb9508 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:54:44 +0900 Subject: [PATCH 01/17] fix: change remote URLs --- README.md | 7 ++----- dzgui.sh | 16 ++++++++-------- helpers/funcs | 6 +++--- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 5732eb9..dae89ad 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ ## What this is -DZGUI is a GUI version of [DZTUI](https://github.com/aclist/dztui/tree/dztui) for Linux. - -Note: development of DZTUI has stopped and has been replaced with DZGUI. - -DZGUI allows you to connect to both official and modded/community DayZ servers on Linux and provides a graphical interface for doing so. This overcomes certain limitations in the Linux client and helps prepare the game to launch by doing the following: +DZGUI allows you to connect to both official and modded/community DayZ servers on Linux and provides a graphical interface for doing so. This overcomes certain limitations in the Linux client and +helps prepare the game to launch by doing the following: 1. Search for and display server metadata in a table (server name, player count, ping, current gametime, distance, IP) 2. Add/delete/manage favorite servers by IP or ID diff --git a/dzgui.sh b/dzgui.sh index 2a8d4e2..8885bc9 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -56,11 +56,11 @@ func_helper="$helpers_path/funcs" #URLS author="aclist" -repo="dztui" -url_prefix="https://raw.githubusercontent.com/$author/$repo" +repo="dzgui" +url_prefix="https://codeberg.org/$author/$repo/raw/branch" stable_url="$url_prefix/dzgui" testing_url="$url_prefix/testing" -releases_url="https://github.com/$author/$repo/releases/download/browser" +releases_url="https://codeberg.org/$author/$repo/releases/download/browser" km_helper_url="$releases_url/latlon" geo_file_url="$releases_url/ips.csv.gz" @@ -373,7 +373,7 @@ dl_changelog(){ local mdbranch [[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "testing" ]] && mdbranch="testing" - local md="https://raw.githubusercontent.com/$author/dztui/${mdbranch}/CHANGELOG.md" + local md="https://codeberg.org/$author/dzgui/raw/branch/${mdbranch}/CHANGELOG.md" curl -Ls "$md" > "$state_path/CHANGELOG.md" } test_display_mode(){ @@ -535,7 +535,7 @@ fetch_dzq(){ return 0 fi local sha=3088bbfb147b77bc7b6a9425581b439889ff3f7f - local author="aclist" + local author="yepoleb" local repo="dayzquery" local url="https://raw.githubusercontent.com/$author/$repo/$sha/dayzquery.py" curl -Ls "$url" > "$file" @@ -572,11 +572,11 @@ fetch_helpers_by_sum(){ ["ui.py"]="be3da1e542d14105f4358dd38901e25a" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="62f6b3fb2dcb56a78b7642c0f0aa7abe" + ["funcs"]="0cbec29142f4fcb03b2bd8367fe365e4" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" - local repo="dztui" + local repo="dzgui" local realbranch local file local sum @@ -596,7 +596,7 @@ fetch_helpers_by_sum(){ file="$i" sum="${sums[$i]}" full_path="$helpers_path/$file" - url="https://raw.githubusercontent.com/$author/$repo/$realbranch/helpers/$file" + url="https://codeberg.org/$author/$repo/raw/branch/$realbranch/helpers/$file" if [[ -f "$full_path" ]] && [[ $(get_hash "$full_path") == $sum ]]; then logger INFO "$file is current" else diff --git a/helpers/funcs b/helpers/funcs index 5df388a..e8745f6 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -72,10 +72,10 @@ author="aclist" repo="dztui" gh_prefix="https://github.com" issues_url="$gh_prefix/$author/$repo/issues" -url_prefix="https://raw.githubusercontent.com/$author/$repo" +url_prefix="https://codeberg.org/$author/$repo/branch" stable_url="$url_prefix/dzgui" testing_url="$url_prefix/testing" -releases_url="$gh_prefix/$author/$repo/releases/download/browser" +releases_url="https://codeberg.org/$author/$repo/releases/download/browser" km_helper_url="$releases_url/latlon" db_file="$releases_url/ips.csv.gz" sums_url="$stable_url/helpers/sums.md5" @@ -852,7 +852,7 @@ dl_changelog(){ local file="CHANGELOG.md" [[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "testing" ]] && mdbranch="testing" - local md="https://raw.githubusercontent.com/$author/$repo/${mdbranch}/$file" + local md="https://codeberg.org/$author/$repo/raw/branch/${mdbranch}/$file" curl -Ls "$md" > "$state_path/$file" } toggle(){ From f503c89c2b2fac160dd37cf23615b65d7d7f3a69 Mon Sep 17 00:00:00 2001 From: aclist Date: Thu, 12 Dec 2024 00:58:56 +0000 Subject: [PATCH 02/17] fix: line wrapping --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index dae89ad..8290e55 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ ## What this is -DZGUI allows you to connect to both official and modded/community DayZ servers on Linux and provides a graphical interface for doing so. This overcomes certain limitations in the Linux client and -helps prepare the game to launch by doing the following: +DZGUI allows you to connect to both official and modded/community DayZ servers on Linux and provides a graphical interface for doing so. This overcomes certain limitations in the Linux client and helps prepare the game to launch by doing the following: 1. Search for and display server metadata in a table (server name, player count, ping, current gametime, distance, IP) 2. Add/delete/manage favorite servers by IP or ID From 1da2e7292820ffb28ad900c0d9212b75ec0f206d Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:27:38 +0900 Subject: [PATCH 03/17] fix: update installscript --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a56422e..1e07a07 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -curl "https://raw.githubusercontent.com/aclist/dztui/dzgui/dzgui.sh" > dzgui.sh +curl "https://codeberg.org/aclist/dzgui/raw/branch/dzgui/dzgui.sh" > dzgui.sh chmod +x dzgui.sh xdg_file="$HOME/.local/share/applications/dzgui.desktop" share="$HOME/.local/share/dzgui" From 0197e0f92103f70a2855dc8aa2f6f7a31f7d19f6 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:08:07 +0900 Subject: [PATCH 04/17] fix: conditional remote url logic --- dzgui.sh | 60 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 8885bc9..45f5663 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -54,16 +54,18 @@ km_helper="$helpers_path/latlon" sums_path="$helpers_path/sums.md5" func_helper="$helpers_path/funcs" -#URLS +#REMOTE +remote_host=gh author="aclist" -repo="dzgui" -url_prefix="https://codeberg.org/$author/$repo/raw/branch" +repo="dztui" +url_prefix="https://raw.githubusercontent.com/$author/$repo" stable_url="$url_prefix/dzgui" testing_url="$url_prefix/testing" -releases_url="https://codeberg.org/$author/$repo/releases/download/browser" +releases_url="https://github.com/$author/$repo/releases/download/browser" km_helper_url="$releases_url/latlon" geo_file_url="$releases_url/ips.csv.gz" + set_im_module(){ #TODO: drop pending SteamOS changes pgrep -a gamescope | grep -q "generate-drm-mode" @@ -312,13 +314,14 @@ check_unmerged(){ check_version(){ local version_url=$(format_version_url) local upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}') + #2024-12-12: do not clobber local version if unreachable + [[ -z $upstream ]] && return logger INFO "Local branch: '$branch', local version: $version" if [[ $branch == "stable" ]]; then version_url="$stable_url/dzgui.sh" elif [[ $branch == "testing" ]]; then version_url="$testing_url/dzgui.sh" fi - local upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}') [[ ! -f "$freedesktop_path/$app_name.desktop" ]] && freedesktop_dirs if [[ $version == $upstream ]]; then logger INFO "Local version is same as upstream" @@ -371,9 +374,14 @@ prompt_dl(){ } dl_changelog(){ local mdbranch + local md [[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "testing" ]] && mdbranch="testing" - local md="https://codeberg.org/$author/dzgui/raw/branch/${mdbranch}/CHANGELOG.md" + if [[ $remote_host == "gh" ]]; then + md="https://raw.githubusercontent.com/$author/$repo/${mdbranch}/CHANGELOG.md" + else + md="https://codeberg.org/$author/$repo/raw/branch/${mdbranch}/CHANGELOG.md" + fi curl -Ls "$md" > "$state_path/CHANGELOG.md" } test_display_mode(){ @@ -596,7 +604,13 @@ fetch_helpers_by_sum(){ file="$i" sum="${sums[$i]}" full_path="$helpers_path/$file" - url="https://codeberg.org/$author/$repo/raw/branch/$realbranch/helpers/$file" + + if [[ $remote_host == "gh" ]]; then + url="https://raw.githubusercontent.com/$author/$repo/$realbranch/helpers/$file" + else + url="https://codeberg.org/$author/$repo/raw/branch/$realbranch/helpers/$file" + fi + if [[ -f "$full_path" ]] && [[ $(get_hash "$full_path") == $sum ]]; then logger INFO "$file is current" else @@ -845,14 +859,32 @@ is_steam_running(){ return 0 fi } +get_response_code(){ + local url="$1" + curl -Ls -I -o /dev/null -w "%{http_code}" "$url" +} test_connection(){ - ping -c1 -4 github.com 1>/dev/null 2>&1 - if [[ ! $? -eq 0 ]]; then - raise_error_and_quit "No connection could be established to the remote server (github.com)." - fi - ping -c1 -4 api.steampowered.com 1>/dev/null 2>&1 - if [[ ! $? -eq 0 ]]; then - raise_error_and_quit "No connection could be established to the remote server (steampowered.com)." + source "$config_file" + declare -A hr + local res1 + local res2 + local str="No connection could be established to the remote server" + hr=( + ["steampowered.com"]="https://api.steampowered.com/IGameServersService/GetServerList/v1/?key=$steam_api" + ["github.com"]="https://github.com/$author" + ["codeberg.org"]="https://codeberg.org/$author" + ) + res=$(get_response_code "${hr["github.com"]}") + [[ $res -ne 200 ]] && remote_host=cb + res=$(get_response_code "${hr["codeberg.org"]}") + [[ $res -ne 200 ]] && raise_error_and_quit "$str (${hr["codeberg.org"]})" + # steam API is mandatory + res=$(get_response_code "${hr["steampowered.com"]}") + [[ $res -ne 200 ]] && raise_error_and_quit "$str ${hr["steampowered.com"]}" + + if [[ $remote_host == "cb" ]]; then + url_prefix="https://codeberg.org/$author/$repo/raw/branch" + releases_url="https://codeberg.org/$author/$repo/releases/download/browser" fi } legacy_cols(){ From a079d554bcdb5a44d9a6aa6c7a333a7fcac173fa Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:13:48 +0900 Subject: [PATCH 05/17] chore: bump version --- dzgui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index 45f5663..1cbd63e 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.6.0-beta.11 +version=5.6.0-beta.12 #CONSTANTS aid=221100 From 7c5bd76e8f73831500056634dc34d8fcc08561ec Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:16:46 +0900 Subject: [PATCH 06/17] fix: test connection control flow --- dzgui.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 1cbd63e..3067c93 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -874,14 +874,18 @@ test_connection(){ ["github.com"]="https://github.com/$author" ["codeberg.org"]="https://codeberg.org/$author" ) - res=$(get_response_code "${hr["github.com"]}") - [[ $res -ne 200 ]] && remote_host=cb - res=$(get_response_code "${hr["codeberg.org"]}") - [[ $res -ne 200 ]] && raise_error_and_quit "$str (${hr["codeberg.org"]})" # steam API is mandatory res=$(get_response_code "${hr["steampowered.com"]}") [[ $res -ne 200 ]] && raise_error_and_quit "$str ${hr["steampowered.com"]}" + res=$(get_response_code "${hr["github.com"]}") + if [[ $res -ne 200 ]]; then + logger WARN "Remote host '${hr["github.com"]}' unreachable', trying fallback" + remote_host=cb + res=$(get_response_code "${hr["codeberg.org"]}") + [[ $res -ne 200 ]] && raise_error_and_quit "$str (${hr["codeberg.org"]})" + fi + if [[ $remote_host == "cb" ]]; then url_prefix="https://codeberg.org/$author/$repo/raw/branch" releases_url="https://codeberg.org/$author/$repo/releases/download/browser" From ea0d94a2fcf24bf5f35febeeb7853f301b67c395 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:25:39 +0900 Subject: [PATCH 07/17] fix: interpolate old vars --- dzgui.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dzgui.sh b/dzgui.sh index 3067c93..fca682b 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -889,6 +889,11 @@ test_connection(){ if [[ $remote_host == "cb" ]]; then url_prefix="https://codeberg.org/$author/$repo/raw/branch" releases_url="https://codeberg.org/$author/$repo/releases/download/browser" + # 2024-12-12: interpolate variables again + stable_url="$url_prefix/dzgui" + testing_url="$url_prefix/testing" + km_helper_url="$releases_url/latlon" + geo_file_url="$releases_url/ips.csv.gz" fi } legacy_cols(){ From 4b95033c1978398cd565c152a64717138cb8dc92 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:31:32 +0900 Subject: [PATCH 08/17] chore: add comments --- dzgui.sh | 2 +- helpers/funcs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index fca682b..13bb058 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -580,7 +580,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="be3da1e542d14105f4358dd38901e25a" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="0cbec29142f4fcb03b2bd8367fe365e4" + ["funcs"]="bdf2b0d71622de2a5762005290879b3d" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" diff --git a/helpers/funcs b/helpers/funcs index e8745f6..42cdd49 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -70,6 +70,8 @@ game_dir="$steam_path/steamapps/common/DayZ" #URLS author="aclist" repo="dztui" +#TODO: this is hardcoded +#2024-12-12 gh_prefix="https://github.com" issues_url="$gh_prefix/$author/$repo/issues" url_prefix="https://codeberg.org/$author/$repo/branch" From 1be68e7be3cf2835db15bfbfce8efc145b5d23a6 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:38:16 +0900 Subject: [PATCH 09/17] fix: enable redirects --- dzgui.sh | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 13bb058..855aaf9 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.6.0-beta.12 +version=5.6.0-beta.13 #CONSTANTS aid=221100 diff --git a/install.sh b/install.sh index 1e07a07..22ec6ab 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -curl "https://codeberg.org/aclist/dzgui/raw/branch/dzgui/dzgui.sh" > dzgui.sh +curl -L "https://codeberg.org/aclist/dzgui/raw/branch/dzgui/dzgui.sh" > dzgui.sh chmod +x dzgui.sh xdg_file="$HOME/.local/share/applications/dzgui.desktop" share="$HOME/.local/share/dzgui" From 12b1c392dfc912779847e64a9dd032db3a2558ed Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:50:18 +0900 Subject: [PATCH 10/17] fix: initial setup --- dzgui.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 855aaf9..aa02198 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.6.0-beta.13 +version=5.6.0-beta.14 #CONSTANTS aid=221100 @@ -874,9 +874,11 @@ test_connection(){ ["github.com"]="https://github.com/$author" ["codeberg.org"]="https://codeberg.org/$author" ) - # steam API is mandatory - res=$(get_response_code "${hr["steampowered.com"]}") - [[ $res -ne 200 ]] && raise_error_and_quit "$str ${hr["steampowered.com"]}" + # steam API is mandatory, except on initial setup + if [[ -n $steam_api ]]; then + res=$(get_response_code "${hr["steampowered.com"]}") + [[ $res -ne 200 ]] && raise_error_and_quit "$str ("steampowered.com")" + fi res=$(get_response_code "${hr["github.com"]}") if [[ $res -ne 200 ]]; then @@ -885,7 +887,6 @@ test_connection(){ res=$(get_response_code "${hr["codeberg.org"]}") [[ $res -ne 200 ]] && raise_error_and_quit "$str (${hr["codeberg.org"]})" fi - if [[ $remote_host == "cb" ]]; then url_prefix="https://codeberg.org/$author/$repo/raw/branch" releases_url="https://codeberg.org/$author/$repo/releases/download/browser" From 62e6da2abb9c3edb8479e5ab6d803a3662c45116 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:08:57 +0900 Subject: [PATCH 11/17] fix: url syntax --- dzgui.sh | 4 ++-- helpers/funcs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) mode change 100755 => 100644 dzgui.sh diff --git a/dzgui.sh b/dzgui.sh old mode 100755 new mode 100644 index aa02198..82a97d2 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.6.0-beta.14 +version=5.6.0-beta.15 #CONSTANTS aid=221100 @@ -580,7 +580,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="be3da1e542d14105f4358dd38901e25a" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="bdf2b0d71622de2a5762005290879b3d" + ["funcs"]="bfe629ed9481627317b49a8f9c6fad24" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" diff --git a/helpers/funcs b/helpers/funcs index 42cdd49..8e06c1a 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -74,7 +74,7 @@ repo="dztui" #2024-12-12 gh_prefix="https://github.com" issues_url="$gh_prefix/$author/$repo/issues" -url_prefix="https://codeberg.org/$author/$repo/branch" +url_prefix="https://codeberg.org/$author/$repo/raw/branch" stable_url="$url_prefix/dzgui" testing_url="$url_prefix/testing" releases_url="https://codeberg.org/$author/$repo/releases/download/browser" @@ -854,6 +854,8 @@ dl_changelog(){ local file="CHANGELOG.md" [[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "testing" ]] && mdbranch="testing" + #TODO: this is hardcoded + #2024-12-12 local md="https://codeberg.org/$author/$repo/raw/branch/${mdbranch}/$file" curl -Ls "$md" > "$state_path/$file" } From c5785d185796b8b066d28d3fe9af2420484abed7 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:31:58 +0900 Subject: [PATCH 12/17] docs: update docs link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8290e55..d6cf770 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Other options include the ability to connect by IP or ID or set a favorite serv ## Setup and usage -Refer to the [manual](https://aclist.github.io/dzgui/dzgui.html) for installation and setup instructions, a feature-by-feature breakdown, and Steam integration tutorials. +Refer to the [manual](https://aclist.codeberg.page) for installation and setup instructions, a feature-by-feature breakdown, and Steam integration tutorials. ![Alt text](/images/example.png) From cbecf569ad217a26de24e3c8272947ad484b399e Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:40:46 +0900 Subject: [PATCH 13/17] fix: add fallbacks and remote resource checks --- CHANGELOG.md | 6 ++++++ dzgui.sh | 28 ++++++++++++++++++---------- helpers/funcs | 47 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 60 insertions(+), 21 deletions(-) mode change 100644 => 100755 dzgui.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 3288630..6d02bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [5.6.0-beta.16] 2024-12-13 +### Fixed +- Add remote resource health checks before downloading updates +### Added +- Add fallback repository + ## [5.6.0-beta.11] 2024-12-07 ### Fixed - Add missing function definition diff --git a/dzgui.sh b/dzgui.sh old mode 100644 new mode 100755 index 82a97d2..6f5f8d1 --- a/dzgui.sh +++ b/dzgui.sh @@ -314,8 +314,8 @@ check_unmerged(){ check_version(){ local version_url=$(format_version_url) local upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}') - #2024-12-12: do not clobber local version if unreachable - [[ -z $upstream ]] && return + local res=$(get_response_code "$version_url") + [[ $res -ne 200 ]] && raise_error_and_quit "Remote resource unavailable: '$version_url'" logger INFO "Local branch: '$branch', local version: $version" if [[ $branch == "stable" ]]; then version_url="$stable_url/dzgui.sh" @@ -377,11 +377,7 @@ dl_changelog(){ local md [[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "testing" ]] && mdbranch="testing" - if [[ $remote_host == "gh" ]]; then - md="https://raw.githubusercontent.com/$author/$repo/${mdbranch}/CHANGELOG.md" - else - md="https://codeberg.org/$author/$repo/raw/branch/${mdbranch}/CHANGELOG.md" - fi + local md="$url_prefix/${mdbranch}/$file" curl -Ls "$md" > "$state_path/CHANGELOG.md" } test_display_mode(){ @@ -523,6 +519,7 @@ get_hash(){ md5sum "$1" | awk '{print $1}' } fetch_a2s(){ + # this file is currently monolithic [[ -d $helpers_path/a2s ]] && { logger INFO "A2S helper is current"; return 0; } local sha=c7590ffa9a6d0c6912e17ceeab15b832a1090640 local author="yepoleb" @@ -530,6 +527,8 @@ fetch_a2s(){ local url="https://github.com/$author/$repo/tarball/$sha" local prefix="${author^}-$repo-${sha:0:7}" local file="$prefix.tar.gz" + local res=$(get_response_code "$url") + [[ $res -ne 200 ]] && raise_error_and_quit "Remote resource unavailable: '$file'" curl -Ls "$url" > "$helpers_path/$file" tar xf "$helpers_path/$file" -C "$helpers_path" "$prefix/a2s" --strip=1 rm "$helpers_path/$file" @@ -546,6 +545,8 @@ fetch_dzq(){ local author="yepoleb" local repo="dayzquery" local url="https://raw.githubusercontent.com/$author/$repo/$sha/dayzquery.py" + local res=$(get_response_code "$url") + [[ $res -ne 200 ]] && raise_error_and_quit "Remote resource unavailable: 'dayzquery.py'" curl -Ls "$url" > "$file" logger INFO "Updated DZQ to sha '$sha'" } @@ -580,11 +581,11 @@ fetch_helpers_by_sum(){ ["ui.py"]="be3da1e542d14105f4358dd38901e25a" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="bfe629ed9481627317b49a8f9c6fad24" + ["funcs"]="2a27ab36d5f8071fe53bf8dfd3b8d88d" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" - local repo="dzgui" + local repo="dztui" local realbranch local file local sum @@ -615,6 +616,8 @@ fetch_helpers_by_sum(){ logger INFO "$file is current" else logger WARN "File '$full_path' checksum != '$sum'" + local res=$(get_response_code "$url") + [[ $res -ne 200 ]] && raise_error_and_quit "Remote resource unavailable: '$url'" curl -Ls "$url" > "$full_path" if [[ ! $? -eq 0 ]]; then raise_error_and_quit "Failed to fetch the file '$file'. Possible timeout?" @@ -635,11 +638,15 @@ fetch_geo_file(){ local km_sum="b038fdb8f655798207bd28de3a004706" local gzip="$helpers_path/ips.csv.gz" if [[ ! -f $geo_file ]] || [[ $(get_hash $geo_file) != $geo_sum ]]; then + local res=$(get_response_code "$geo_file_url") + [[ $res -ne 200 ]] && raise_error_and_quit "Remote resource unavailable: '$geo_file_url'" curl -Ls "$geo_file_url" > "$gzip" #force overwrite gunzip -f "$gzip" fi if [[ ! -f $km_helper ]] || [[ $(get_hash $km_helper) != $km_sum ]]; then + local res=$(get_response_code "$km_helper_url") + [[ $res -ne 200 ]] && raise_error_and_quit "Remote resource unavailable: '$km_helper_url'" curl -Ls "$km_helper_url" > "$km_helper" chmod +x "$km_helper" fi @@ -887,10 +894,11 @@ test_connection(){ res=$(get_response_code "${hr["codeberg.org"]}") [[ $res -ne 200 ]] && raise_error_and_quit "$str (${hr["codeberg.org"]})" fi + logger INFO "Set remote host to '${hr["codeberg.org"]}'" + remote_host=cb if [[ $remote_host == "cb" ]]; then url_prefix="https://codeberg.org/$author/$repo/raw/branch" releases_url="https://codeberg.org/$author/$repo/releases/download/browser" - # 2024-12-12: interpolate variables again stable_url="$url_prefix/dzgui" testing_url="$url_prefix/testing" km_helper_url="$releases_url/latlon" diff --git a/helpers/funcs b/helpers/funcs index 8e06c1a..3681c01 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -70,18 +70,12 @@ game_dir="$steam_path/steamapps/common/DayZ" #URLS author="aclist" repo="dztui" -#TODO: this is hardcoded -#2024-12-12 gh_prefix="https://github.com" issues_url="$gh_prefix/$author/$repo/issues" -url_prefix="https://codeberg.org/$author/$repo/raw/branch" +url_prefix="https://raw.githubusercontent.com/$author/$repo" stable_url="$url_prefix/dzgui" testing_url="$url_prefix/testing" -releases_url="https://codeberg.org/$author/$repo/releases/download/browser" -km_helper_url="$releases_url/latlon" -db_file="$releases_url/ips.csv.gz" -sums_url="$stable_url/helpers/sums.md5" -#TODO: move adoc to index +releases_url="$gh_prefix/$author/$repo/releases/download/browser" help_url="https://$author.github.io/dzgui/dzgui" forum_url="$gh_prefix/$author/$repo/discussions" sponsor_url="$gh_prefix/sponsors/$author" @@ -829,7 +823,40 @@ format_version_url(){ esac echo "$version_url" } +get_response_code(){ + local url="$1" + curl -Ls -I -o /dev/null -w "%{http_code}" "$url" +} +test_connection(){ + source "$config_file" + declare -A hr + local res1 + local res2 + local str="No connection could be established to the remote server" + hr=( + ["github.com"]="https://github.com/$author" + ["codeberg.org"]="https://codeberg.org/$author" + ) + res=$(get_response_code "${hr["github.com"]}") + if [[ $res -ne 200 ]]; then + logger WARN "Remote host '${hr["github.com"]}' unreachable', trying fallback" + remote_host=cb + res=$(get_response_code "${hr["codeberg.org"]}") + if [[ $res -ne 200 ]]; then + printf "Failed to fetch new version. Rolling back" + return 1 + fi + fi + logger INFO "Set remote host to '${hr["codeberg.org"]}'" + if [[ $remote_host == "cb" ]]; then + url_prefix="https://codeberg.org/$author/$repo/raw/branch" + releases_url="https://codeberg.org/$author/$repo/releases/download/browser" + stable_url="$url_prefix/dzgui" + testing_url="$url_prefix/testing" + fi +} download_new_version(){ + test_connection local version_url="$(format_version_url)" mv "$src_path" "$src_path.old" curl -Ls "$version_url" > "$src_path" @@ -854,9 +881,7 @@ dl_changelog(){ local file="CHANGELOG.md" [[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "testing" ]] && mdbranch="testing" - #TODO: this is hardcoded - #2024-12-12 - local md="https://codeberg.org/$author/$repo/raw/branch/${mdbranch}/$file" + local md="$url_prefix/${mdbranch}/$file" curl -Ls "$md" > "$state_path/$file" } toggle(){ From d4d0593927678da56e797191af2e4f23618e45a1 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:49:39 +0900 Subject: [PATCH 14/17] fix: add fallback logic to installscript --- install.sh | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 22ec6ab..13f96cc --- a/install.sh +++ b/install.sh @@ -1,8 +1,41 @@ #!/usr/bin/env bash -curl -L "https://codeberg.org/aclist/dzgui/raw/branch/dzgui/dzgui.sh" > dzgui.sh -chmod +x dzgui.sh -xdg_file="$HOME/.local/share/applications/dzgui.desktop" -share="$HOME/.local/share/dzgui" -[[ -f $xdg_file ]] && rm $xdg_file -[[ -d $share ]] && rm -rf "$share" -./dzgui.sh +get_response_code(){ + local url="$1" + curl -Ls -I -o /dev/null -w "%{http_code}" "$url" +} +abort(){ + printf "Remote resource not available. Try again later.\n" + exit 1 +} +fetch(){ + local file="dzgui.sh" + local author="aclist" + local repo="dztui" + local branch="dzgui" + local url + local res + gh_url="https://raw.githubusercontent.com/$author/$repo/$branch/$file" + cb_url="https://codeberg.org/$author/$repo/raw/branch/$branch/$file" + + url="$gh_url" + printf "Checking the remote resource at '%s'\n" "$url" + res=$(get_response_code "$url") + if [[ $res -ne 200 ]]; then + url="$cb_url" + printf "Checking the remote resource at '%s'\n" "$url" + res=$(get_response_code "$url") + if [[ $res -ne 200 ]]; then + abort + fi + fi + + curl -L "$url" > dzgui.sh + chmod +x dzgui.sh + xdg_file="$HOME/.local/share/applications/dzgui.desktop" + share="$HOME/.local/share/dzgui" + [[ -f $xdg_file ]] && rm $xdg_file + [[ -d $share ]] && rm -rf "$share" + ./dzgui.sh +} + +fetch From 5d6cbaa1a5c8b7e79de64d9ad6fb720c97df89e4 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:51:31 +0900 Subject: [PATCH 15/17] chore: bump version --- dzgui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index 6f5f8d1..b5af209 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.6.0-beta.15 +version=5.6.0-beta.16 #CONSTANTS aid=221100 From 4da78d33f350dc8fd364c0c285d7fd4acd2f2616 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:58:44 +0900 Subject: [PATCH 16/17] fix: clean up URLs --- dzgui.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index b5af209..a92e175 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -606,11 +606,7 @@ fetch_helpers_by_sum(){ sum="${sums[$i]}" full_path="$helpers_path/$file" - if [[ $remote_host == "gh" ]]; then - url="https://raw.githubusercontent.com/$author/$repo/$realbranch/helpers/$file" - else - url="https://codeberg.org/$author/$repo/raw/branch/$realbranch/helpers/$file" - fi + url="${url_prefix}/$realbranch/helpers/$file" if [[ -f "$full_path" ]] && [[ $(get_hash "$full_path") == $sum ]]; then logger INFO "$file is current" @@ -895,7 +891,6 @@ test_connection(){ [[ $res -ne 200 ]] && raise_error_and_quit "$str (${hr["codeberg.org"]})" fi logger INFO "Set remote host to '${hr["codeberg.org"]}'" - remote_host=cb if [[ $remote_host == "cb" ]]; then url_prefix="https://codeberg.org/$author/$repo/raw/branch" releases_url="https://codeberg.org/$author/$repo/releases/download/browser" From 3fce2cc3ad710781029453da458d60ae6d45b9fe Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:18:56 +0900 Subject: [PATCH 17/17] fix: return codes --- dzgui.sh | 2 +- helpers/funcs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index a92e175..07c06f8 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -581,7 +581,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="be3da1e542d14105f4358dd38901e25a" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="2a27ab36d5f8071fe53bf8dfd3b8d88d" + ["funcs"]="10c7d9cb9fbb792626ec9e7a4a788ba5" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" diff --git a/helpers/funcs b/helpers/funcs index 3681c01..82ab6ce 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -843,7 +843,6 @@ test_connection(){ remote_host=cb res=$(get_response_code "${hr["codeberg.org"]}") if [[ $res -ne 200 ]]; then - printf "Failed to fetch new version. Rolling back" return 1 fi fi @@ -857,6 +856,12 @@ test_connection(){ } download_new_version(){ test_connection + rc=$? + if [[ $rc -eq 1 ]]; then + printf "Remote resource unavailable. Aborting" + logger WARN "Remote resource unavailable" + return 1 + fi local version_url="$(format_version_url)" mv "$src_path" "$src_path.old" curl -Ls "$version_url" > "$src_path" @@ -896,6 +901,7 @@ toggle(){ fi update_config download_new_version + [[ $? -eq 1 ]] && return 1 return 255 ;; Toggle[[:space:]]mod[[:space:]]install[[:space:]]mode)