From a3471b303fb65aaa1f2de55165eaa8a2d05ca15f Mon Sep 17 00:00:00 2001 From: neox Date: Thu, 13 Jun 2024 15:40:11 +0200 Subject: [PATCH] WIP: flux de test --- boot_and_check.sh | 39 +++++++++++++++++++++++-------- includes.sh => logs.inc | 52 ++++++++++++++++------------------------- power.inc | 37 +++++++++++++++++++++++++++++ ssh.inc | 30 ++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 42 deletions(-) rename includes.sh => logs.inc (59%) create mode 100644 power.inc create mode 100644 ssh.inc diff --git a/boot_and_check.sh b/boot_and_check.sh index ff3b32f..53bf295 100755 --- a/boot_and_check.sh +++ b/boot_and_check.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +# +# KGPE-D16 firmware boot process debugging tools via BMC +# # Copyright (C) 2024 Adrien 'neox' Bourmault # # 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 . -## 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 ' + + 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! } diff --git a/includes.sh b/logs.inc similarity index 59% rename from includes.sh rename to logs.inc index 35c5058..a843d0a 100644 --- a/includes.sh +++ b/logs.inc @@ -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 # # 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 . -## 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 $@ +} \ No newline at end of file diff --git a/power.inc b/power.inc new file mode 100644 index 0000000..014e9ce --- /dev/null +++ b/power.inc @@ -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 +# +# 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 . + +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 +} \ No newline at end of file diff --git a/ssh.inc b/ssh.inc new file mode 100644 index 0000000..a6b4ab2 --- /dev/null +++ b/ssh.inc @@ -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 +# +# 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 . + +ssh_bmc() +{ + sshpass -p '0penBmc' ssh root@ppalsoc08-bmc ${@} +} + +ssh_hst() +{ + sshpass -p 'password' ssh neox@ppalsoc08 ${@} +}