WIP: flux de test

This commit is contained in:
Adrien Bourmault 2024-06-13 15:40:11 +02:00
parent a9a9516856
commit a3471b303f
Signed by: neox
GPG Key ID: 95F65F55F682A17A
4 changed files with 116 additions and 42 deletions

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash
#
# KGPE-D16 firmware boot process debugging tools via BMC
#
# Copyright (C) 2024 Adrien 'neox' Bourmault <neox@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
@ -14,24 +17,40 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Some variables
set -e
source power.inc
source logs.inc
buffer=mktemp
greyblue='\033[38;5;245m'
color_reset='\033[0m'
. includes.sh
## Main program ---------------------------------------------------------------
main()
{
stop_logs
exit 0
echo -e ${color_reset}
echo 'Welcome to the KGPE-D16 debugging tools'
echo 'Copyright (C) 2024 Adrien "neox" Bourmault <neox@gnu.org>'
stop_logs
echo Starting logs...
start_logs buffer
echo Booting up...
boot
wait_for_expression "Debian GNU/Linux 9"
wait_for buffer "Debian GNU/Linux 9"
echo System successfully booted!
wait_for_expression "link becomes ready"
wait_for_expression "ttyS1"
echo SSH should be ready
wait_for buffer "link becomes ready"
echo Network ready
wait_for buffer "tty"
echo Login should be ready
echo Shutting down
shutdown
echo Successful power cycle!
}

View File

@ -1,4 +1,9 @@
#!/usr/bin/env bash
#
# KGPE-D16 firmware boot process debugging tools via BMC
#
# Desc: log management
#
# Copyright (C) 2024 Adrien 'neox' Bourmault <neox@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
@ -14,34 +19,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## SSH Management -------------------------------------------------------------
ssh_bmc()
{
sshpass -p '0penBmc' ssh root@ppalsoc08-bmc ${@}
}
source ssh.inc
ssh_hst()
{
sshpass -p 'password' ssh neox@ppalsoc08 ${@}
}
# colors
greyblue='\033[38;5;245m'
color_reset='\033[0m'
## Power Management -----------------------------------------------------------
boot()
{
ssh_bmc /usr/local/bin/asus_power.sh on
}
force_shutdown()
{
ssh_bmc /usr/local/bin/asus_power.sh off
}
shutdown()
{
ssh_hst sudo shutdown now
}
## Logs Management ------------------------------------------------------------
get_logs()
{
ssh_bmc /usr/bin/microcom /dev/ttyS0 -s 115200
@ -52,21 +35,26 @@ stop_logs()
ssh_bmc killall microcom
}
start_logs()
{
get_logs > ${1} &
}
find_in_logs()
{
keyword=$@
while read line
do
echo -e "${greyblue}${line}${color_reset}" >&2
echo "$line" | grep "$keyword" &> /dev/null
if [ $? -eq 0 ]; then
echo "Found keyword : $line"
stop_logs
echo "${greyblue}Found : ${line}${color_reset}"
break
fi
done
}
wait_for_expression()
wait_for()
{
get_logs | find_in_logs $@
tail -f ${1} | find_in_logs $@
}

37
power.inc Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
#
# KGPE-D16 firmware boot process debugging tools via BMC
#
# Desc: power management
#
# 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/>.
source ssh.inc
boot()
{
ssh_bmc /usr/local/bin/asus_power.sh on
}
halt()
{
ssh_bmc /usr/local/bin/asus_power.sh off
}
shutdown()
{
ssh_hst sudo shutdown now
}

30
ssh.inc Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# KGPE-D16 firmware boot process debugging tools via BMC
#
# Desc: log management
#
# 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/>.
ssh_bmc()
{
sshpass -p '0penBmc' ssh root@ppalsoc08-bmc ${@}
}
ssh_hst()
{
sshpass -p 'password' ssh neox@ppalsoc08 ${@}
}