2

I'm installing Scientific Linux 7 (I've got no reason to this isn't the case with all RHEL forks though) with a Kickstart script that contains the following:

%post --interpreter /bin/bash --log /root/postinstall.log
# do stuff
%end

After install, the log file is there for inspection as expected.

But, using SL 6 I used to be able to change to TTY 2 and watch the log with tail -f /mnt/sysimage/root/postinstall.log. Now, it appears the log is created, but contents are not written until the post-install process is completed.

Is there a way to monitor this progress? I've looked for the log file in /tmp/, /var/log/, /mnt/sysimage/tmp/, and /mnt/sysimage/var/log/ without any luck. If the log file isn't available, is there a way to send output to another TTY from a Kickstart post-install script?

Attempt 1:

%post --interpreter /bin/bash
(
# do stuff
echo foo
echo bar
echo baz
) | tee /root/postinstall.log > /dev/tty1
%end

This almost works, however, line endings seem to be a problem. It's only doing an LF, not a CR on the screen. The above outputs this on TTY1:

foo
    bar
        baz

Attempt 2:

%post --interpreter /bin/bash --log /root/postinstall.log

echo "Changing output to TTY 3; press Alt-F3 to view" > /dev/tty1
exec 1>/dev/tty3 2>&1
#do stuff
%end

This outputs the data correctly to the screen, but logs nothing. It also has the curious side-effect of delaying the reboot for like 10 minutes after the script completes.

1

Redirect your output to /dev/pts/0 instead.

  • Yes, /dev/pts/0 seems to handle line endings much better than /dev/tty1. – miken32 Jun 5 at 22:34
0

Finally figured this out:

%post --interpreter /bin/bash

printf "Changing output to TTY 3; press Alt-F3 to view\r\n" > /dev/tty1
{
# do stuff
} 2>&1 | tee /root/postinstall.log > /dev/tty3

%end

As mentioned in the question, the screen on /dev/tty1 seems to have problems with line endings, so my first attempt probably would have worked had I redirected to /dev/tty3 instead. But this solution avoids the subshell and also redirects STDERR.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.