Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onie discover stopped while console XOFF is triggered #386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rootconf/default/bin/discover
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
14 changes: 14 additions & 0 deletions rootconf/default/etc/init.d/console-logger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Copyright (C) 2016 Audi Hsu <[email protected]>
#
# 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 &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking for this whole patch, it seems we can simplify it a little bit.

Do we really need both $console_log_file and $tee_log_file?

It seems we only need $tee_log_file.

Copy link
Contributor Author

@audihsu-qci audihsu-qci Jun 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are _log_console_msg and other different log message levels, I shall keep the console_log_file and tee_log_file.
Unless the logging message definition is changed.

touch $tee_log_file && /usr/bin/tail -f $tee_log_file > /dev/console &
1 change: 1 addition & 0 deletions rootconf/default/etc/rcS.d/S30console-logger.sh
16 changes: 9 additions & 7 deletions rootconf/default/lib/onie/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we could just use $tee_log_file here. Then we do not need $console_log_file.

Thinking a bit about names.

The name tee_log_file, which I wrote initially, is not a very good name. It does not tell the programmer what the file is really for. If we do consolidate on one log file, I think $console_log_file is a better name. I would search and replace $tee_log_file with $console_log_file. That name more clearly indicates what the file is for.

}

_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
}

Expand Down