1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2024-12-29 13:52:03 +01:00

Merge pull request 'fix: Set up alternate host' (#2) from release/triage into testing

Reviewed-on: https://codeberg.org/aclist/dztui/pulls/2
This commit is contained in:
aclist 2024-12-12 02:33:22 +00:00
commit 33b2aa85df
4 changed files with 61 additions and 22 deletions

View file

@ -1,8 +1,4 @@
## What this is ## 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) 1. Search for and display server metadata in a table (server name, player count, ping, current gametime, distance, IP)

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail set -o pipefail
version=5.6.0-beta.11 version=5.6.0-beta.12
#CONSTANTS #CONSTANTS
aid=221100 aid=221100
@ -54,7 +54,8 @@ km_helper="$helpers_path/latlon"
sums_path="$helpers_path/sums.md5" sums_path="$helpers_path/sums.md5"
func_helper="$helpers_path/funcs" func_helper="$helpers_path/funcs"
#URLS #REMOTE
remote_host=gh
author="aclist" author="aclist"
repo="dztui" repo="dztui"
url_prefix="https://raw.githubusercontent.com/$author/$repo" url_prefix="https://raw.githubusercontent.com/$author/$repo"
@ -64,6 +65,7 @@ releases_url="https://github.com/$author/$repo/releases/download/browser"
km_helper_url="$releases_url/latlon" km_helper_url="$releases_url/latlon"
geo_file_url="$releases_url/ips.csv.gz" geo_file_url="$releases_url/ips.csv.gz"
set_im_module(){ set_im_module(){
#TODO: drop pending SteamOS changes #TODO: drop pending SteamOS changes
pgrep -a gamescope | grep -q "generate-drm-mode" pgrep -a gamescope | grep -q "generate-drm-mode"
@ -312,13 +314,14 @@ check_unmerged(){
check_version(){ check_version(){
local version_url=$(format_version_url) local version_url=$(format_version_url)
local upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}') 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" logger INFO "Local branch: '$branch', local version: $version"
if [[ $branch == "stable" ]]; then if [[ $branch == "stable" ]]; then
version_url="$stable_url/dzgui.sh" version_url="$stable_url/dzgui.sh"
elif [[ $branch == "testing" ]]; then elif [[ $branch == "testing" ]]; then
version_url="$testing_url/dzgui.sh" version_url="$testing_url/dzgui.sh"
fi fi
local upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}')
[[ ! -f "$freedesktop_path/$app_name.desktop" ]] && freedesktop_dirs [[ ! -f "$freedesktop_path/$app_name.desktop" ]] && freedesktop_dirs
if [[ $version == $upstream ]]; then if [[ $version == $upstream ]]; then
logger INFO "Local version is same as upstream" logger INFO "Local version is same as upstream"
@ -371,9 +374,14 @@ prompt_dl(){
} }
dl_changelog(){ dl_changelog(){
local mdbranch local mdbranch
local md
[[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "stable" ]] && mdbranch="dzgui"
[[ $branch == "testing" ]] && mdbranch="testing" [[ $branch == "testing" ]] && mdbranch="testing"
local md="https://raw.githubusercontent.com/$author/dztui/${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" curl -Ls "$md" > "$state_path/CHANGELOG.md"
} }
test_display_mode(){ test_display_mode(){
@ -535,7 +543,7 @@ fetch_dzq(){
return 0 return 0
fi fi
local sha=3088bbfb147b77bc7b6a9425581b439889ff3f7f local sha=3088bbfb147b77bc7b6a9425581b439889ff3f7f
local author="aclist" local author="yepoleb"
local repo="dayzquery" local repo="dayzquery"
local url="https://raw.githubusercontent.com/$author/$repo/$sha/dayzquery.py" local url="https://raw.githubusercontent.com/$author/$repo/$sha/dayzquery.py"
curl -Ls "$url" > "$file" curl -Ls "$url" > "$file"
@ -572,11 +580,11 @@ fetch_helpers_by_sum(){
["ui.py"]="be3da1e542d14105f4358dd38901e25a" ["ui.py"]="be3da1e542d14105f4358dd38901e25a"
["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067"
["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397"
["funcs"]="62f6b3fb2dcb56a78b7642c0f0aa7abe" ["funcs"]="bdf2b0d71622de2a5762005290879b3d"
["lan"]="c62e84ddd1457b71a85ad21da662b9af" ["lan"]="c62e84ddd1457b71a85ad21da662b9af"
) )
local author="aclist" local author="aclist"
local repo="dztui" local repo="dzgui"
local realbranch local realbranch
local file local file
local sum local sum
@ -596,7 +604,13 @@ fetch_helpers_by_sum(){
file="$i" file="$i"
sum="${sums[$i]}" sum="${sums[$i]}"
full_path="$helpers_path/$file" full_path="$helpers_path/$file"
if [[ $remote_host == "gh" ]]; then
url="https://raw.githubusercontent.com/$author/$repo/$realbranch/helpers/$file" 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 if [[ -f "$full_path" ]] && [[ $(get_hash "$full_path") == $sum ]]; then
logger INFO "$file is current" logger INFO "$file is current"
else else
@ -845,14 +859,41 @@ is_steam_running(){
return 0 return 0
fi fi
} }
get_response_code(){
local url="$1"
curl -Ls -I -o /dev/null -w "%{http_code}" "$url"
}
test_connection(){ test_connection(){
ping -c1 -4 github.com 1>/dev/null 2>&1 source "$config_file"
if [[ ! $? -eq 0 ]]; then declare -A hr
raise_error_and_quit "No connection could be established to the remote server (github.com)." 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"
)
# 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 fi
ping -c1 -4 api.steampowered.com 1>/dev/null 2>&1
if [[ ! $? -eq 0 ]]; then if [[ $remote_host == "cb" ]]; then
raise_error_and_quit "No connection could be established to the remote server (steampowered.com)." 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 fi
} }
legacy_cols(){ legacy_cols(){

View file

@ -70,12 +70,14 @@ game_dir="$steam_path/steamapps/common/DayZ"
#URLS #URLS
author="aclist" author="aclist"
repo="dztui" repo="dztui"
#TODO: this is hardcoded
#2024-12-12
gh_prefix="https://github.com" gh_prefix="https://github.com"
issues_url="$gh_prefix/$author/$repo/issues" 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" stable_url="$url_prefix/dzgui"
testing_url="$url_prefix/testing" 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" km_helper_url="$releases_url/latlon"
db_file="$releases_url/ips.csv.gz" db_file="$releases_url/ips.csv.gz"
sums_url="$stable_url/helpers/sums.md5" sums_url="$stable_url/helpers/sums.md5"
@ -852,7 +854,7 @@ dl_changelog(){
local file="CHANGELOG.md" local file="CHANGELOG.md"
[[ $branch == "stable" ]] && mdbranch="dzgui" [[ $branch == "stable" ]] && mdbranch="dzgui"
[[ $branch == "testing" ]] && mdbranch="testing" [[ $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" curl -Ls "$md" > "$state_path/$file"
} }
toggle(){ toggle(){

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/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 chmod +x dzgui.sh
xdg_file="$HOME/.local/share/applications/dzgui.desktop" xdg_file="$HOME/.local/share/applications/dzgui.desktop"
share="$HOME/.local/share/dzgui" share="$HOME/.local/share/dzgui"