From 59ca38c7a483a7ae33a2c074c62064566361903c Mon Sep 17 00:00:00 2001 From: audi Date: Thu, 23 Jun 2016 15:36:52 +0800 Subject: [PATCH] Fix onie discover stopped while console XOFF is triggered This patch print logs to files, which was printed to /dev/console directly - tee_log_file to /var/log/onie-tee.log - _log_console_msg to /var/log/onie-console.log - /etc/rcS.d/S30console-logger.sh will tail these logs to /dev/console Cause: While XOFF is trigger with console port somehow, onie discover will stop searching installer after a while. Reproduce: 1. In console terminal, type CTRL+S to send XOFF 2. telnet/ssh to DUT, and tail -f /var/log/onie.log 3. The discover loop will stop searching after a while, since linux kernel console buffer is full. --- rootconf/default/bin/discover | 2 +- rootconf/default/etc/init.d/console-logger.sh | 14 ++++++++++++++ rootconf/default/etc/rcS.d/S30console-logger.sh | 1 + rootconf/default/lib/onie/functions | 16 +++++++++------- 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100755 rootconf/default/etc/init.d/console-logger.sh create mode 120000 rootconf/default/etc/rcS.d/S30console-logger.sh diff --git a/rootconf/default/bin/discover b/rootconf/default/bin/discover index f2cb12b2f..f9f6c3036 100755 --- a/rootconf/default/bin/discover +++ b/rootconf/default/bin/discover @@ -184,7 +184,7 @@ while true ; do cat $onie_neigh_file > $onie_parms_file echo "$onie_disco" >> $onie_parms_file sed -e 's/@@/ = /g' -e 's/##/\n/g' $onie_parms_file | logger -t discover -p ${syslog_onie}.info - exec_installer $onie_parms_file 2>&1 | tee $tee_log_file | logger -t onie-exec -p ${syslog_onie}.info + exec_installer $onie_parms_file 2>&1 | tee -a $tee_log_file | logger -t onie-exec -p ${syslog_onie}.info [ -r /var/run/install.rc ] && [ "$(cat /var/run/install.rc)" = "0" ] && exit 0 # pause to avoid DoSing someone log_info_msg "Sleeping for $delay seconds " diff --git a/rootconf/default/etc/init.d/console-logger.sh b/rootconf/default/etc/init.d/console-logger.sh new file mode 100755 index 000000000..62e4e6a3a --- /dev/null +++ b/rootconf/default/etc/init.d/console-logger.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Copyright (C) 2016 Audi Hsu +# +# SPDX-License-Identifier: GPL-2.0 + +## +## redirect console_log_file and tee_log_file to /dev/console +## + +. /lib/onie/functions + +touch $console_log_file && /usr/bin/tail -f $console_log_file > /dev/console & +touch $tee_log_file && /usr/bin/tail -f $tee_log_file > /dev/console & diff --git a/rootconf/default/etc/rcS.d/S30console-logger.sh b/rootconf/default/etc/rcS.d/S30console-logger.sh new file mode 120000 index 000000000..d310a2f45 --- /dev/null +++ b/rootconf/default/etc/rcS.d/S30console-logger.sh @@ -0,0 +1 @@ +../init.d/console-logger.sh \ No newline at end of file diff --git a/rootconf/default/lib/onie/functions b/rootconf/default/lib/onie/functions index 0258edf5a..680f060a1 100644 --- a/rootconf/default/lib/onie/functions +++ b/rootconf/default/lib/onie/functions @@ -15,7 +15,9 @@ export onie_installer="/var/tmp/installer" ONIE_RUN_DIR="/var/run/onie" -tee_log_file=/dev/console +tee_log_file="/var/log/onie-tee.log" +console_log_file="/var/log/onie-console.log" + if [ "$onie_boot_reason" = "update" -o "$onie_boot_reason" = "embed" ] ; then filename_prefix="onie-updater" onie_operation="onie-update" @@ -44,33 +46,33 @@ syslog_tag="onie" _log_msg() { - printf "$@" | tee $tee_log_file | logger -t $syslog_tag -p ${syslog_onie}.info + printf "$@" | tee -a $tee_log_file | logger -t $syslog_tag -p ${syslog_onie}.info } _log_console_msg() { - printf "$@" | tee /dev/console | logger -t $syslog_tag -p ${syslog_onie}.info + printf "$@" | tee -a $console_log_file | logger -t $syslog_tag -p ${syslog_onie}.info } _log_info_msg() { - printf "$@" | tee $tee_log_file | logger -t $syslog_tag -p ${syslog_onie}.info + printf "$@" | tee -a $tee_log_file | logger -t $syslog_tag -p ${syslog_onie}.info } _log_warn_msg() { - printf "$@" | tee $tee_log_file | logger -t ${syslog_tag}-warn -p ${syslog_onie}.warn + printf "$@" | tee -a $tee_log_file | logger -t ${syslog_tag}-warn -p ${syslog_onie}.warn } _log_err_msg() { - printf "$@" | tee $tee_log_file | logger -t ${syslog_tag}-error -p ${syslog_onie}.err + printf "$@" | tee -a $tee_log_file | logger -t ${syslog_tag}-error -p ${syslog_onie}.err } log_debug_msg() { if [ "$onie_verbose" = "y" ]; then - printf "$@" | tee $tee_log_file | logger -t ${syslog_tag}-debug -p ${syslog_onie}.debug + printf "$@" | tee -a $tee_log_file | logger -t ${syslog_tag}-debug -p ${syslog_onie}.debug fi }