Improve OS detection

- Fix OS detection on Debian when lsb_release is not available
- Closes #123
This commit is contained in:
hwdsl2 2017-03-23 12:39:01 -05:00
parent fec47196d6
commit 6d9eb9a2fa
2 changed files with 10 additions and 4 deletions

View File

@ -21,8 +21,11 @@ exiterr() { echo "Error: $1" >&2; exit 1; }
exiterr2() { echo "Error: 'apt-get install' failed." >&2; exit 1; }
os_type="$(lsb_release -si 2>/dev/null)"
if [ -z "$os_type" ] && [ -f "/etc/lsb-release" ]; then
os_type="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
if [ -z "$os_type" ]; then
[ -f /etc/os-release ] && os_type="$(. /etc/os-release && echo "$ID")"
[ -f /etc/lsb-release ] && os_type="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
[ "$os_type" = "debian" ] && os_type=Debian
[ "$os_type" = "ubuntu" ] && os_type=Ubuntu
fi
if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "Raspbian" ]; then
exiterr "This script only supports Ubuntu/Debian."

View File

@ -47,8 +47,11 @@ check_ip() {
}
os_type="$(lsb_release -si 2>/dev/null)"
if [ -z "$os_type" ] && [ -f "/etc/lsb-release" ]; then
os_type="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
if [ -z "$os_type" ]; then
[ -f /etc/os-release ] && os_type="$(. /etc/os-release && echo "$ID")"
[ -f /etc/lsb-release ] && os_type="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
[ "$os_type" = "debian" ] && os_type=Debian
[ "$os_type" = "ubuntu" ] && os_type=Ubuntu
fi
if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "Raspbian" ]; then
exiterr "This script only supports Ubuntu/Debian."