Dynamically start console server on a given TTY

obmc-console-server currently uses /dev/ttyVUART0, which is a symlink
to ttyS0. This patch allows the TTY number to be populated based on some source
and then passes the TTY number on which the console server needs to be started.

This patch also makes sure that obmc-console-ssh@.service is instantiated only
if the console server is started on the TTY device mentioned above.

Fixes openbmc/openbmc#407

Change-Id: If7a6f0e5b899a32225af262e72a3292fb619920a
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/common/recipes-phosphor/console/obmc-console/obmc-console@.service b/common/recipes-phosphor/console/obmc-console/obmc-console@.service
new file mode 100644
index 0000000..d84fca9
--- /dev/null
+++ b/common/recipes-phosphor/console/obmc-console/obmc-console@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Phosphor Console Muxer listening on device /dev/%I
+BindsTo=dev-%i.device
+After=dev-%i.device
+
+[Service]
+# TODO: openbmc/obmc-console#5 - Restore this to 'obmc-console-server ttyVUART0'
+ExecStart=/bin/sh -c 'realpath /dev/%i | xargs basename | xargs {sbindir}/obmc-console-server'
+Restart=always
+
+[Install]
+WantedBy={SYSTEMD_DEFAULT_TARGET}