mirror of
https://github.com/aclist/dztui.git
synced 2024-12-30 14:12:04 +01:00
Bump version
This commit is contained in:
parent
993c6c780f
commit
bbc2b5bb2a
1 changed files with 76 additions and 18 deletions
92
dzgui.sh
92
dzgui.sh
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
version=2.2.1-rc.1
|
version=2.3.0
|
||||||
aid=221100
|
aid=221100
|
||||||
game="dayz"
|
game="dayz"
|
||||||
workshop="steam://url/CommunityFilePage/"
|
workshop="steam://url/CommunityFilePage/"
|
||||||
|
@ -11,10 +11,10 @@ config_path="$HOME/.config/dztui/"
|
||||||
config_file="${config_path}dztuirc"
|
config_file="${config_path}dztuirc"
|
||||||
tmp=/tmp/dztui.tmp
|
tmp=/tmp/dztui.tmp
|
||||||
separator="%%"
|
separator="%%"
|
||||||
git_url="https://github.com/aclist/dztui/issues"
|
git_url="https://github.com/aclist/dztui/issues/new/choose"
|
||||||
version_url="https://raw.githubusercontent.com/aclist/dztui/dzgui/dzgui.sh"
|
stable_url="https://raw.githubusercontent.com/aclist/dztui/dzgui/dzgui.sh"
|
||||||
|
testing_url="https://raw.githubusercontent.com/aclist/dztui/testing/dzgui.sh"
|
||||||
help_url="https://aclist.github.io/dzgui/dzgui"
|
help_url="https://aclist.github.io/dzgui/dzgui"
|
||||||
upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}')
|
|
||||||
check_config_msg="Check config values and restart."
|
check_config_msg="Check config values and restart."
|
||||||
|
|
||||||
#TODO: prevent connecting to offline servers
|
#TODO: prevent connecting to offline servers
|
||||||
|
@ -116,6 +116,9 @@ name="$name"
|
||||||
|
|
||||||
#Set to 1 to perform dry-run and print launch options
|
#Set to 1 to perform dry-run and print launch options
|
||||||
debug="0"
|
debug="0"
|
||||||
|
|
||||||
|
#Toggle stable/testing branch
|
||||||
|
branch="stable"
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
guess_path(){
|
guess_path(){
|
||||||
|
@ -202,8 +205,10 @@ open_mod_links(){
|
||||||
echo "<title>DZGUI</title>" >> $link_file
|
echo "<title>DZGUI</title>" >> $link_file
|
||||||
echo "<h1>DZGUI</h1>" >> $link_file
|
echo "<h1>DZGUI</h1>" >> $link_file
|
||||||
echo "<p>Open these links and subscribe to them on the Steam Workshop, then continue with the application prompts.<br><b>Note:</b> it may take some time for mods to synchronize before DZGUI can see them.<br>It can help to have Steam in an adjacent window so that you can see the downloads completing.</p>" >> $link_file
|
echo "<p>Open these links and subscribe to them on the Steam Workshop, then continue with the application prompts.<br><b>Note:</b> it may take some time for mods to synchronize before DZGUI can see them.<br>It can help to have Steam in an adjacent window so that you can see the downloads completing.</p>" >> $link_file
|
||||||
|
n=1
|
||||||
for i in $diff; do
|
for i in $diff; do
|
||||||
echo "<a href=\"${workshop}$i\">${workshop}$i</a><br>"
|
echo "$n. <a href=\"${workshop}$i\">${workshop}$i</a><br>"
|
||||||
|
let n++
|
||||||
done >> $link_file
|
done >> $link_file
|
||||||
echo "</html>" >> $link_file
|
echo "</html>" >> $link_file
|
||||||
browser "$link_file" &
|
browser "$link_file" &
|
||||||
|
@ -262,7 +267,13 @@ passed_mod_check(){
|
||||||
}
|
}
|
||||||
connect(){
|
connect(){
|
||||||
#TODO: sanitize/validate input
|
#TODO: sanitize/validate input
|
||||||
|
readarray -t qport_arr <<< "$qport_list"
|
||||||
|
if [[ -z ${qport_arr[@]} ]]; then
|
||||||
|
err "Failed to process favorite server"
|
||||||
|
return
|
||||||
|
fi
|
||||||
ip=$(echo "$1" | awk -F"$separator" '{print $1}')
|
ip=$(echo "$1" | awk -F"$separator" '{print $1}')
|
||||||
|
#TODO: deprecated (for now)
|
||||||
bid=$(echo "$1" | awk -F"$separator" '{print $2}')
|
bid=$(echo "$1" | awk -F"$separator" '{print $2}')
|
||||||
fetch_mods_sa "$ip"
|
fetch_mods_sa "$ip"
|
||||||
validate_mods
|
validate_mods
|
||||||
|
@ -279,12 +290,17 @@ connect(){
|
||||||
fetch_mods_sa(){
|
fetch_mods_sa(){
|
||||||
sa_ip=$(echo $ip | awk -F: '{print $1}')
|
sa_ip=$(echo $ip | awk -F: '{print $1}')
|
||||||
for i in ${qport_arr[@]}; do
|
for i in ${qport_arr[@]}; do
|
||||||
if [[ -n $(echo "$i" | awk -v ip=$ip -F: '$0 ~ ip') ]]; then
|
if [[ -n $(echo "$i" | awk -v ip=$ip '$0 ~ ip') ]]; then
|
||||||
sa_port=$(echo $i | awk -v ip=$ip -F: '$0 ~ ip {print $3}')
|
sa_port=$(echo $i | awk -v ip=$ip -F$separator '$0 ~ ip {print $2}')
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "[DZGUI] Querying modlist on ${sa_ip}:${sa_port}"
|
echo "[DZGUI] Querying modlist on ${sa_ip}:${sa_port}"
|
||||||
remote_mods=$(curl -Ls "https://dayzsalauncher.com/api/v1/query/$sa_ip/$sa_port" | jq -r '.result.mods[].steamWorkshopId')
|
remote_mods=$(curl -Ls "https://dayzsalauncher.com/api/v1/query/$sa_ip/$sa_port" | jq -r '.result.mods[].steamWorkshopId')
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc -eq 1 ]]; then
|
||||||
|
err "Failed to fetch modlist"
|
||||||
|
return
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
fetch_mods(){
|
fetch_mods(){
|
||||||
#TODO: broken upstream
|
#TODO: broken upstream
|
||||||
|
@ -388,10 +404,10 @@ populate(){
|
||||||
while true; do
|
while true; do
|
||||||
#TODO: add boolean statement for ping flag; affects all column ordinal output
|
#TODO: add boolean statement for ping flag; affects all column ordinal output
|
||||||
cols="--column="Server" --column="IP" --column="Players" --column="Gametime" --column="Status" --column="ID" --column="Ping""
|
cols="--column="Server" --column="IP" --column="Players" --column="Gametime" --column="Status" --column="ID" --column="Ping""
|
||||||
sel=$(cat $tmp | zenity $sd_res --list $cols --title="DZGUI" --text="DZGUI $version | Mode: $mode | Fav: $fav_label" \
|
set_header ${FUNCNAME[0]}
|
||||||
--separator="$separator" --print-column=2,6 2>/dev/null)
|
|
||||||
rc=$?
|
rc=$?
|
||||||
if [[ $rc -eq 0 ]]; then if [[ -z $sel ]]; then
|
if [[ $rc -eq 0 ]]; then
|
||||||
|
if [[ -z $sel ]]; then
|
||||||
warn "No item was selected."
|
warn "No item was selected."
|
||||||
else
|
else
|
||||||
connect $sel
|
connect $sel
|
||||||
|
@ -414,15 +430,47 @@ connect_to_fav(){
|
||||||
if [[ -n $fav ]]; then
|
if [[ -n $fav ]]; then
|
||||||
one_shot_launch=1
|
one_shot_launch=1
|
||||||
query_api
|
query_api
|
||||||
sel=$(jq -r '.data[] .attributes | "\(.ip):\(.port)%%\(.id)"' <<< $response)
|
qport_list=$(echo "$response" | jq -r '.data[] .attributes | "\(.ip):\(.port)%%\(.portQuery)"')
|
||||||
echo "[DZGUI] Attempting connection to $fav_label"
|
echo "[DZGUI] Attempting connection to $fav_label"
|
||||||
connect "$sel"
|
connect "$qport_list"
|
||||||
one_shot_launch=0
|
one_shot_launch=0
|
||||||
else
|
else
|
||||||
warn "No fav server configured"
|
warn "No fav server configured"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
set_header(){
|
||||||
|
if [[ $1 == "populate" ]]; then
|
||||||
|
sel=$(cat $tmp | zenity $sd_res --list $cols --title="DZGUI" --text="DZGUI $version | Mode: $mode | Branch: $branch | Fav: $fav_label" \
|
||||||
|
--separator="$separator" --print-column=2,6 2>/dev/null)
|
||||||
|
elif [[ $1 == "main_menu" ]]; then
|
||||||
|
sel=$(zenity --width=1280 --height=800 --list --title="DZGUI" --text="DZGUI $version | Mode: $mode | Branch: $branch | Fav: $fav_label" \
|
||||||
|
--cancel-label="Exit" --ok-label="Select" --column="Select launch option" "${items[@]}" 2>/dev/null)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
toggle_branch(){
|
||||||
|
mv $config_file ${config_path}dztuirc.old
|
||||||
|
nr=$(awk '/branch=/ {print NR}' ${config_path}dztuirc.old)
|
||||||
|
if [[ $branch == "stable" ]]; then
|
||||||
|
branch="testing"
|
||||||
|
else
|
||||||
|
branch="stable"
|
||||||
|
fi
|
||||||
|
flip_branch="branch=\"$branch\""
|
||||||
|
awk -v "var=$flip_branch" -v "nr=$nr" 'NR==nr {$0=var}{print}' ${config_path}dztuirc.old > $config_file
|
||||||
|
printf "[DZGUI] Toggled branch to '$branch'\n"
|
||||||
|
source $config_file
|
||||||
|
}
|
||||||
|
debug_menu(){
|
||||||
|
debug_list=(
|
||||||
|
"Toggle branch"
|
||||||
|
)
|
||||||
|
debug_sel=$(zenity --list --width=1280 --height=800 --column="Options" --title="DZGUI" "${debug_list[@]}" 2>/dev/null)
|
||||||
|
if [[ $debug_sel == "${debug_list[0]}" ]]; then
|
||||||
|
toggle_branch
|
||||||
|
check_version
|
||||||
|
fi
|
||||||
|
}
|
||||||
main_menu(){
|
main_menu(){
|
||||||
if [[ $debug -eq 1 ]]; then
|
if [[ $debug -eq 1 ]]; then
|
||||||
items+=("Debug options")
|
items+=("Debug options")
|
||||||
|
@ -432,8 +480,7 @@ main_menu(){
|
||||||
items[3]="Change favorite server"
|
items[3]="Change favorite server"
|
||||||
fi
|
fi
|
||||||
while true; do
|
while true; do
|
||||||
sel=$(zenity --width=1280 --height=800 --list --title="DZGUI" --text="DZGUI $version | Mode: $mode | Fav: $fav_label" \
|
set_header ${FUNCNAME[0]}
|
||||||
--cancel-label="Exit" --ok-label="Select" --column="Select launch option" "${items[@]}" 2>/dev/null)
|
|
||||||
rc=$?
|
rc=$?
|
||||||
if [[ $rc -eq 0 ]]; then
|
if [[ $rc -eq 0 ]]; then
|
||||||
if [[ -z $sel ]]; then
|
if [[ -z $sel ]]; then
|
||||||
|
@ -468,6 +515,8 @@ main_menu(){
|
||||||
help_file
|
help_file
|
||||||
elif [[ $sel == "${items[8]}" ]]; then
|
elif [[ $sel == "${items[8]}" ]]; then
|
||||||
changelog | zenity --text-info $sd_res --title="DZGUI" 2>/dev/null
|
changelog | zenity --text-info $sd_res --title="DZGUI" 2>/dev/null
|
||||||
|
elif [[ $sel == "${items[9]}" ]]; then
|
||||||
|
debug_menu
|
||||||
else
|
else
|
||||||
warn "This feature is not yet implemented."
|
warn "This feature is not yet implemented."
|
||||||
fi
|
fi
|
||||||
|
@ -478,9 +527,8 @@ main_menu(){
|
||||||
}
|
}
|
||||||
parse_json(){
|
parse_json(){
|
||||||
list=$(jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
|
list=$(jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
|
||||||
qport_list=$(echo "$response" | jq -r '.data[] .attributes | "\(.ip):\(.port):\(.portQuery)"')
|
qport_list=$(echo "$response" | jq -r '.data[] .attributes | "\(.ip):\(.port)%%\(.portQuery)"')
|
||||||
echo -e "$list" > $tmp
|
echo -e "$list" > $tmp
|
||||||
readarray -t qport_arr <<< "$qport_list"
|
|
||||||
}
|
}
|
||||||
check_ping(){
|
check_ping(){
|
||||||
ping_ip=$(echo "$1" | awk -F'\t' '{print $2}' | awk -F: '{print $1}')
|
ping_ip=$(echo "$1" | awk -F'\t' '{print $2}' | awk -F: '{print $1}')
|
||||||
|
@ -573,12 +621,22 @@ download_new_version(){
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
check_branch(){
|
||||||
|
if [[ $branch == "stable" ]]; then
|
||||||
|
version_url="$stable_url"
|
||||||
|
elif [[ $branch == "testing" ]]; then
|
||||||
|
version_url="$testing_url"
|
||||||
|
fi
|
||||||
|
upstream=$(curl -Ls "$version_url" | awk -F= '/^version=/ {print $2}')
|
||||||
|
}
|
||||||
check_version(){
|
check_version(){
|
||||||
|
source $config_file
|
||||||
|
check_branch
|
||||||
if [[ $version == $upstream ]]; then
|
if [[ $version == $upstream ]]; then
|
||||||
check_unmerged
|
check_unmerged
|
||||||
else
|
else
|
||||||
echo "[DZGUI] Upstream ($upstream) is > local ($version)"
|
echo "[DZGUI] Upstream ($upstream) is > local ($version)"
|
||||||
zenity --question --title="DZGUI" --text "Newer version available.\n\nYour version:\t\t\t$version\nUpstream version:\t\t$upstream\n\nAttempt to download latest version?" --width=500 --ok-label="Yes" --cancel-label="No" 2>/dev/null
|
zenity --question --title="DZGUI" --text "Newer version available.\n\nYour branch:\t\t\t$branch\nYour version:\t\t\t$version\nUpstream version:\t\t$upstream\n\nVersion updates introduce important bug fixes and are encouraged.\n\nAttempt to download latest version?" --width=500 --ok-label="Yes" --cancel-label="No" 2>/dev/null
|
||||||
rc=$?
|
rc=$?
|
||||||
if [[ $rc -eq 1 ]]; then
|
if [[ $rc -eq 1 ]]; then
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue