mirror of
https://github.com/aclist/dztui.git
synced 2025-04-02 02:23:01 +02:00
fix: add fallback logic to installscript
This commit is contained in:
parent
cbecf569ad
commit
d4d0593927
1 changed files with 40 additions and 7 deletions
47
install.sh
Normal file → Executable file
47
install.sh
Normal file → Executable file
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue