Skip to content

Commit a5b0fec

Browse files
pfeerickayufan
authored andcommitted
Updates to diagnostic script (#37)
Added get_flash_information(), exclude /var/lib/smartmontools as is routinled updated by 3rd parties, made check for pine64 and rock64 support packages, checks for iostat before using it and change log file path based on permissions. Import of folliwing commits from pfeerick/pine64-scripts: b7f82afbe0a8838c8910785ff37b9c01144054ad cceb8ab35c26cb7ff8eb5b684c10d13f3cf4fa63 65ceaf5209e838bcc74b0db86199699c657f5311 14ae540f47a6baa5e4a241a8d6752f0e3adfa865 951d920961f34d2daf680d9242219fc575569749
1 parent 3b70461 commit a5b0fec

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

package/root/usr/local/sbin/pine64_diagnostics.sh

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
# Written 2017 Peter Feerick and contributors, released under GPLv3
77
#
88

9-
Log="/var/log/${0##*/}.log"
10-
VerifyRepairExcludes="/etc/|/boot/|cache|getty"
9+
#if user doesn't have permission for /var/log, write to /tmp
10+
if [ -w /var/log ]; then
11+
Log="/var/log/${0##*/}.log"
12+
else
13+
Log="/tmp/${0##*/}.log"
14+
fi
15+
16+
VerifyRepairExcludes="/etc/|/boot/|cache|getty|/var/lib/smartmontools/"
1117

1218
Main() {
1319
# check if stdout is a terminal...
@@ -127,13 +133,26 @@ GenerateLog() {
127133

128134
echo -e "\n### Loaded modules:\n\n$(lsmod)"
129135

130-
echo -e "\n### package version:\n"
131-
apt-cache policy linux-pine64-package
136+
if [[ $(dpkg-query -W -f='${Status}' linux-pine64-package 2>/dev/null | grep -c "ok installed") == "1" ]]; then
137+
echo -e "\n### linux-pine64-package version:\n"
138+
apt-cache policy linux-pine64-package
139+
fi
140+
141+
if [[ $(dpkg-query -W -f='${Status}' linux-rock64-package 2>/dev/null | grep -c "ok installed") == "1" ]]; then
142+
echo -e "\n### linux-rock64-package version:\n"
143+
apt-cache policy linux-rock64-package
144+
fi
132145

133146
echo -e "\n### Kernel version:\n"
134147
uname -a
135148

136-
echo -e "\n### Current sysinfo:\n\n$(iostat -p ALL | grep -v "^loop")\n\n$(vmstat -w)\n\n$(free -h)\n\n$(dmesg | tail -n 250)"
149+
echo -e "Searching for info on flash media... "
150+
get_flash_information >>${Log}
151+
which iostat >/dev/null 2>&1 && \
152+
153+
echo -e "\n### Current sysinfo:\n\n"
154+
which iostat >/dev/null 2>&1 && echo -e "$(iostat -p ALL | grep -v '^loop')\n\n"
155+
echo -e "$(vmstat -w)\n\n$(free -h)\n\n$(dmesg | tail -n 250)"
137156
} # GenerateLog
138157

139158
CheckCard() {
@@ -267,6 +286,19 @@ GetDevice() {
267286
fi
268287
} # GetDevice
269288

289+
get_flash_information() {
290+
# http://www.bunniestudios.com/blog/?page_id=1022
291+
find /sys -name oemid | while read Device ; do
292+
DeviceNode="${Device%/*}"
293+
DeviceName="${DeviceNode##*/}"
294+
echo -e "\n### ${DeviceName} info:\n"
295+
find "${DeviceNode}" -maxdepth 1 -type f | while read ; do
296+
NodeName="${REPLY##*/}"
297+
echo -e "$(printf "%20s" ${NodeName}): $(cat "${DeviceNode}/${NodeName}" | tr '\n' " ")"
298+
done
299+
done
300+
} # get_flash_information
301+
270302
UploadSupportLogs() {
271303
#prevent colour escape sequences in log
272304
BOLD=''
@@ -287,7 +319,7 @@ UploadSupportLogs() {
287319
echo -e "Generating diagnostic logs... "
288320
GenerateLog > ${Log}
289321
echo -e "Running file integrity checks... "
290-
VerifyFiles >> ${Log}
322+
VerifyFiles >> ${Log}
291323

292324
#check network connection
293325
fping sprunge.us | grep -q alive || \

0 commit comments

Comments
 (0)