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

42 lines
1.1 KiB
Bash
Raw Normal View History

2023-05-17 01:23:02 +02:00
#!/usr/bin/env bash
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