mirror of
https://github.com/aclist/dztui.git
synced 2025-04-08 13:33:00 +02:00
Add auto-download
This commit is contained in:
parent
e289a3fc43
commit
7989ab36f8
1 changed files with 22 additions and 5 deletions
27
dztui.sh
27
dztui.sh
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
version=0.4.1
|
version=0.5.0
|
||||||
release_url="https://raw.githubusercontent.com/aclist/dztui/main/dztui.sh"
|
release_url="https://raw.githubusercontent.com/aclist/dztui/main/dztui.sh"
|
||||||
aid=221100
|
aid=221100
|
||||||
game="dayz"
|
game="dayz"
|
||||||
|
@ -35,17 +35,34 @@ err(){
|
||||||
printf "[ERROR] %s\n" "$1"
|
printf "[ERROR] %s\n" "$1"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
download_new_version(){
|
||||||
|
source_script=$(realpath "$0")
|
||||||
|
source_dir=$(dirname "$source_script")
|
||||||
|
mv $source_script $source_script.old
|
||||||
|
curl -Ls "$release_url" > $source_script
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc -eq 0 ]]; then
|
||||||
|
printf "[INFO] Wrote %s to %s\n" $upstream "$source_script"
|
||||||
|
printf "[INFO] Restart app to use new version\n"
|
||||||
|
chmod +x $source_script
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
mv $source_script.old $source_script
|
||||||
|
err "Failed to download new version. Reverting to prior version and quitting."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
version_check(){
|
version_check(){
|
||||||
upstream=$(curl -Ls "$release_url" | awk -F= 'NR==3 {print $2}')
|
upstream=$(curl -Ls "$release_url" | awk -F= 'NR==3 {print $2}')
|
||||||
printf "[INFO] Checking for new version\n"
|
printf "[INFO] Checking for new version\n"
|
||||||
if [[ ! $upstream == "$version" ]]; then
|
if [[ ! $upstream == "$version" ]]; then
|
||||||
printf "[INFO] A newer version of DZTUI is available at:\n$release_url.\n"
|
printf "[INFO] A newer version of DZTUI is available (%s)\n" $upstream
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Continue anyway? [Y/n] " response
|
read -p "Attempt to download new version? [Y/n] " response
|
||||||
if [[ $response == "Y" ]]; then
|
if [[ $response == "Y" ]]; then
|
||||||
break
|
download_new_version
|
||||||
elif [[ $response == "n" ]]; then
|
elif [[ $response == "n" ]]; then
|
||||||
exit_msg
|
break
|
||||||
else
|
else
|
||||||
:
|
:
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue