meta-google: console: Allow host console redirection

Originally written by William, upstreaming it from our downstream repo.

Signed-off-by: William A. Kennington III <wak@google.com>
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: If23d97cb2505f45af089571d77a70a32a37d1ce8
diff --git a/meta-google/recipes-phosphor/console/obmc-console/serial-to-host@.service.in b/meta-google/recipes-phosphor/console/obmc-console/serial-to-host@.service.in
new file mode 100644
index 0000000..c38b720
--- /dev/null
+++ b/meta-google/recipes-phosphor/console/obmc-console/serial-to-host@.service.in
@@ -0,0 +1,29 @@
+[Unit]
+Description=Host Serial Getty on %I
+BindsTo=dev-%i.device
+After=dev-%i.device systemd-user-sessions.service
+After=rc-local.service
+Before=getty.target
+IgnoreOnIsolate=yes
+
+Requires=obmc-console@@HOST_TTY@.service
+After=obmc-console@@HOST_TTY@.service
+Conflicts=serial-to-bmc@%i.service
+StartLimitIntervalSec=0
+
+[Service]
+Type=simple
+Restart=always
+RestartSec=0
+RestartPreventExitStatus=2
+SuccessExitStatus=2
+ExecStart=-/sbin/agetty -8 -n -l /usr/bin/obmc-console-client -o '-e a00pae9n2B9m1c' -i -N -R -L %I 115200 xterm
+ExecStopPost=-/bin/sh -c '(( EXIT_STATUS == 2 )) && systemctl start --no-block serial-to-bmc@%i'
+UtmpIdentifier=%I
+TTYPath=/dev/%I
+KillMode=process
+IgnoreSIGPIPE=no
+SendSIGHUP=yes
+
+[Install]
+WantedBy=getty.target