Improve download script

This commit is contained in:
crschnick 2023-05-10 00:13:49 +00:00
parent 90bc07981f
commit 2c9d26f65f

View file

@ -19,6 +19,7 @@ get_file_ending() {
;; ;;
*) *)
exit 1 exit 1
;;
esac esac
} }
@ -79,6 +80,7 @@ parse_os_name() {
;; ;;
*) *)
return 1 return 1
;;
esac esac
return 0 return 0
} }
@ -87,17 +89,24 @@ uninstall() {
local uname_str="$(uname -s)" local uname_str="$(uname -s)"
case "$uname_str" in case "$uname_str" in
Linux) Linux)
if [ -d "/opt/xpipe" ]; then
info "Uninstalling previous version"
if [ -f "/etc/debian_version" ]; then if [ -f "/etc/debian_version" ]; then
DEBIAN_FRONTEND=noninteractive sudo apt-get remove -qy xpipe DEBIAN_FRONTEND=noninteractive sudo apt-get remove -qy xpipe
else else
sudo rpm -e xpipe sudo rpm -e xpipe
fi fi
fi
;; ;;
Darwin) Darwin)
if [ -d "/Applications/X-Pipe.app" ]; then
info "Uninstalling previous version"
sudo /Applications/X-Pipe.app/Contents/Resources/scripts/uninstall.sh sudo /Applications/X-Pipe.app/Contents/Resources/scripts/uninstall.sh
fi
;; ;;
*) *)
exit 1 exit 1
;;
esac esac
} }
@ -118,6 +127,7 @@ install() {
;; ;;
*) *)
exit 1 exit 1
;;
esac esac
} }
@ -159,16 +169,17 @@ check_architecture() {
return 1 return 1
} }
# return if sourced (for testing the functions above) # return if sourced (for testing the functions above)
return 0 2>/dev/null return 0 2>/dev/null
check_architecture "$(uname -m)" || exit 1 check_architecture "$(uname -m)" || exit 1
download_archive="$(download_release; exit "$?")" download_archive="$(
download_release
exit "$?"
)"
exit_status="$?" exit_status="$?"
if [ "$exit_status" != 0 ] if [ "$exit_status" != 0 ]; then
then
error "Could not download X-Pipe release." error "Could not download X-Pipe release."
exit "$exit_status" exit "$exit_status"
fi fi