1
0
mirror of synced 2024-11-26 23:06:03 +03:00

Improve OS detection

- Check /etc/lsb-release if command "lsb_release" is missing
This commit is contained in:
hwdsl2 2017-01-02 01:43:21 -06:00
parent 3dbf3a9c09
commit 9ea2b50dae
2 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,9 @@ exiterr() { echo "Error: $1" >&2; exit 1; }
exiterr2() { echo "Error: 'apt-get install' failed." >&2; exit 1; } exiterr2() { echo "Error: 'apt-get install' failed." >&2; exit 1; }
os_type="$(lsb_release -si 2>/dev/null)" 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")"
fi
if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "Raspbian" ]; then if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "Raspbian" ]; then
exiterr "This script only supports Ubuntu/Debian." exiterr "This script only supports Ubuntu/Debian."
fi fi

View File

@ -46,6 +46,9 @@ check_ip() {
} }
os_type="$(lsb_release -si 2>/dev/null)" 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")"
fi
if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "Raspbian" ]; then if [ "$os_type" != "Ubuntu" ] && [ "$os_type" != "Debian" ] && [ "$os_type" != "Raspbian" ]; then
exiterr "This script only supports Ubuntu/Debian." exiterr "This script only supports Ubuntu/Debian."
fi fi