mirror of
https://github.com/librenms/librenms-agent.git
synced 2024-05-09 09:54:52 +00:00
Use os-release whenever possible for the distro script (#220)
Except centos... https://bugs.centos.org/view.php?id=8359
This commit is contained in:
35
snmp/distro
35
snmp/distro
@ -24,6 +24,7 @@ elif [ "${OS}" = "Linux" ] ; then
|
|||||||
DIST=$(cat /etc/redhat-release | awk '{print $1}')
|
DIST=$(cat /etc/redhat-release | awk '{print $1}')
|
||||||
if [ "${DIST}" = "CentOS" ]; then
|
if [ "${DIST}" = "CentOS" ]; then
|
||||||
DIST="CentOS"
|
DIST="CentOS"
|
||||||
|
IGNORE_OS_RELEASE=1 # https://bugs.centos.org/view.php?id=8359
|
||||||
elif [ "${DIST}" = "CloudLinux" ]; then
|
elif [ "${DIST}" = "CloudLinux" ]; then
|
||||||
DIST="CloudLinux"
|
DIST="CloudLinux"
|
||||||
elif [ "${DIST}" = "Mandriva" ]; then
|
elif [ "${DIST}" = "Mandriva" ]; then
|
||||||
@ -77,10 +78,6 @@ elif [ "${OS}" = "Linux" ] ; then
|
|||||||
REV=$(sed -n -e 's/^.*PHOTON_BUILD_NUMBER=//p' /etc/photon-release)
|
REV=$(sed -n -e 's/^.*PHOTON_BUILD_NUMBER=//p' /etc/photon-release)
|
||||||
IGNORE_LSB=1 # photon os does not have /etc/lsb-release nor lsb_release
|
IGNORE_LSB=1 # photon os does not have /etc/lsb-release nor lsb_release
|
||||||
|
|
||||||
elif [ -f /etc/os-release ] ; then
|
|
||||||
DIST=$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '"')
|
|
||||||
REV=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '"')
|
|
||||||
|
|
||||||
elif [ -f /etc/openwrt_version ] ; then
|
elif [ -f /etc/openwrt_version ] ; then
|
||||||
DIST="OpenWrt"
|
DIST="OpenWrt"
|
||||||
REV=$(cat /etc/openwrt_version)
|
REV=$(cat /etc/openwrt_version)
|
||||||
@ -94,17 +91,6 @@ elif [ "${OS}" = "Linux" ] ; then
|
|||||||
REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
|
REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
|
|
||||||
LSB_DIST=$(lsb_release -si)
|
|
||||||
LSB_REV=$(lsb_release -sr)
|
|
||||||
if [ "$LSB_DIST" != "" ] ; then
|
|
||||||
DIST=$LSB_DIST
|
|
||||||
fi
|
|
||||||
if [ "$LSB_REV" != "" ] ; then
|
|
||||||
REV=$LSB_REV
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "$(command -v awk)" ]; then # some distros do not ship with awk
|
if [ -x "$(command -v awk)" ]; then # some distros do not ship with awk
|
||||||
if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
|
if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
|
||||||
DIST="dd-wrt"
|
DIST="dd-wrt"
|
||||||
@ -115,8 +101,23 @@ elif [ "${OS}" = "Linux" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${REV}" ]
|
# try standardized os version methods
|
||||||
then
|
if [ -f /etc/os-release -a "${IGNORE_OS_RELEASE}" != 1 ] ; then
|
||||||
|
source /etc/os-release
|
||||||
|
STD_DIST="$NAME"
|
||||||
|
STD_REV="$VERSION_ID"
|
||||||
|
elif [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
|
||||||
|
STD_DIST=$(lsb_release -si)
|
||||||
|
STD_REV=$(lsb_release -sr)
|
||||||
|
fi
|
||||||
|
if [ -n "${STD_DIST}" ]; then
|
||||||
|
DIST="${STD_DIST}"
|
||||||
|
fi
|
||||||
|
if [ -n "${STD_REV}" ]; then
|
||||||
|
REV="${STD_REV}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${REV}" ]; then
|
||||||
OSSTR="${DIST} ${REV}"
|
OSSTR="${DIST} ${REV}"
|
||||||
else
|
else
|
||||||
OSSTR="${DIST}"
|
OSSTR="${DIST}"
|
||||||
|
Reference in New Issue
Block a user