Skip to content

Commit

Permalink
Merge pull request #832 from janosdebugs/patch-1
Browse files Browse the repository at this point in the history
Better OS detection
  • Loading branch information
hellt authored Mar 21, 2022
2 parents 90d3de2 + 0df5fff commit 7e073ab
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,27 @@ detectOS() {
# Minimalist GNU for Windows
mingw*) OS='windows' ;;
esac

if type "rpm" &>/dev/null; then
PKG_FORMAT="rpm"
elif type "dpkg" &>/dev/null; then
PKG_FORMAT="deb"

if [ -f /etc/os-release ]; then
OS_ID="$(. /etc/os-release && echo "$ID")"
fi
case "${OS_ID}" in
ubuntu|debian|raspbian)
PKG_FORMAT="deb"
;;

centos|rhel|sles)
PKG_FORMAT="rpm"
;;

*)
if type "rpm" &>/dev/null; then
PKG_FORMAT="rpm"
elif type "dpkg" &>/dev/null; then
PKG_FORMAT="deb"
fi
;;
esac
}

# runs the given command as root (detects if we are root already)
Expand Down

0 comments on commit 7e073ab

Please sign in to comment.