obmc-console: Rely on packaged systemd units

systemd units are now provided by obmc-console, so remove the in-tree
files.

Change-Id: I4970ad8056969b46ade1b4f09dea494fc0154957
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/recipes-phosphor/console/obmc-console/obmc-console-ssh.socket b/recipes-phosphor/console/obmc-console/obmc-console-ssh.socket
deleted file mode 100644
index 3174489..0000000
--- a/recipes-phosphor/console/obmc-console/obmc-console-ssh.socket
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Phosphor Host Console SSH Per-Connection socket
-Wants=obmc-console@{OBMC_CONSOLE_HOST_TTY}.service
-
-[Socket]
-ListenStream=2200
-Accept=yes
-
-[Install]
-WantedBy=sockets.target
diff --git a/recipes-phosphor/console/obmc-console/obmc-console-ssh@.service b/recipes-phosphor/console/obmc-console/obmc-console-ssh@.service
deleted file mode 100644
index 82ffe79..0000000
--- a/recipes-phosphor/console/obmc-console/obmc-console-ssh@.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Phosphor Host Console SSH Per-Connection
-Wants=obmc-console@{OBMC_CONSOLE_HOST_TTY}.service
-
-[Service]
-Environment="DROPBEAR_RSAKEY_DIR=/etc/dropbear"
-EnvironmentFile={envfiledir}/dropbear
-ExecStart=-/usr/bin/env dropbear -i -r ${{DROPBEAR_RSAKEY_DIR}}/dropbear_rsa_host_key -c "/usr/bin/env obmc-console-client" $DROPBEAR_EXTRA_ARGS
-SyslogIdentifier=dropbear
-ExecReload={base_bindir}/kill -HUP $MAINPID
-StandardInput=socket
-KillMode=process
diff --git a/recipes-phosphor/console/obmc-console/obmc-console@.service b/recipes-phosphor/console/obmc-console/obmc-console@.service
deleted file mode 100644
index 246544a..0000000
--- a/recipes-phosphor/console/obmc-console/obmc-console@.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Phosphor Console Muxer listening on device /dev/%I
-BindsTo=dev-%i.device
-After=dev-%i.device
-
-[Service]
-ExecStart=/usr/bin/env obmc-console-server --config {sysconfdir}/obmc-console.conf %i
-SyslogIdentifier=obmc-console-server
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
diff --git a/recipes-phosphor/console/obmc-console_git.bb b/recipes-phosphor/console/obmc-console_git.bb
index 7d11bff..baa7c8c 100644
--- a/recipes-phosphor/console/obmc-console_git.bb
+++ b/recipes-phosphor/console/obmc-console_git.bb
@@ -5,36 +5,57 @@
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
 
-inherit obmc-phosphor-systemd
 inherit autotools pkgconfig
 inherit obmc-phosphor-discovery-service
+inherit systemd
 
-TARGET_CFLAGS   += "-fpic -O2"
+S = "${WORKDIR}/git"
+
+TARGET_CFLAGS += "-fpic -O2"
+
+PACKAGECONFIG ??= "udev ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
+PACKAGECONFIG[udev] = "--with-udevdir=`pkg-config --variable=udevdir udev`,\
+                       --without-udevdir,udev"
+PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir}, \
+                          --without-systemdsystemunitdir"
 
 DEPENDS += "autoconf-archive-native \
             systemd \
-            "
+           "
 
 SRC_URI += "git://github.com/openbmc/obmc-console"
 SRC_URI += "file://${BPN}.conf"
 
-SRCREV = "c5ce2cbd12e395749c3b4abedf0d81f49b402b70"
+SRCREV = "fdf1a7102f800711daadfc3895fc8feeffa73c0e"
 PV = "1.0+git${SRCPV}"
 
 REGISTERED_SERVICES_${PN} += "obmc_console:tcp:2200:"
-OBMC_CONSOLE_HOST_TTY ?= "ttyVUART0"
-SYSTEMD_SUBSTITUTIONS += "OBMC_CONSOLE_HOST_TTY:${OBMC_CONSOLE_HOST_TTY}:${PN}-ssh@.service"
-SYSTEMD_SUBSTITUTIONS += "OBMC_CONSOLE_HOST_TTY:${OBMC_CONSOLE_HOST_TTY}:${PN}-ssh.socket"
 
-SYSTEMD_SERVICE_${PN} = " \
-        ${PN}@.service \
-        ${PN}@${OBMC_CONSOLE_HOST_TTY}.service \
-        ${PN}-ssh.socket \
-        ${PN}-ssh@.service \
-        "
+SYSTEMD_SERVICE_${PN} += "obmc-console-ssh@.service \
+                obmc-console-ssh.socket \
+                obmc-console@.service \
+                "
+
+FILES_${PN} += "/lib/systemd/system/obmc-console-ssh@.service.d/use-socket.conf"
+
 do_install_append() {
-        install -m 0755 -d ${D}${sysconfdir}
-        install -m 0644 ${WORKDIR}/${PN}.conf ${D}${sysconfdir}/${PN}.conf
+        # Install the server configuration
+        install -m 0755 -d ${D}${sysconfdir}/${BPN}
+        if test -f "${WORKDIR}/${BPN}.conf"; then
+                # Remove the upstream-provided server configuration
+                rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
+                # Install the old-style server configuration
+                install -m 0644 ${WORKDIR}/${BPN}.conf ${D}${sysconfdir}/
+                # Link the custom configuration to the required location
+                ln -sr ${D}${sysconfdir}/${BPN}.conf ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
+        elif test -f "${WORKDIR}/server.ttyVUART0.conf" ; then
+                # Remove the upstream-provided server configuration
+                rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
+                # Install the package-provided new-style configuration
+                install -m 0644 ${WORKDIR}/server.ttyVUART0.conf ${D}${sysconfdir}/${BPN}/
+        else
+                # Otherwise, remove socket-id from the shipped configuration to
+                # align with the lack of a client configuration file
+                sed -ri '/^socket-id =/d' ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
+        fi
 }
-
-S = "${WORKDIR}/git"