Debian Codegraph @

support/mender-inventory-os

raw
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 for lsb_release in /bin/lsb_release /usr/bin/lsb_release; do
23 if [ -x $lsb_release ]; then
24 OS="$($lsb_release -sd)"
25 if [ -n "$OS" ]; then
26 echo "os=$OS"
27 exit 0
28 fi
29 fi
30 done
31
32 if [ -e /etc/issue ]; then
33 OS="$(cat /etc/issue)"
34 if [ -n "$OS" ]; then
35 echo "os=$OS"
36 exit 0
37 fi
38 fi
39
40 echo "os=unknown"
41 exit 0