From 06ab1390fa1e390cfaf65f4bafac2d0e923f2c91 Mon Sep 17 00:00:00 2001 From: Maksim Malchuk Date: Mon, 23 May 2016 15:49:11 +0300 Subject: [PATCH] Run console on the serial port if required This commit adds the ability to use IPMI SOL console when the nodes provisioned with an option 'console=ttySx' or 'console=ttySx,speed', where x is 0 for the COM1 and 1 for COM2. If speed parameter doesn't provided so 9600 used as default. This feature can be used for the bootstrap nodes too. DocImpact Closes-Bug: #1544820 Change-Id: I210001c5692281add2439843f4ad69d65c8f6e17 Signed-off-by: Maksim Malchuk --- cloud-init-templates/boothook_ubuntu.jinja2 | 24 +++++++++++++++++++ .../files/trusty/etc/init/ttyS0.conf | 18 ++++++++++++++ .../files/trusty/etc/init/ttyS1.conf | 18 ++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 contrib/fuel_bootstrap/files/trusty/etc/init/ttyS0.conf create mode 100644 contrib/fuel_bootstrap/files/trusty/etc/init/ttyS1.conf diff --git a/cloud-init-templates/boothook_ubuntu.jinja2 b/cloud-init-templates/boothook_ubuntu.jinja2 index b526f28..182f1f6 100644 --- a/cloud-init-templates/boothook_ubuntu.jinja2 +++ b/cloud-init-templates/boothook_ubuntu.jinja2 @@ -97,3 +97,27 @@ cloud-init-per instance skel_bash cp -f /etc/skel/.bash* /root/ cloud-init-per instance hiera_puppet mkdir -p /etc/puppet /var/lib/hiera cloud-init-per instance touch_puppet touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml /var/log/puppet.log cloud-init-per instance chmod_puppet chmod 600 /var/log/puppet.log + +cloud-init-per instance upstart_console /bin/sh -c 'for i in $(seq 0 1); do +cat >/etc/init/ttyS${i}.conf <<-EOF +# ttyS${i} - getty + +start on stopped rc RUNLEVEL=[12345] +stop on runlevel [!12345] + +respawn + +pre-start script + # exit if console not present on ttyS${i} + cat /proc/cmdline | grep -q "console=ttyS${i}" +end script + +script + # get console speed if provded with "console=ttySx,38400" + SPEED=\$(cat /proc/cmdline | sed -e"s/^.*console=ttyS${i}[,]*\([^ ]*\)[ ]*.*\$/\1/g") + # or use 9600 console speed as default + exec /sbin/getty -L \${SPEED:-9600} ttyS${i} +end script +EOF +done +' diff --git a/contrib/fuel_bootstrap/files/trusty/etc/init/ttyS0.conf b/contrib/fuel_bootstrap/files/trusty/etc/init/ttyS0.conf new file mode 100644 index 0000000..718db01 --- /dev/null +++ b/contrib/fuel_bootstrap/files/trusty/etc/init/ttyS0.conf @@ -0,0 +1,18 @@ +# ttyS0 - getty + +start on stopped rc RUNLEVEL=[12345] +stop on runlevel [!12345] + +respawn + +pre-start script + # exit if console not present on ttyS0 + cat /proc/cmdline | grep -q "console=ttyS0" +end script + +script + # get console speed if provded with "console=ttySx,38400" + SPEED=$(cat /proc/cmdline | sed -e"s/^.*console=ttyS0[,]*\([^ ]*\)[ ]*.*$/\1/g") + # or use 9600 console speed as default + exec /sbin/getty -L ${SPEED:-9600} ttyS0 +end script diff --git a/contrib/fuel_bootstrap/files/trusty/etc/init/ttyS1.conf b/contrib/fuel_bootstrap/files/trusty/etc/init/ttyS1.conf new file mode 100644 index 0000000..5d954a4 --- /dev/null +++ b/contrib/fuel_bootstrap/files/trusty/etc/init/ttyS1.conf @@ -0,0 +1,18 @@ +# ttyS1 - getty + +start on stopped rc RUNLEVEL=[12345] +stop on runlevel [!12345] + +respawn + +pre-start script + # exit if console not present on ttyS1 + cat /proc/cmdline | grep -q "console=ttyS1" +end script + +script + # get console speed if provded with "console=ttySx,38400" + SPEED=$(cat /proc/cmdline | sed -e"s/^.*console=ttyS1[,]*\([^ ]*\)[ ]*.*$/\1/g") + # or use 9600 console speed as default + exec /sbin/getty -L ${SPEED:-9600} ttyS1 +end script