-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
raspiKernelInfo.sh
executable file
·138 lines (116 loc) · 4.02 KB
/
raspiKernelInfo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#######################################################################################################################
#
# Retrieve information about running kernel on a Raspberry
#
# Call with
# curl -s https://raw.githubusercontent.com/rpi-simonz/raspberryTools/master/raspiKernelInfo.sh | bash
#
####################################################################################################
#
# Copyright (c) 2023-2024 framp at linux-tips-and-tricks dot de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#######################################################################################################################
MYSELF=${0##*/}
VERSION="0.2"
GITREPO="https://github.com/framps/raspberryTools"
function usage() {
cat <<EOF
$MYSELF $VERSION ($GITREPO)
Usage: $MYSELF [option]*
-Options-
-c show the command producing the info, additionally to the short description
-C show the command producing the info, without short description
-f show full (more) infos about the system
EOF
}
function displayAndExec() {
if (( $ONLYCOMMANDS )) ; then
echo "--- $1"
else
if (( $COMMANDS )) ; then
echo "--- ${2:+$2 ---} $1"
else
echo "--- ${2:-$1}"
fi
fi
if grep -q "$" <<< "$1"; then
eval $1
else
$1
fi
echo ""
}
# see https://github.com/RPi-Distro/pi-gen
declare -A STAGE_DESCRIPTION=( \
["stage0"]="Bootstrap" \
["stage1"]="Truly minimal system" \
["stage2"]="Lite system" \
["stage3"]="Desktop system" \
["stage4"]="Normal Raspbian image" \
["stage5"]="The Raspbian Full image" \
)
function extractStageDescription() {
local stage=""
stage="$(grep "^Generated" /etc/rpi-issue)"
stage="${stage##* }" # retrieve last field
if [[ "${STAGE_DESCRIPTION[$stage]+abc}" ]]; then
echo "${STAGE_DESCRIPTION[$stage]}"
else
echo "Unknown stage"
fi
}
COMMANDS=0
ONLYCOMMANDS=0
FULL=0
while (( "$#" )); do
case "$1" in
-c|--commands)
COMMANDS=1 ; shift 1
;;
-C|--onlycommands)
ONLYCOMMANDS=1 ; shift 1
;;
-f|--full)
FULL=1 ; shift 1
;;
-h|--help)
usage ; exit
;;
esac
done
echo "$MYSELF $VERSION ($GITREPO)"
if (( $FULL )) ; then
displayAndExec "tail -4 /proc/cpuinfo" "CPUINFO"
else
displayAndExec "tail -4 /proc/cpuinfo | grep -v \"^Serial\"" "CPUINFO"
fi
displayAndExec "free --human | grep -E '^Speicher:|Mem:' | cut -c -20" "MEMORY"
(( $FULL )) && displayAndExec "(ip --brief link ; ip --brief address) | grep -v '^lo'" "NETWORK"
displayAndExec "grep PRETTY_NAME /etc/os-release" "OS"
if [[ -f /etc/rpi-issue ]]; then
displayAndExec "cat /etc/rpi-issue ; echo -e \"($(extractStageDescription))\"" "ORIGINAL IMAGE"
fi
configFile="/boot/config.txt"
[[ -f /boot/firmware/config.txt ]] && configFile="/boot/firmware/config.txt"
[[ -f $configFile ]] && displayAndExec "grep arm_64bit $configFile" "64 BIT SET IN CONFIG?"
displayAndExec "getconf LONG_BIT" "SOFTWARE BITS"
displayAndExec "dpkg --print-architecture" "SOFTWARE ARCH"
displayAndExec "uname -a" "SYSTEM INFORMATION"
(( $FULL )) && displayAndExec "sudo parted -l | grep -v -e '^Sector' -e '^Partition' -e '^$' -e '^Disk Flags'" "STORAGE"
(( $FULL )) && displayAndExec "lsblk -f" "STORAGE"
displayAndExec "echo \$XDG_SESSION_TYPE" "X11, WAYLAND OR TTY"
[[ -n $DESKTOP_SESSION ]] && displayAndExec "echo \$DESKTOP_SESSION"