-
Notifications
You must be signed in to change notification settings - Fork 5
/
stretch-system_info.v2.1.2
6370 lines (5777 loc) · 159 KB
/
stretch-system_info.v2.1.2
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# system_info.sh
# Written by: Ken Cormack, unixken@yahoo.com
# Copyright (c) 2020, Ken Cormack
# github: https://github.com/kencormack/system_info
# license: GPL 3.0
# Contributor: William Stearns, william.l.stearns@gmail.com
#
# This script attempts to perform a fairly complete audit of the current
# configuration of a Raspberry Pi. The target hardware is any variant or
# model of Pi, up to and including the Pi 4B, 400, and CM4 modules.
#
# Supported OS versions include Raspbian Stretch and Buster (including
# the newly renamed "Raspberry Pi OS", in 32-bit.) Expect things not to
# work on the 64-bit OS, while it is still beta. No attempts will be made
# to back-port this to Jessie or older, nor will I attempt to port this to
# Ubuntu, OSMC, LibreELEC, or any other OS distribution available for the Pi.
#
# See the README.md file, at the github link above, for additional info.
#
##################################################
#---------------
# Called by fnMAIN
#
fnGET_HELP()
{
# This line, included in every function, is part of the debugging/trace
# log stuff used in testing & development of this script. See the file
# DEBBUGGING.md on the github page, for a full explaination of how I
# chose to implement a debug/trace log.
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# Thor: "Hey, let's do 'Get Help'. It's great. Works every time."
# Loki: "It's humiliating. We are not doing 'Get Help'."
if [[ "${MY_ARG}" = "--help" ]] || [[ "${MY_ARG}" = "-h" ]]
then
# Thor: "GET HELP! MY BROTHER'S DYING!"
clear
echo
echo -e "SYSTEM_INFO v${MY_VERSION} - HELP"
cat <<'EOF'
$ system_info*
Run normally, the script shows a menu of different categories to examine.
Multiple selections can be made. Pressing ENTER by itself executes the
selected options. If 17 is selected, then all options are executed,
regardless of whether they were selected. Choices are saved, and the menu
pre-loaded with those selections, the next time the script is run.
$ system_info* [1-17]
If a menu option is specified as a parameter, saved selections are ignored,
and the specified category selected. Only a single category can be given
in this way. If 17 is specified, then all categories run, just as if
option 17 were selected from the menu. Any option specified in this way is
NOT saved for pre-loading the next time the script is run.
$ system_info* [3> filename]
For development/testing. Writes debug/trace data to the specified file.
$ system_info* [ -h | --help ]
You are here.
EOF
# Thor: "Classic!"
# Loki: "Humiliating."
# -- 'Thor: Ragnarok'
exit
fi
}
#---------------
# Called by fnMAIN
#
fnINITIALIZE()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# Indexed arrays
declare -a CHOICES
declare -a OPTIONS
export PATH="${PATH:+${PATH}:}/usr/sbin:/sbin"
LC_ALL=C
LANG=C
if [[ "${TERM}" = "" ]] || [[ "${TERM}" = "dumb" ]]
then
REV=""
SGR0=""
BELL=""
else
REV="$(tput rev 2>/dev/null)"
SGR0="$(tput sgr0 2>/dev/null)"
BELL="$(tput bel 2>/dev/null)"
fi
RCFILE="${HOME}/.system_inforc"
ERROR=" "
DEG_SYMBOL=$'\xc2\xb0'
SECTION=""
}
#---------------
# Called by fnMAIN
#
fnDEFINE_OPTIONS()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# The array of menu OPTIONS is defined
OPTIONS[0]="Pi Hardware"
OPTIONS[1]="Performance"
OPTIONS[2]="O/S Config"
OPTIONS[3]="Memory"
OPTIONS[4]="Logging"
OPTIONS[5]="Services"
OPTIONS[6]="Hardware Busses"
OPTIONS[7]="Serial & Bluetooth"
OPTIONS[8]="USB & Other Devices"
OPTIONS[9]="Filesystems & Storage"
OPTIONS[10]="Audio & Video"
OPTIONS[11]="Networking"
OPTIONS[12]="Network Filesystems"
OPTIONS[13]="Containers & Virtualization"
OPTIONS[14]="Modules and Packages"
OPTIONS[15]="System Security"
OPTIONS[16]="Run All Of The Above"
}
#---------------
# Called by fnMAIN
#
fnCONFIRM_BASH()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# This guards against people launching this script with an incorrect shell,
# such as by running 'sh scriptname', overriding the 'shebang'.
if [[ "${BASH_VERSION}" = "" ]]
then
clear
echo "${BELL}"
echo "################################################################"
echo
echo "ERROR: THE WRONG SHELL IS BEING USED TO RUN THIS SCRIPT."
echo
echo "${0} is written for the bash shell only."
echo "It will not run under sh, ksh, or any other shell but \"bash\"."
echo
echo "Please do either this..."
echo " $ chmod +x ${0}"
echo " $ ./${0}"
echo
echo "or this..."
echo " $ bash ${0}"
echo
echo "...to execute under bash, as intended."
echo
echo "################################################################"
echo
exit
fi
}
#---------------
# Called by the mainline
#
fnABORT()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# Called by a trap, whenever the signals
# SIGHUP SIGINT SIGQUIT SIGABRT or SIGTERM
# are received. We clean up after ourselves.
echo
echo "ABORT${BELL}"
# delete the lshw tmp file
rm /tmp/.lshw_businfo."${PPID}" 2>/dev/null
# close the debugging file descriptor
exec 3>&- 2> /dev/null
# exit the script
exit
}
#---------------
# Called by fnMAIN and fnDO_INSPECTIONS
#
fnTITLE()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
echo
echo " _ VERSION ${MY_VERSION} _ __"
echo $' ___ _ _ ___| |_ ___ _ __ ___ (_)_ __ / _| ___'
echo $'/ __| | | / __| __/ _ \\ \'_ \` _ \\ | | \'_ \\| |_ / _ \\'
echo $'\__ \ |_| \__ \ || __/ | | | | | | | | | | _| (_) |'
echo $'|___/\__, |___/\__\___|_| |_| |_| |_|_| |_|_| \___/'
echo $' |___/'
echo " RASPBERRY PI SYSTEM INFORMATION REPORT"
echo
}
#---------------
# Called by multiple functions
#
fnBANNER()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
echo "==============================================================================="
echo "SYSTEM_INFO(${SECTION}): ${*}"
echo "==============================================================================="
echo
}
#---------------
# Called by multiple functions
#
fnSUB_BANNER()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
echo "-------------------------------------------------------"
echo " ${*}"
echo
}
#---------------
# Inspect the mode (permissions - in octal), owner, and group of a
# specified directory or file.
# Called by passing 4 parameters to the function as follows:
# fnMOG octal_mode owner group directory
# Called by fnUSERCHECK and fnCHECK_PERMISSIONS
#
fnMOG()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
local OCTAL=""
local OWNER=""
local GROUP=""
local CHECKPATH=""
local COCTAL=""
local SYMBOLIC=""
local COWNER=""
local CGROUP=""
OCTAL="${1}" # recommended perms, eg: 755 (rwxr-xr-x)
OWNER="${2}" # recommended owner
GROUP="${3}" # recommended group
CHECKPATH="${4}" # path to check
if [[ -e "${CHECKPATH}" ]]
then
# Run commands
COCTAL="$(${SUDO} stat -L -c %a "${CHECKPATH}")"
SYMBOLIC="$(${SUDO} stat -L -c %A "${CHECKPATH}")"
COWNER="$(${SUDO} stat -L -c %U "${CHECKPATH}")"
CGROUP="$(${SUDO} stat -L -c %G "${CHECKPATH}")"
# Compare
echo "[${CHECKPATH}]"
if [[ "${COCTAL}" != "${OCTAL}" ]]
then
echo " Permissions ... WARN [${COCTAL}] (${SYMBOLIC}) - Recommend [${OCTAL}])"
else
echo " Permissions ... OK [${OCTAL}] (${SYMBOLIC})"
fi
if [[ "${COWNER}" != "${OWNER}" ]]
then
echo " Owner ......... WARN [${COWNER}] - Recommend [${OWNER}]"
else
echo " Owner ......... OK [${OWNER}]"
fi
if [[ "${CGROUP}" != "${GROUP}" ]]
then
echo " Group ......... WARN [${CGROUP}] - Recommend [${GROUP}]"
else
echo " Group ......... OK [${GROUP}]"
fi
fi
}
#---------------
# Called by fnCONFIRM_PREREQS
# Calls fnBANNER
#
fnCONFIRM_OS()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# Written for Raspbian Stretch and above. Jessie and older not supported.
# if os-release file exists...
if [[ -f /etc/os-release ]]
then
# source the os-release file
. /etc/os-release 2>/dev/null
# if Raspbian...
if [[ "${ID}" = "raspbian" ]]
then
# and if older than Stretch...
if [[ "$(echo "${VERSION_ID} < 9" | bc)" -eq 1 ]]
then
# too old.
echo
fnBANNER "UNSUPPORTED RASPBIAN VERSION"
echo "This script is designed for Raspbian GNU/Linux 9 (Stretch), and above."
echo "Version ${PRETTY_NAME} is not supported."
echo
exit 1
else
# if Raspbian, and Stretch or newer, then ok.
echo "OS version check: ok"
fi
else
# if not Raspbian, then unsupported.
echo
fnBANNER "LINUX VERSION UNKNOWN"
echo "This script is designed for Raspbian GNU/Linux 9 (Stretch), and above."
echo "Unable to identify your version of the operating system... Exiting."
echo
exit 1
fi
else
# if os-release file doesn't exist...
echo
fnBANNER "LINUX VERSION UNKNOWN"
echo "This script is designed for Raspbian GNU/Linux 9 (Stretch), and above."
echo "Unable to identify your version of the operating system... Exiting."
echo
exit 1
fi
}
#---------------
# Called by fnCONFIRM_PREREQS
# Calls fnBANNER
#
fnRING_BUF()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# Check that dmesg contains anything we might need. Examples include the
# "memory split", "active display driver", "rtc", and several other tests.
if [[ "$(dmesg | grep "Booting Linux")" = "" ]]
then
echo
fnBANNER "DMESG RING BUFFER HAS WRAPPED - PLEASE REBOOT"
echo "This script relies on \"dmesg\" to provide some of the data it needs."
echo
echo "Kernel messages are stored in a data structure called a ring buffer."
echo "The buffer is fixed in size, with new data overwriting the oldest data."
echo "When data we need has already been overwritten, that data is lost to us."
echo
echo "Your ring buffer has already wrapped. Please reboot your system before"
echo "attempting to re-run this script, to ensure that the buffer contains"
echo "any data we need."
echo
exit 1
else
echo "dmesg ring buffer: ok"
fi
}
#---------------
# Called by fnCONFIRM_PREREQS
#
fnSUDO()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
# If we're not already root, set "${SUDO}" so that commands that need
# root privs will run under sudo
SUDO=$(type -path sudo)
if [[ "${EUID}" -ne 0 ]] && [[ "${SUDO}" = "" ]]
then
echo
echo "${0} has not been run as root and sudo is not available, exiting." >&2
exit 1
else
echo "running as user: $(whoami)"
if [[ "${EUID}" -ne 0 ]]
then
if [[ -n "${SUDO}" ]]
then
echo "sudo is available: ok"
fi
fi
fi
}
#---------------
# Called by fnCONFIRM_PREREQS
# Calls fnBANNER
#
fnCHECK_VIRT()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
if [[ "$(systemd-detect-virt)" = "none" ]]
then
echo "virtual machine: ok"
else
echo
fnBANNER "RUNNING WITHIN A VIRTUAL MACHINE IS NOT SUPPORTED"
echo "This script does not support running inside a virtual machine."
echo "Please exit the VM and run the script again."
echo
exit 1
fi
}
#---------------
# Called by fnCONFIRM_PREREQS
# Calls fnBANNER
#
fnCHECK_CHROOT()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
if ${SUDO} systemd-detect-virt --chroot
then
echo
fnBANNER "RUNNING WITHIN A CHROOT'D ENVIRONMENT IS NOT SUPPORTED"
echo "This script does not support running in a chroot'd environment."
echo "Please exit the chroot'd environment and run the script again."
echo
exit 1
else
echo "chroot check: ok"
fi
echo
}
#---------------
# Called by fnCONFIRM_PREREQS
# Calls fnNEW_STYLE_REV_CODES and fnOLD_STYLE_REV_CODES
#
fnGET_REVISION_CODE()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
local PCB_REVISION=""
local MODEL_NAME=""
local PROCESSOR=""
local MANUFACTURER=""
local MEMORY_SIZE=""
local ENCODED_FLAG=""
local WARRANTY_VOID_OLD=""
local WARRANTY_VOID_NEW=""
# NOTE: Revision codes, old and new style, are documented here and elsewhere:
# https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/revision-codes/README.md
MY_REVISION=$(awk '/^Revision/ { print $NF }' /proc/cpuinfo 2>/dev/null)
# Force a rev code for testing...
# MY_REVISION=c03141 ; # CM4
# MY_REVISION=1000002 ; # Old rev, expired warranty
# MY_REVISION=0003 ; # Model B w/ mods
# MY_REVISION=2a020d3 ; # Model 3B+, expired warranty
## Some of the following revision-decoding logic was shamelessly borrowed from:
## https://raspberrypi.stackexchange.com/questions/100076/what-revisions-does-cat-proc-cpuinfo-return-on-the-new-pi-4-1-2-4gb
## I've made only some coding style changes to match the rest of this script,
## and accomodated new models released since the original post.
# These are from the new style revision codes, but we can borrow some
# of the values, for the old style codes. The arrays lack the "2.0"
# board revs, the "Qisda" manufacturer, and the "256/512" MB value used
# by some of the old-style revision codes. Rather than modify these
# arrays, I just use those values directly, in sorting out the old codes.
PCB_REVISION=("v1.0" "v1.1" "v1.2" "v1.3" "v1.4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15")
MODEL_NAME=("A" "B" "A+" "B+" "Pi2B" "Alpha" "CM1" "unknown" "3B" "Zero" "CM3" "unknown" "Zero W" "3B+" "3A+" "internal use only" "CM3+" "4B" "18 ?" "400" "CM4")
PROCESSOR=("BCM2835" "BCM2836" "BCM2837" "BCM2711" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15")
MANUFACTURER=("Sony UK" "Egoman" "Embest" "Sony Japan" "Embest" "Stadium" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15")
MEMORY_SIZE=("256 MB" "512 MB" "1024 MB" "2048 MB" "4096 MB" "8192 MB" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15")
ENCODED_FLAG=("" "revision is a bit field")
WARRANTY_VOID_OLD=("" "warranty void - Pre Pi2") # Adds a prefix of "1" to the revision code
WARRANTY_VOID_NEW=("" "warranty void - Post Pi2") # Adds a prefix of "2" to the revision code
# Save as globals so we can make decisions later based on model, ram, etc.
MY_PCB_REVISION=${PCB_REVISION[$((0x${MY_REVISION}&0xf))]}
MY_MODEL_NAME=${MODEL_NAME[$((0x${MY_REVISION}>>4&0xff))]}
MY_PROCESSOR=${PROCESSOR[$((0x${MY_REVISION}>>12&0xf))]}
MY_MANUFACTURER=${MANUFACTURER[$((0x${MY_REVISION}>>16&0xf))]}
MY_MEMORY_SIZE=${MEMORY_SIZE[$((0x${MY_REVISION}>>20&7))]}
MY_ENCODED_FLAG=${ENCODED_FLAG[$((0x${MY_REVISION}>>23&1))]}
MY_WARRANTY_VOID_OLD=${WARRANTY_VOID_OLD[$((0x${MY_REVISION}>>24&1))]}
MY_WARRANTY_VOID_NEW=${WARRANTY_VOID_NEW[$((0x${MY_REVISION}>>25&1))]}
MY_COMMENT=""
MY_RELEASE_DATE=""
ENCODED=$((0x${MY_REVISION} >> 23 & 1))
if [[ ${ENCODED} = 1 ]]
then
# NEW STYLE REV CODES
# See if the rev code has a warranty-void prefix.
# If yes, a 1-char prefix ("1"=Bit 24, or "2"=Bit 25) is present
# and the last 6 chars are the actual revision code
if [[ "${#MY_REVISION}" = 7 ]]
then
MY_WARRANTY_VOID_PREFIX="$(echo "${MY_REVISION}" | cut -c1)"
# Trim off the prefix for other lookups later on.
MY_BASE_REVISION="$(echo "${MY_REVISION}" | cut -c2-)"
else
MY_WARRANTY_VOID_PREFIX=""
MY_BASE_REVISION="${MY_REVISION}"
fi
fnNEW_STYLE_REV_CODES
else
# OLD STYLE REV CODES
# See if the rev code has a warranty-void prefix
# If yes, the 3-char warranty-void prefix ("100") is present
# and the last 4 chars are the actual revision code
if [[ "${#MY_REVISION}" = 7 ]]
then
MY_WARRANTY_VOID_PREFIX="$(echo "${MY_REVISION}" | cut -c1-3)"
# Trim off the prefix for other lookups later on.
MY_BASE_REVISION="$(echo "${MY_REVISION}" | cut -c4-)"
else
# Otherwise, no prefix is present
MY_WARRANTY_VOID_PREFIX=""
MY_BASE_REVISION="${MY_REVISION}"
fi
fnOLD_STYLE_REV_CODES
fi
# Some features of the 4B, also present in later models, allow these
# to be lumped together for certain processing in this script. With
# this, they can all be treated in common fashion without having to
# check for each model type specifically.
case "${MY_MODEL_NAME}" in
4B|CM4|400)
PI4_FAMILY="1"
;;
*)
PI4_FAMILY="0"
;;
esac
# Here, I strip the lead alpha-character from the base revision number,
# that indicates the amount of RAM present (a=1GB, b=4GB, c=4GB, d=8GB),
# to get to the data that otherwise designates the model/rev.
# Pi 4B:
# Revision [abc]03111 is original board with USB-C power design flaw.
# Revision [abc]03112 is v1.2 board with fix.
# (First char, a, b, c or d, refers to 1GB, 2GB, 4GB, or 8GB memory.)
# Revision d03114 is the 8GB v1.4 board, which also has the fix.
if [[ "$(echo "${MY_REVISION}" | cut -c2-)" = "03111" ]]
then
MY_COMMENT="USB-C power design flaw affecting \"Smart\" USB-C cables."
fi
# Pi CM4:
# Educated guesses for the as yet unreleased CM4
if [[ "$(echo "${MY_REVISION}" | cut -c2-)" = "03141" ]]
then
MY_COMMENT="Guessing at this - CM4 rev codes not yet published."
fi
}
#---------------
# Called by fnGET_REVISION_CODE
#
fnNEW_STYLE_REV_CODES()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
case "${MY_BASE_REVISION}" in
a01040)
# 2 Model B
MY_RELEASE_DATE="Unknown"
;;
a01041)
# 2 Model B
MY_RELEASE_DATE="Q1 2015"
;;
a21041)
# 2 Model B
MY_RELEASE_DATE="Q1 2015"
;;
a22042)
# 2 Model B (with BCM2837)
MY_RELEASE_DATE="Q3 2016"
;;
900021)
# A+
MY_RELEASE_DATE="Q3 2016"
;;
900032)
# B+
MY_RELEASE_DATE="Q2 2016?"
;;
900092)
# Zero
MY_RELEASE_DATE="Q4 2015"
;;
900093)
# Zero
MY_RELEASE_DATE="Q2 2016"
;;
920093)
# Zero
MY_RELEASE_DATE="Q4 2016?"
;;
9000c1)
# Zero W
MY_RELEASE_DATE="Q1 2017"
;;
a02082)
# 3 Model B
MY_RELEASE_DATE="Q1 2016"
;;
a020a0)
# CM3 (and CM3 Lite)
MY_RELEASE_DATE="Q1 2017"
;;
a22082)
# 3 Model B
MY_RELEASE_DATE="Q1 2016"
;;
a32082)
# 3 Model B
MY_RELEASE_DATE="Q4 2016"
;;
a020d3)
# 3 Model B+
MY_RELEASE_DATE="Q1 2018"
;;
9020e0)
# 3 Model A+
MY_RELEASE_DATE="Q4 2018"
;;
a02100)
# CM3+
MY_RELEASE_DATE="Q1 2019"
;;
[abc]03111)
# 4 Model B v1.1 - 1/2/4GB
MY_RELEASE_DATE="Q2 2019"
;;
a03112)
# 4 Model B v1.2 - 1GB
MY_RELEASE_DATE="Q1 2020 - Special Order Only"
;;
[bc]03112)
# 4 Model B v1.2 - 2/4GB
MY_RELEASE_DATE="Q1 2020"
;;
d03114)
# 4 Model B v1.4 - 8GB
MY_RELEASE_DATE="Q1 2020"
;;
c03130)
# Pi 400
MY_RELEASE_DATE="Q4 2020"
;;
[abcd]03141)
# CM4 - 1/2/4/8GB?
MY_RELEASE_DATE="Q4 2020"
;;
*)
# No match found
MY_RELEASE_DATE="Unknown"
;;
esac
}
#---------------
# Called by fnGET_REVISION_CODE
#
fnOLD_STYLE_REV_CODES()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
case "${MY_BASE_REVISION}" in
0002)
# B 1.0 256MB
MY_PCB_REVISION=${PCB_REVISION[0]}
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[1]}
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q1 2012"
;;
0003)
# B 1.0 256MB
MY_PCB_REVISION=${PCB_REVISION[0]}
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[1]}
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q3 2012"
MY_COMMENT="Fuses mod and D14 removed"
;;
0004)
# B 2.0 256MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[0]}
MY_RELEASE_DATE="Q3 2012"
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
;;
0005)
# B 2.0 256MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER="Qisda"
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q4 2012"
;;
0006)
# B 2.0 256MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[1]}
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q4 2012"
;;
0007)
# A 2.0 256MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[0]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[1]}
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q1 2013"
;;
0008)
# A 2.0 256MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[0]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[0]}
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q1 2013"
;;
0009)
# A 2.0 256MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[0]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER="Qisda"
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q1 2013"
;;
000d)
# B 2.0 512MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[1]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q4 2012"
;;
000e)
# B 2.0 512MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[0]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q4 2012"
;;
000f)
# B 2.0 512MB
MY_PCB_REVISION="2.0"
MY_MODEL_NAME=${MODEL_NAME[1]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[1]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q4 2012"
;;
0010)
# B+ 1.2 512MB
MY_PCB_REVISION=${PCB_REVISION[2]}
MY_MODEL_NAME=${MODEL_NAME[3]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[0]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q3 2014"
;;
0011)
# CM1 1.0 512MB
MY_PCB_REVISION=${PCB_REVISION[0]}
MY_MODEL_NAME=${MODEL_NAME[6]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[0]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q2 2014"
;;
0012)
# A+ 1.1 256MB
MY_PCB_REVISION=${PCB_REVISION[1]}
MY_MODEL_NAME=${MODEL_NAME[2]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[0]}
MY_MEMORY_SIZE=${MEMORY_SIZE[0]}
MY_RELEASE_DATE="Q4 2014"
;;
0013)
# B+ 1.2 512MB
MY_PCB_REVISION=${PCB_REVISION[2]}
MY_MODEL_NAME=${MODEL_NAME[3]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[2]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q1 2015"
;;
0014)
# CM1 1.0 512MB
MY_PCB_REVISION=${PCB_REVISION[0]}
MY_MODEL_NAME=${MODEL_NAME[6]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[2]}
MY_MEMORY_SIZE=${MEMORY_SIZE[1]}
MY_RELEASE_DATE="Q2 2014"
;;
0015)
# A+ 1.1 256MB/512MB
MY_PCB_REVISION=${PCB_REVISION[1]}
MY_MODEL_NAME=${MODEL_NAME[2]}
MY_PROCESSOR=${PROCESSOR[0]}
MY_MANUFACTURER=${MANUFACTURER[2]}
MY_MEMORY_SIZE="256MB/512MB"
MY_RELEASE_DATE="?"
;;
*)
MY_PCB_REVISION="Unknown"
MY_MODEL_NAME="Unknown"
MY_PROCESSOR="Unknown"
MY_MANUFACTURER="Unknown"
MY_MEMORY_SIZE="Unknown"
MY_RELEASE_DATE="Unknown"
;;
esac
}
#---------------
# Called by fnGROUP_HARDWARE
# Calls fnBANNER
#
fnPRINT_DECODED_REV()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
if [[ ${ENCODED} = 1 ]]
then
fnBANNER "NEW STYLE SYSTEM REVISION NUMBER"
else
fnBANNER "OLD STYLE SYSTEM REVISION NUMBER"
fi
echo "Revision : ${MY_REVISION}"
echo "PCB Revision : ${MY_PCB_REVISION}"
echo "Model Name : ${MY_MODEL_NAME}"
echo "Processor : ${MY_PROCESSOR}"
echo "Manufacturer : ${MY_MANUFACTURER}"
echo "Memory Size : ${MY_MEMORY_SIZE}"
if [[ ${ENCODED} = 1 ]]
then
echo "Encoded Flag : ${MY_ENCODED_FLAG}"
fi
if [[ -n "${MY_WARRANTY_VOID_OLD}" ]] || [[ -n "${MY_WARRANTY_VOID_NEW}" ]] || [[ -n "${MY_WARRANTY_VOID_PREFIX}" ]]
then
echo "Warranty Void : yes"
else
echo "Warranty Void : no"
fi
echo
if [[ -n "${MY_RELEASE_DATE}" ]]
then
echo "Release Date : ${MY_RELEASE_DATE}"
fi
if [[ -n "${MY_COMMENT}" ]]
then
echo "Model Notes : ${MY_COMMENT}"
fi
echo
}
#---------------
# Called by fnCONFIRM_PREREQS
# Calls fnBANNER
#
fnCHK_PACKAGES()
{
echo -e "\nenter: ${FUNCNAME[*]}" >&3
local PKG_MISSING=""
local REQUIRED=""
local REQ_HIT=""
local REQ_MAX=""
local PIGPIO_PKG=""
local DOCKER_PKG=""
local SUPPLEMENTAL=""
local SUP_HIT=""
local SUP_MAX=""
PKG_MISSING=0
if type -path dpkg >/dev/null 2>&1
then
#################################
# First, the required packages
REQUIRED=$(dpkg -l 2>/dev/null | awk '{ print $2 }' | grep -E -i "^alsa-utils$|^bc$|^bluez$|^coreutils$|^cron$|^i2c-tools$|^initramfs-tools$|^iproute2$|^libraspberrypi-bin$|^lsb-release$|^lshw$|^net-tools$|^procps$|^rpi-eeprom$|^sed$|^systemd$|^util-linux$|^usbutils$|^v4l-utils$|^wireless-tools$")
REQ_HIT=0
REQ_MAX=0
for PACKAGE in alsa-utils bc bluez coreutils cron i2c-tools initramfs-tools iproute2 libraspberrypi-bin lsb-release lshw net-tools procps rpi-eeprom usbutils sed systemd util-linux v4l-utils wireless-tools
do
if [[ "${PACKAGE}" = "rpi-eeprom" ]]
then
# If the Pi is not a 4B, 400, or CM4, then skip checking for the rpi-eeprom package
if [[ "${PI4_FAMILY}" != "1" ]]
then
continue
fi
fi
# Otherwise, for all packages, on all models...
# If the package is installed...
if [[ "$(echo "${REQUIRED}" | grep "${PACKAGE}")" != "" ]]
then
(( REQ_HIT++ )) || :
else
# Otherwise, tell the user to install it.
fnBANNER "Required package \"${PACKAGE}\" is not installed." | grep -v "^$"
echo "Install with:"
echo " sudo apt install -y ${PACKAGE}"
PKG_MISSING=1
echo
fi
(( REQ_MAX++ )) || :
done
if [[ ${PKG_MISSING} -ne 0 ]]
then
fnBANNER "Once any missing packages are installed, re-run this script."
echo
exit
else
echo "${REQ_HIT} out of ${REQ_MAX} required packages are installed."
echo "All core inspections will be performed."
echo
######################################
# Now, the supplemental packages.
# If installed, great. If not installed, don't trouble the user to add
# them. Some of the supplemental package names have changed, between
# Stretch and Buster. The next few lines accomodate these different
# package names. The package containing daemon "pigpiod" is called
# "pigpiod" on Buster, but called "pigpio" on Stretch. The package
# containing "docker" is called "docker-ce-cli" on Buster, but called
# "docker.io" on Stretch.
if [[ "${VERSION_ID}" -eq 9 ]]
then
# Package names on Stretch
PIGPIO_PKG=pigpio
DOCKER_PKG=docker.io
else
# Package names on Buster
PIGPIO_PKG=pigpiod
DOCKER_PKG=docker-ce-cli
fi
# The packages conditionally named above, appear as variables here...
SUPPLEMENTAL=$(dpkg -l 2>/dev/null | awk '{ print $2 }' | grep -E -i "^apparmor$|^at$|^auditd$|^chkrootkit$|^clamav$|^cups-client$|^dc$|^${DOCKER_PKG}$|^ethtool$|^hdparm$|^lirc$|^lm-sensors$|^lvm2$|^lynis$|^m4$|^mdadm$|^nfs-kernel-server$|^nmap$|^perl-base$|^${PIGPIO_PKG}$|^python3-gpiozero$|^quota$|^rkhunter$|^rng-tools$|^rpcbind$|^rtl-sdr$|^samba$|^screen$|^smartmontools$|^snort$|^sysbench$|^sysstat$|^systemd-container$|^systemd-coredump$|^tripwire$|^ufw$|^unhide$|^watchdog$|^wiringpi$|^x11-xserver-utils$")
SUP_HIT=0
SUP_MAX=0
# They also appear as variables here...
for PACKAGE in apparmor at auditd chkrootkit clamav cups-client dc ${DOCKER_PKG} ethtool hdparm lirc lm-sensors lvm2 lynis m4 mdadm nfs-kernel-server nmap perl-base ${PIGPIO_PKG} python3-gpiozero quota rkhunter rng-tools rpcbind rtl-sdr samba screen smartmontools snort sysbench sysstat systemd-container systemd-coredump tripwire ufw unhide watchdog wiringpi x11-xserver-utils
do
# If wiringpi is installed, it needs to be v2.52 on the Pi 4B - 1/2/4GB
# models only..
# See - http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/
# This script will not support WiringPi, of any version, on a Pi 4B 8GB, 400, or CM4
# model.
if [[ "${PACKAGE}" = "wiringpi" ]]
then
WIRINGPI_VERS=$(gpio -v 2>/dev/null | head -1 | awk '{ print $NF }')
if [[ "${WIRINGPI_VERS}" = "2.52" ]]
then
# Can't use "${PI4_FAMILY}" here because we allow this on 4Bs older than the 8GB model.
if [[ "${MY_REVISION}" != "d03114" ]] && [[ "${MY_MODEL_NAME}" != "400" ]] && [[ "${MY_MODEL_NAME}" != "CM4" ]]
then
(( SUP_HIT++ ))
(( SUP_MAX++ ))
#KPC
echo "DEBUG: ${PACKAGE} is ${WIRINGPI_VERS}" >&3
continue
fi
fi
# If not a 4B, 400, or CM4 then wiringpi v2.50 from the repositories will do
if [[ "${PI4_FAMILY}" != "1" ]]