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 1/8] 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 2/8] 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 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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"