diff --git a/elements/serial-console/README.md b/elements/serial-console/README.md index 73ce59c9..f753b160 100644 --- a/elements/serial-console/README.md +++ b/elements/serial-console/README.md @@ -1,4 +1,4 @@ -Start getty on ttyS0 and/or ttyS1 +Start getty on active serial consoles. With ILO and other remote admin environments, having a serial console can be useful for debugging and troubleshooting. @@ -7,4 +7,4 @@ For upstart: If ttyS1 exists, getty will run on that, otherwise on ttyS0. For systemd: - Try to start getty on both ttyS0 and ttyS1. + We dynamically start a getty on any active serial port via udev rules. diff --git a/elements/serial-console/install.d/20-stty b/elements/serial-console/install.d/20-stty index fe1e0b12..57e6312e 100755 --- a/elements/serial-console/install.d/20-stty +++ b/elements/serial-console/install.d/20-stty @@ -1,12 +1,10 @@ #!/bin/bash - -home=$(dirname $0) set -uex +SCRIPTDIR=$(dirname $0) DIB_INIT_SYSTEM=$(dib-init-system) if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then - install -m 0644 -o root -g root $home/ttySx.conf /etc/init/ttySx.conf + install -m 0644 -o root -g root ${SCRIPTDIR}/ttySx.conf /etc/init/ttySx.conf elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then - ln -s /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service - ln -s /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS1.service + install -D -g root -o root -m 0644 ${SCRIPTDIR}/serial-console-udev.rules /etc/udev/rules.d/99-serial-console.rules fi diff --git a/elements/serial-console/install.d/serial-console-udev.rules b/elements/serial-console/install.d/serial-console-udev.rules new file mode 100644 index 00000000..a0bd6c74 --- /dev/null +++ b/elements/serial-console/install.d/serial-console-udev.rules @@ -0,0 +1 @@ +SUBSYSTEM=="tty", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="getty@$name.service", ATTRS{type}=="4"