From 624984b1c9464ce87c2a645f6b50bdf83f832316 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 9 Dec 2021 10:34:12 -0500 Subject: [PATCH] Do not assume SPCR until confluent confirms text console TIOCCONS was called for users that did not want to use serial. This makes the serial console delayeed when automatic, but avoids video users from being confused. --- .../usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh | 1 + .../genesis/initramfs/opt/confluent/bin/rungenesis | 1 + .../lib/dracut/hooks/cmdline/10-confluentdiskless.sh | 1 + .../suse15/initramfs/opt/confluent/bin/suseagent | 1 + .../initramfs/scripts/init-premount/confluent | 1 + confluent_osdeploy/utils/autocons.c | 4 +++- 6 files changed, 8 insertions(+), 1 deletion(-) diff --git a/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh b/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh index 1b64ff6c..2903fdb5 100644 --- a/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh +++ b/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh @@ -134,6 +134,7 @@ while [ $ready = "0" ]; do fi rm $tmperr done +if [ ! -z "$autocons" ] && grep textconsole: true /etc/confluent/confluent.deploycfg > /dev/null; then /opt/confluent/bin/autocons -c > /dev/null; fi if [ -c /dev/tpmrm0 ]; then tpm2_pcrextend 15:sha256=2fbe96c50dde38ce9cd2764ddb79c216cfbcd3499568b1125450e60c45dd19f2 fi diff --git a/confluent_osdeploy/genesis/initramfs/opt/confluent/bin/rungenesis b/confluent_osdeploy/genesis/initramfs/opt/confluent/bin/rungenesis index 36607b86..ee6573dc 100644 --- a/confluent_osdeploy/genesis/initramfs/opt/confluent/bin/rungenesis +++ b/confluent_osdeploy/genesis/initramfs/opt/confluent/bin/rungenesis @@ -77,6 +77,7 @@ done cd - > /dev/null rm -rf $tpmdir /usr/libexec/platform-python /opt/confluent/bin/apiclient /confluent-api/self/deploycfg2 > /etc/confluent/confluent.deploycfg +if [ ! -z "$autocons" ] && grep textconsole: true /etc/confluent/confluent.deploycfg > /dev/null; then /opt/confluent/bin/autocons -c > /dev/null; fi umask $oldumask new_apikey=$(cat /etc/confluent/confluent.apikey) if [ "$new_apikey" != "$confluent_apikey" ]; then diff --git a/confluent_osdeploy/suse15-diskless/initramfs/lib/dracut/hooks/cmdline/10-confluentdiskless.sh b/confluent_osdeploy/suse15-diskless/initramfs/lib/dracut/hooks/cmdline/10-confluentdiskless.sh index 6fcb44c3..0a801188 100644 --- a/confluent_osdeploy/suse15-diskless/initramfs/lib/dracut/hooks/cmdline/10-confluentdiskless.sh +++ b/confluent_osdeploy/suse15-diskless/initramfs/lib/dracut/hooks/cmdline/10-confluentdiskless.sh @@ -133,6 +133,7 @@ while [ $ready = "0" ]; do fi rm $tmperr done +if [ ! -z "$autocons" ] && grep textconsole: true /etc/confluent/confluent.deploycfg > /dev/null; then /opt/confluent/bin/autocons -c > /dev/null; fi tpm2_pcrextend 15:sha256=2fbe96c50dde38ce9cd2764ddb79c216cfbcd3499568b1125450e60c45dd19f2 umask $oldumask autoconfigmethod=$(grep ipv4_method /etc/confluent/confluent.deploycfg |awk '{print $2}') diff --git a/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent b/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent index f7aac35c..5bf663c8 100755 --- a/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent +++ b/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent @@ -52,6 +52,7 @@ if [ -z "$mgtiface" ]; then else curl -H "CONFLUENT_MGTIFACE: $mgtiface" -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $(cat /etc/confluent/confluent.apikey)" https://$mgr/confluent-api/self/deploycfg > /etc/confluent/confluent.deploycfg fi +if [ ! -z "$autocons" ] && grep textconsole: true /etc/confluent/confluent.deploycfg > /dev/null; then /opt/confluent/bin/autocons -c > /dev/null; fi profilename=$(grep ^profile: /etc/confluent/confluent.deploycfg) profilename=${profilename#profile: } curl https://$mgr/confluent-public/os/$profilename/profile.yaml > /tmp/profile.yaml diff --git a/confluent_osdeploy/ubuntu20.04-diskless/initramfs/scripts/init-premount/confluent b/confluent_osdeploy/ubuntu20.04-diskless/initramfs/scripts/init-premount/confluent index 401f558a..583ffd9e 100644 --- a/confluent_osdeploy/ubuntu20.04-diskless/initramfs/scripts/init-premount/confluent +++ b/confluent_osdeploy/ubuntu20.04-diskless/initramfs/scripts/init-premount/confluent @@ -96,6 +96,7 @@ if echo $confluent_mgr | grep '%' > /dev/null; then ifname=${ifname%:} fi curl --cacert /etc/confluent/ca.pem -sSf -H "CONFLUENT_NODENAME: $confluent_nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://${confluent_http_mgr}/confluent-api/self/deploycfg2 > /etc/confluent/confluent.deploycfg +if [ ! -z "$autocons" ] && grep textconsole: true /etc/confluent/confluent.deploycfg > /dev/null; then /opt/confluent/bin/autocons -c > /dev/null; fi v6meth=$(grep ^ipv6_method: /etc/confluent/confluent.deploycfg|awk '{print $2}') if [ "$v6meth" = static ]; then v6addr=$(grep ^ipv6_address: /etc/confluent/confluent.deploycfg | awk '{print $2}') diff --git a/confluent_osdeploy/utils/autocons.c b/confluent_osdeploy/utils/autocons.c index 05cd4407..54c6ca73 100644 --- a/confluent_osdeploy/utils/autocons.c +++ b/confluent_osdeploy/utils/autocons.c @@ -124,6 +124,8 @@ int main(int argc, char* argv[]) { if (ws.ws_row < 24) { ws.ws_col = 24; } ioctl(ttyf, TIOCSWINSZ, &ws); tcsetattr(ttyf, TCSANOW, &tty); - ioctl(ttyf, TIOCCONS, 0); + if (argc > 1 && (strcmp(argv[1], '-c') == 0)) { + ioctl(ttyf, TIOCCONS, 0); + } }