forked from ungleich-public/cdist
Merge branch 'feature/explorer/os_version/ubuntu-os-release-fallback' into 'master'
explorer/os_version: Fall back to os-release/lsb-release file on Ubuntu See merge request ungleich-public/cdist!1014
This commit is contained in:
commit
f9ce4bc33a
1 changed files with 25 additions and 1 deletions
|
@ -21,6 +21,17 @@
|
||||||
# All os variables are lower case
|
# All os variables are lower case
|
||||||
#
|
#
|
||||||
|
|
||||||
|
rc_getvar() {
|
||||||
|
awk -F= -v varname="$2" '
|
||||||
|
function unquote(s) {
|
||||||
|
if (s ~ /^".*"$/ || s ~ /^'\''.*'\''$/)
|
||||||
|
return substr(s, 2, length(s) - 2)
|
||||||
|
else
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
$1 == varname { print unquote(substr($0, index($0, "=") + 1)) }' "$1"
|
||||||
|
}
|
||||||
|
|
||||||
case $("${__explorer:?}/os")
|
case $("${__explorer:?}/os")
|
||||||
in
|
in
|
||||||
amazon)
|
amazon)
|
||||||
|
@ -114,7 +125,20 @@ in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ubuntu)
|
ubuntu)
|
||||||
lsb_release -sr
|
if command -v lsb_release >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
lsb_release -sr
|
||||||
|
elif test -r /usr/lib/os-release
|
||||||
|
then
|
||||||
|
# fallback to /usr/lib/os-release if lsb_release is not present (like
|
||||||
|
# on minimized Ubuntu installations)
|
||||||
|
rc_getvar /usr/lib/os-release VERSION_ID
|
||||||
|
elif test -r /etc/lsb-release
|
||||||
|
then
|
||||||
|
# extract DISTRIB_RELEASE= variable from /etc/lsb-release on old
|
||||||
|
# versions without /usr/lib/os-release.
|
||||||
|
rc_getvar /etc/lsb-release DISTRIB_RELEASE
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
alpine)
|
alpine)
|
||||||
cat /etc/alpine-release
|
cat /etc/alpine-release
|
||||||
|
|
Loading…
Reference in a new issue