Skip to content

Commit

Permalink
Merge pull request #218 from jouvin/pre_post_formatting
Browse files Browse the repository at this point in the history
aii-ks: fix logging of pre and post script actions for EL7
  • Loading branch information
jrha authored Nov 10, 2016
2 parents 80c9d78 + 6f316e3 commit 70dae2a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion aii-ks/src/main/perl/ks.pm
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,14 @@ sub log_action {
}

if ($consolelogging) {
# In EL7, /dev/console doesn't add the carriage return for each line feed (new line)
# resulting in unreadable messages on the console. /dev/pts/0 must be used instead.
# But on prior versions, /dev/pts/0 doesn't exist at installation time and cannot be used.
# The following code allows to use /dev/pts/0 if it exists else to revert to /dev/console.
push(@logactions, "console='/dev/console'");
push(@logactions, "[ -c /dev/pts/0 ] && console='/dev/pts/0'");
push(@logactions, '# Make sure messages show up on the serial console',
"tail -f $logfile > /dev/console &");
"tail -f $logfile > \$console &");
}

push(@logactions,"drainsleep=$drainsleep"); # add trailing newline
Expand Down
2 changes: 1 addition & 1 deletion aii-ks/src/test/perl/kickstart_logging.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ like($fh, qr{^%packages\s--ignoremissing\s--resolvedeps\n^package\n^package2\n^b
# logaction tests
my $logaction = NCM::Component::ks::log_action($cfg, 'mylogfile', 1);
like($logaction, qr{^exec\s>mylogfile\s2>&1}, 'start with exec redirection'); # no multiline search!
like($logaction, qr{^tail\s-f\smylogfile\s>\s/dev/console\s&}m, 'console logging enabled');
like($logaction, qr{^tail\s-f\smylogfile\s>\s\$console\s&}m, 'logfile displayed on console');

like($logaction, qr{^wait_for_network\slogserver}m, 'Insert sleep to make sure network is up');
like($logaction, qr{^\(tail\s-f\smylogfile.*?usleep.*?\snc\s-u\slogserver\s514\)\s&$}m, 'netcat udp logsending');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ my $logaction = NCM::Component::ks::log_action($cfg, 'mylogfile', 1);
like($logaction, qr{^exec\s>mylogfile\s2>&1}, 'start with exec redirection'); # no multiline search!

# hmm, first test might be too specific in case of subtle changes
unlike($logaction, qr{^tail\s-f\smylogfile\s>\s/dev/console\s&}m, 'no console logging enabled');
unlike($logaction, qr{/dev/console}, 'no /dev/console at all');
unlike($logaction, qr{^tail\s-f\smylogfile\s>\s\$console\s&}m, 'no console logging enabled');
unlike($logaction, qr{\$console}, 'console not defined');

unlike($logaction, qr{^\(tail\s-f\smylogfile.*?usleep.*\)\s&$}m, 'no logsending');
unlike($logaction, qr{usleep}, 'no usleep at all');
Expand Down
4 changes: 3 additions & 1 deletion aii-ks/src/test/resources/regexps/pre_noblock_logging
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ Test the logging in the pre section
---
---
^exec >/tmp/pre-log.log 2>&1$
^console='/dev/console'$
^\[ -c /dev/pts/0 \] && console='/dev/pts/0'$
^\# Make sure messages show up on the serial console$
^tail -f /tmp/pre-log.log > /dev/console &$
^tail -f /tmp/pre-log.log > \$console &$
^drainsleep=0$
^$
^echo 'Begin of pre section'$
Expand Down

0 comments on commit 70dae2a

Please sign in to comment.