3

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.

4 Answers 4

1

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

2
  • Yes, /dev/pts/0 seems to handle line endings much better than /dev/tty1.
    – miken32
    Commented Jun 5, 2019 at 22:34
  • /dev/pts/0 doesn't work on EL8 or EL9 . . This special file is only available outside of the chroot.
    – greg
    Commented Sep 29, 2022 at 13:25
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.

0
exec < /dev/tty6 > /dev/tty6
chvt 6
<scripts here>
chvt 1

This worked for me, I can monitor the %post without having to flip ttys

0

The problem is with carriage return if you use

echo "message" >/dev/tty1

Try instead

echo -e "message\r" >/dev/tty1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .