bmc-debug-tools/logs.inc

60 lines
1.2 KiB
PHP
Raw Normal View History

2024-06-13 12:31:56 +02:00
#!/usr/bin/env bash
2024-06-13 15:40:11 +02:00
#
# KGPE-D16 firmware boot process debugging tools via BMC
#
# Desc: log management
#
2024-06-13 12:31:56 +02:00
# Copyright (C) 2024 Adrien 'neox' Bourmault <neox@gnu.org>
#
# 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 <https://www.gnu.org/licenses/>.
2024-06-13 15:40:11 +02:00
source ssh.inc
2024-06-13 12:31:56 +02:00
2024-06-13 15:40:11 +02:00
# colors
greyblue='\033[38;5;245m'
color_reset='\033[0m'
2024-06-13 12:31:56 +02:00
get_logs()
{
ssh_bmc /usr/bin/microcom /dev/ttyS0 -s 115200
}
stop_logs()
{
ssh_bmc killall microcom
}
2024-06-13 15:40:11 +02:00
start_logs()
{
get_logs > ${1} &
}
2024-06-13 12:31:56 +02:00
find_in_logs()
{
2024-06-13 15:40:11 +02:00
2024-06-13 12:31:56 +02:00
keyword=$@
while read line
do
echo "$line" | grep "$keyword" &> /dev/null
if [ $? -eq 0 ]; then
2024-06-13 15:40:11 +02:00
echo "${greyblue}Found : ${line}${color_reset}"
break
2024-06-13 12:31:56 +02:00
fi
done
}
2024-06-13 15:40:11 +02:00
wait_for()
2024-06-13 12:31:56 +02:00
{
2024-06-13 15:40:11 +02:00
tail -f ${1} | find_in_logs $@
}