1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci# Before running this script please ensure that your PATH is
3f08c3bdfSopenharmony_ci# typical as you use for compilation/istallation. I use
4f08c3bdfSopenharmony_ci# /bin /sbin /usr/bin /usr/sbin /usr/local/bin, but it may
5f08c3bdfSopenharmony_ci# differ on your system.
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ciPATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_citst_cmd_available()
10f08c3bdfSopenharmony_ci{
11f08c3bdfSopenharmony_ci	if type command > /dev/null 2>&1; then
12f08c3bdfSopenharmony_ci		command -v $1 > /dev/null 2>&1 || return 1
13f08c3bdfSopenharmony_ci	else
14f08c3bdfSopenharmony_ci		which $1 > /dev/null 2>&1
15f08c3bdfSopenharmony_ci		if [ $? -eq 0 ]; then
16f08c3bdfSopenharmony_ci			return 0
17f08c3bdfSopenharmony_ci		else
18f08c3bdfSopenharmony_ci			return 1
19f08c3bdfSopenharmony_ci		fi
20f08c3bdfSopenharmony_ci	fi
21f08c3bdfSopenharmony_ci}
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_citst_cmd_run()
24f08c3bdfSopenharmony_ci{
25f08c3bdfSopenharmony_ci	local cmd="$1"
26f08c3bdfSopenharmony_ci	shift
27f08c3bdfSopenharmony_ci	tst_cmd_available $cmd && eval "$cmd $@"
28f08c3bdfSopenharmony_ci}
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_ciis_enabled()
31f08c3bdfSopenharmony_ci{
32f08c3bdfSopenharmony_ci	[ -f "$1" ] && [ "$(cat $1)" = "Y" -o "$(cat $1)" = "1" ]
33f08c3bdfSopenharmony_ci}
34f08c3bdfSopenharmony_ci
35f08c3bdfSopenharmony_ciecho 'If some fields are empty or look unusual you may have an old version.'
36f08c3bdfSopenharmony_ciecho 'Compare to the current minimal requirements in Documentation/Changes.'
37f08c3bdfSopenharmony_ci
38f08c3bdfSopenharmony_ciecho
39f08c3bdfSopenharmony_ciecho "`ls /etc/*release 2> /dev/null`"
40f08c3bdfSopenharmony_cicat /etc/*release 2> /dev/null
41f08c3bdfSopenharmony_ciif [ $? = 1 ]; then
42f08c3bdfSopenharmony_ci   echo "`ls /usr/lib/*release 2> /dev/null`"
43f08c3bdfSopenharmony_ci   cat /usr/lib/*release 2> /dev/null
44f08c3bdfSopenharmony_cifi
45f08c3bdfSopenharmony_ciif [ $? = 1 ]; then
46f08c3bdfSopenharmony_ci   echo '/etc/issue:'
47f08c3bdfSopenharmony_ci   cat /etc/issue 2> /dev/null
48f08c3bdfSopenharmony_cifi
49f08c3bdfSopenharmony_ciif [ $? = 1 ]; then
50f08c3bdfSopenharmony_ci	echo 'lsb_release -a'
51f08c3bdfSopenharmony_ci	lsb_release -a 2> /dev/null
52f08c3bdfSopenharmony_cifi
53f08c3bdfSopenharmony_ci
54f08c3bdfSopenharmony_ciecho
55f08c3bdfSopenharmony_ciecho 'uname:'
56f08c3bdfSopenharmony_ciuname -a
57f08c3bdfSopenharmony_ci
58f08c3bdfSopenharmony_ciecho
59f08c3bdfSopenharmony_ciecho '/proc/cmdline'
60f08c3bdfSopenharmony_cicat /proc/cmdline
61f08c3bdfSopenharmony_ci
62f08c3bdfSopenharmony_ciecho
63f08c3bdfSopenharmony_ci
64f08c3bdfSopenharmony_ciecho "Gnu C                 " `gcc --version 2>/dev/null | head -n 1`
65f08c3bdfSopenharmony_ciecho "Clang                 " `clang --version 2>/dev/null | head -n 1`
66f08c3bdfSopenharmony_ci
67f08c3bdfSopenharmony_cimake --version 2>&1 | awk -F, '{print $1}' | awk \
68f08c3bdfSopenharmony_ci      '/GNU Make/{print "Gnu make              ",$NF}'
69f08c3bdfSopenharmony_ci
70f08c3bdfSopenharmony_cild -v 2>&1 | awk -F\) '{print $1}' | awk \
71f08c3bdfSopenharmony_ci      '/BFD/{print "binutils              ",$NF}'
72f08c3bdfSopenharmony_ci
73f08c3bdfSopenharmony_cimkswap -V 2>&1 | awk '{print "util-linux            ", $NF}'
74f08c3bdfSopenharmony_ci
75f08c3bdfSopenharmony_cimount --version 2>&1 | awk -F\- '{print "mount                 ", $NF}'
76f08c3bdfSopenharmony_ci
77f08c3bdfSopenharmony_ciinsmod -V  2>&1 | awk 'NR==1 {print "modutils              ",$NF}'
78f08c3bdfSopenharmony_ci
79f08c3bdfSopenharmony_citune2fs 2>&1 | grep "^tune2fs" | sed 's/,//' |  awk \
80f08c3bdfSopenharmony_ci'NR==1 {print "e2fsprogs             ", $2}'
81f08c3bdfSopenharmony_ci
82f08c3bdfSopenharmony_cireiserfsck 2>&1 | grep reiserfsprogs | awk \
83f08c3bdfSopenharmony_ci'NR==1{print "reiserfsprogs         ", $NF}'
84f08c3bdfSopenharmony_ci
85f08c3bdfSopenharmony_cicardmgr -V 2>&1| grep version | awk \
86f08c3bdfSopenharmony_ci'NR==1{print "pcmcia-cs             ", $3}'
87f08c3bdfSopenharmony_ci
88f08c3bdfSopenharmony_cipppd --version 2>&1| grep version | awk \
89f08c3bdfSopenharmony_ci'NR==1{print "PPP                   ", $3}'
90f08c3bdfSopenharmony_ci
91f08c3bdfSopenharmony_ciisdnctrl 2>&1 | grep version | awk \
92f08c3bdfSopenharmony_ci'NR==1{print "isdn4k-utils          ", $NF}'
93f08c3bdfSopenharmony_ci
94f08c3bdfSopenharmony_cils -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed \
95f08c3bdfSopenharmony_ci-e 's/\.so$//' | awk -F'[.-]'   '{print "Linux C Library        " \
96f08c3bdfSopenharmony_ci$(NF-2)"."$(NF-1)"."$NF}'
97f08c3bdfSopenharmony_ci
98f08c3bdfSopenharmony_cildd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
99f08c3bdfSopenharmony_ci'NR==1{print "Dynamic linker (ldd)  ", $NF}'
100f08c3bdfSopenharmony_ci
101f08c3bdfSopenharmony_cils -l /usr/lib/lib{g,stdc}++.so  2>/dev/null | awk -F. \
102f08c3bdfSopenharmony_ci       '{print "Linux C++ Library      " $4"."$5"."$6}'
103f08c3bdfSopenharmony_ci
104f08c3bdfSopenharmony_cips --version 2>&1 | awk 'NR==1{print "Procps                ", $NF}'
105f08c3bdfSopenharmony_ci
106f08c3bdfSopenharmony_ciifconfig --version 2>&1 | grep tools | awk \
107f08c3bdfSopenharmony_ci'NR==1{print "Net-tools             ", $NF}'
108f08c3bdfSopenharmony_ci
109f08c3bdfSopenharmony_ciip -V 2>&1 | awk \
110f08c3bdfSopenharmony_ci'NR==1{print "iproute2              ", $NF}'
111f08c3bdfSopenharmony_ci
112f08c3bdfSopenharmony_ciping -V 2>&1 | awk \
113f08c3bdfSopenharmony_ci'NR==1{print "iputils               ", $NF}'
114f08c3bdfSopenharmony_ci
115f08c3bdfSopenharmony_ciethtool --version | grep version 2>&1 | awk \
116f08c3bdfSopenharmony_ci'NR==1{print "ethtool               ", $NF}'
117f08c3bdfSopenharmony_ci
118f08c3bdfSopenharmony_ci# Kbd needs 'loadkeys -h',
119f08c3bdfSopenharmony_ciloadkeys -h 2>&1 | awk \
120f08c3bdfSopenharmony_ci'(NR==1 && ($3 !~ /option/)) {print "Kbd                   ", $3}'
121f08c3bdfSopenharmony_ci
122f08c3bdfSopenharmony_ci# while console-tools needs 'loadkeys -V'.
123f08c3bdfSopenharmony_ciloadkeys -V 2>&1 | awk \
124f08c3bdfSopenharmony_ci'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools         ", $3}'
125f08c3bdfSopenharmony_ci
126f08c3bdfSopenharmony_ciexpr --v 2>&1 | awk 'NR==1{print "Sh-utils              ", $NF}'
127f08c3bdfSopenharmony_ci
128f08c3bdfSopenharmony_ciif [ -e /proc/modules ]; then
129f08c3bdfSopenharmony_ci    X=`cat /proc/modules | sed -e "s/ .*$//"`
130f08c3bdfSopenharmony_ci    echo "Modules Loaded         "$X
131f08c3bdfSopenharmony_cifi
132f08c3bdfSopenharmony_ci
133f08c3bdfSopenharmony_ciecho
134f08c3bdfSopenharmony_ciecho 'cpuinfo:'
135f08c3bdfSopenharmony_citst_cmd_run lscpu || cat /proc/cpuinfo
136f08c3bdfSopenharmony_ci
137f08c3bdfSopenharmony_ciecho
138f08c3bdfSopenharmony_ciecho 'free reports:'
139f08c3bdfSopenharmony_cifree
140f08c3bdfSopenharmony_ci
141f08c3bdfSopenharmony_ciecho
142f08c3bdfSopenharmony_ciecho 'memory (/proc/meminfo):'
143f08c3bdfSopenharmony_cicat /proc/meminfo
144f08c3bdfSopenharmony_ci
145f08c3bdfSopenharmony_ciecho
146f08c3bdfSopenharmony_ciecho 'available filesystems:'
147f08c3bdfSopenharmony_ciecho $(cut -f2 /proc/filesystems | sort -u)
148f08c3bdfSopenharmony_ci
149f08c3bdfSopenharmony_ciecho
150f08c3bdfSopenharmony_ciecho 'mounted filesystems (/proc/mounts):'
151f08c3bdfSopenharmony_cicat /proc/mounts
152f08c3bdfSopenharmony_ci
153f08c3bdfSopenharmony_ciecho
154f08c3bdfSopenharmony_ciecho 'mounted filesystems (df):'
155f08c3bdfSopenharmony_ciif `df -hT >/dev/null 2>/dev/null`; then
156f08c3bdfSopenharmony_ci	df -hT
157f08c3bdfSopenharmony_cielse
158f08c3bdfSopenharmony_ci	df
159f08c3bdfSopenharmony_cifi
160f08c3bdfSopenharmony_ci
161f08c3bdfSopenharmony_ci
162f08c3bdfSopenharmony_ciecho
163f08c3bdfSopenharmony_ciif is_enabled /sys/module/apparmor/parameters/enabled; then
164f08c3bdfSopenharmony_ci	echo 'AppArmor enabled'
165f08c3bdfSopenharmony_ci	tst_cmd_run aa-status
166f08c3bdfSopenharmony_cielse
167f08c3bdfSopenharmony_ci	echo 'AppArmor disabled'
168f08c3bdfSopenharmony_cifi
169f08c3bdfSopenharmony_ci
170f08c3bdfSopenharmony_ciecho
171f08c3bdfSopenharmony_ci
172f08c3bdfSopenharmony_ciif ! tst_cmd_run sestatus; then
173f08c3bdfSopenharmony_ci	printf 'SELinux mode: '
174f08c3bdfSopenharmony_ci	tst_cmd_run getenforce || echo 'unknown'
175f08c3bdfSopenharmony_cifi
176