From 4df3fda8eabc1f3aa744b7564891651c168b7dea Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 30 Apr 2021 09:39:00 -0400 Subject: [PATCH] Change logging/display for RH oses The pre and post phases are desirable to see both in logs and consoles. Unfortunately, anaconda cheaps out by using communicate(), which means the logs are unwritten until the end. Change by using bash's redirectiors to create a dynamically updated logfile and tail -f that. --- .../el7/profiles/default/scripts/post.sh | 4 +++- .../el7/profiles/default/scripts/pre.sh | 12 ++++++------ .../el7/profiles/default/scripts/prechroot.sh | 4 ++-- .../el8/profiles/default/scripts/post.sh | 4 +++- .../el8/profiles/default/scripts/pre.sh | 13 +++++++------ .../el8/profiles/default/scripts/prechroot.sh | 4 ++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/confluent_osdeploy/el7/profiles/default/scripts/post.sh b/confluent_osdeploy/el7/profiles/default/scripts/post.sh index 10448f13..6afcd90f 100644 --- a/confluent_osdeploy/el7/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/el7/profiles/default/scripts/post.sh @@ -1,5 +1,7 @@ #!/bin/sh -tail -f /tmp/nochroot/${0}.log >& /dev/tty & +mkdir -p /var/log/confluent +exec >> /var/log/confluent/confluent-post.log +tail -f /var/log/confluent/confluent-post.log > /dev/tty & # need to copy over ssh key info nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}') apikey=$(cat /etc/confluent/confluent.apikey) diff --git a/confluent_osdeploy/el7/profiles/default/scripts/pre.sh b/confluent_osdeploy/el7/profiles/default/scripts/pre.sh index 1073359b..386c524a 100644 --- a/confluent_osdeploy/el7/profiles/default/scripts/pre.sh +++ b/confluent_osdeploy/el7/profiles/default/scripts/pre.sh @@ -1,5 +1,4 @@ #!/bin/sh -tail -f ${0}.log >& /dev/tty & # This runs prior to the installer beginning. This is used to rewrite the # scripted install file, merging data from confluent and identifying @@ -8,7 +7,12 @@ tail -f ${0}.log >& /dev/tty & # If you want to use a more custom partition plan, the easiest # method is to edit the kicktstart file and comment out or # delete %include /tmp/partitioning - +if [ -f "/run/install/cmdline.d/01-autocons.conf" ]; then + consoledev=$(cat /run/install/cmdline.d/01-autocons.conf | sed -e 's!console=!/dev/!' -e 's/,.*//') + TMUX= tmux a <> $consoledev >&0 2>&1 & +fi +exec >> /tmp/confluent-pre.log +tail -f /tmp/confluent-pre.log > /dev/tty & nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}') locale=$(grep ^locale: /etc/confluent/confluent.deploycfg) locale=${locale#locale: } @@ -50,10 +54,6 @@ for pubkey in /etc/ssh/ssh_host*key.pub; do echo HostCertificate $certfile >> /etc/ssh/sshd_config.anaconda done /usr/sbin/sshd -f /etc/ssh/sshd_config.anaconda -if [ -f "/run/install/cmdline.d/01-autocons.conf" ]; then - consoledev=$(cat /run/install/cmdline.d/01-autocons.conf | sed -e 's!console=!/dev/!' -e 's/,.*//') - TMUX= tmux a <> $consoledev >&0 2>&1 & -fi cryptboot=$(grep ^encryptboot: /etc/confluent/confluent.deploycfg | awk '{print $2}') LUKSPARTY='' touch /tmp/addonpackages diff --git a/confluent_osdeploy/el7/profiles/default/scripts/prechroot.sh b/confluent_osdeploy/el7/profiles/default/scripts/prechroot.sh index b3082e46..48fa65f7 100644 --- a/confluent_osdeploy/el7/profiles/default/scripts/prechroot.sh +++ b/confluent_osdeploy/el7/profiles/default/scripts/prechroot.sh @@ -16,8 +16,8 @@ cp /tmp/functions /mnt/sysimage/etc/confluent/ if [ -f /tmp/cryptboot ]; then cp /tmp/cryptboot /mnt/sysimage/tmp/ fi -mkdir -p /mnt/sysimage/tmp/nochroot/tmp -mount -o bind,ro /tmp/ /mnt/sysimage/tmp/nochroot/tmp +mkdir -p /mnt/sysimage/var/log/confluent +mv /tmp/confluent-pre.log /mnt/sysimage/var/log/confluent echo Port 2222 >> /etc/ssh/sshd_config.anaconda echo Match LocalPort 22 >> /etc/ssh/sshd_config.anaconda echo " ChrootDirectory /mnt/sysimage" >> /etc/ssh/sshd_config.anaconda diff --git a/confluent_osdeploy/el8/profiles/default/scripts/post.sh b/confluent_osdeploy/el8/profiles/default/scripts/post.sh index 10448f13..6afcd90f 100644 --- a/confluent_osdeploy/el8/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/el8/profiles/default/scripts/post.sh @@ -1,5 +1,7 @@ #!/bin/sh -tail -f /tmp/nochroot/${0}.log >& /dev/tty & +mkdir -p /var/log/confluent +exec >> /var/log/confluent/confluent-post.log +tail -f /var/log/confluent/confluent-post.log > /dev/tty & # need to copy over ssh key info nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}') apikey=$(cat /etc/confluent/confluent.apikey) diff --git a/confluent_osdeploy/el8/profiles/default/scripts/pre.sh b/confluent_osdeploy/el8/profiles/default/scripts/pre.sh index 19cf330c..23bc238f 100644 --- a/confluent_osdeploy/el8/profiles/default/scripts/pre.sh +++ b/confluent_osdeploy/el8/profiles/default/scripts/pre.sh @@ -7,8 +7,12 @@ # If you want to use a more custom partition plan, the easiest # method is to edit the kicktstart file and comment out or # delete %include /tmp/partitioning - -tail -f ${0}.log >& /dev/tty & +if [ -f "/run/install/cmdline.d/01-autocons.conf" ]; then + consoledev=$(cat /run/install/cmdline.d/01-autocons.conf | sed -e 's!console=!/dev/!' -e 's/,.*//') + tmux a <> $consoledev >&0 2>&1 & +fi +exec >> /tmp/confluent-pre.log +tail -f /tmp/confluent-pre.log > /dev/tty & /usr/libexec/platform-python /etc/confluent/apiclient >& /dev/null nicname=$(ip link|grep ^$(cat /tmp/confluent.ifidx): | awk '{print $2}' | awk -F: '{print $1}') nmcli c u $nicname @@ -57,10 +61,7 @@ done grep -v RSAAuthentication /etc/ssh/sshd_config.anaconda > /etc/ssh/sshd_config.anaconda.new mv /etc/ssh/sshd_config.anaconda.new /etc/ssh/sshd_config.anaconda /usr/sbin/sshd -f /etc/ssh/sshd_config.anaconda -if [ -f "/run/install/cmdline.d/01-autocons.conf" ]; then - consoledev=$(cat /run/install/cmdline.d/01-autocons.conf | sed -e 's!console=!/dev/!' -e 's/,.*//') - tmux a <> $consoledev >&0 2>&1 & -fi + cryptboot=$(grep ^encryptboot: /etc/confluent/confluent.deploycfg | awk '{print $2}') LUKSPARTY='' touch /tmp/cryptpkglist diff --git a/confluent_osdeploy/el8/profiles/default/scripts/prechroot.sh b/confluent_osdeploy/el8/profiles/default/scripts/prechroot.sh index b3082e46..48fa65f7 100644 --- a/confluent_osdeploy/el8/profiles/default/scripts/prechroot.sh +++ b/confluent_osdeploy/el8/profiles/default/scripts/prechroot.sh @@ -16,8 +16,8 @@ cp /tmp/functions /mnt/sysimage/etc/confluent/ if [ -f /tmp/cryptboot ]; then cp /tmp/cryptboot /mnt/sysimage/tmp/ fi -mkdir -p /mnt/sysimage/tmp/nochroot/tmp -mount -o bind,ro /tmp/ /mnt/sysimage/tmp/nochroot/tmp +mkdir -p /mnt/sysimage/var/log/confluent +mv /tmp/confluent-pre.log /mnt/sysimage/var/log/confluent echo Port 2222 >> /etc/ssh/sshd_config.anaconda echo Match LocalPort 22 >> /etc/ssh/sshd_config.anaconda echo " ChrootDirectory /mnt/sysimage" >> /etc/ssh/sshd_config.anaconda