Skip to content

Commit 35595ed

Browse files
author
Kristian Amlie
committed
MEN-2060: New inventory script for "os" attribute, installed by default.
Changelog: Title Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech> (cherry picked from commit cdaa465)
1 parent fe9cb4a commit 35595ed

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

support/mender-inventory-os

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
# Returns an "os" attribute to Mender containing the currently running OS.
4+
5+
set -e
6+
7+
for file in /etc/os-release /usr/lib/os-release; do
8+
if [ ! -e $file ]; then
9+
continue
10+
fi
11+
12+
eval "$(egrep '^(PRETTY_NAME|NAME|VERSION)=("[^"]*"|[^" ]*)' $file)"
13+
if [ -n "$PRETTY_NAME" ]; then
14+
echo "os=$PRETTY_NAME"
15+
exit 0
16+
elif [ -n "$NAME" -a -n "$VERSION" ]; then
17+
echo "os=$NAME $VERSION"
18+
exit 0
19+
fi
20+
done
21+
22+
if [ -x /usr/bin/lsb_release ]; then
23+
OS="$(/usr/bin/lsb_release -sd)"
24+
if [ -n "$OS" ]; then
25+
echo "os=$OS"
26+
exit 0
27+
fi
28+
fi
29+
30+
if [ -e /etc/issue ]; then
31+
OS="$(cat /etc/issue)"
32+
if [ -n "$OS" ]; then
33+
echo "os=$OS"
34+
exit 0
35+
fi
36+
fi
37+
38+
echo "os=unknown"
39+
exit 0

0 commit comments

Comments
 (0)