move service file, dbus conf into repo

Move the service file for phosphor-networkd from the bitbake recipe to
the source repository.
Move the dbus configuration file for phosphor-network from a generated
file to the source repository.

Tested: Verified dbus conf and service file were installed where
expected.
Change-Id: Idd1a1872aeb020f6b0e2eb9dba7c2e96198be2af
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/Makefile.am b/Makefile.am
index 43f4643..8e5c191 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,6 +3,14 @@
 	xyz/openbmc_project/Network/VLAN/Create/server.hpp \
 	xyz/openbmc_project/Network/IP/Create/server.hpp
 
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = \
+		xyz.openbmc_project.Network.service
+
+dbuspolicy_DATA = \
+		xyz.openbmc_project.Network.conf
+endif
+
 sbin_PROGRAMS = phosphor-network-manager ncsi-netlink
 
 noinst_HEADERS = \
diff --git a/configure.ac b/configure.ac
index 1bc24c7..14ed382 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,34 @@
 # Checks for library functions.
 LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot'
 
+PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([systemdsystemunitdir],
+     [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
+     [],
+     [with_systemdsystemunitdir=auto]
+)
+AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
+    [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+     AS_IF([test "x$def_systemdsystemunitdir" = "x"],
+           [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
+                  [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
+            )
+            with_systemdsystemunitdir=no],
+           [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
+     )]
+)
+AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
+      [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
+)
+AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
+
+AC_ARG_WITH([dbuspolicydir],
+    AS_HELP_STRING([--with-dbuspolicydir=DIR], [Directory for D-Bus system policy files])
+)
+AS_IF([test "x$with_dbuspolicydir" = "x"],
+      [with_dbuspolicydir="${sysconfdir}/dbus-1/system.d"]
+)
+AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
 
 # Check/set gtest specific functions.
 AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-GTEST_HAS_PTHREAD=0"])
@@ -106,10 +134,15 @@
 AS_IF([test "x$NETWORK_CONF_DIR" == "x"], [NETWORK_CONF_DIR="/etc/systemd/network"])
 AC_DEFINE_UNQUOTED([NETWORK_CONF_DIR], ["$NETWORK_CONF_DIR"], [Network configuration directory])
 
+AC_ARG_VAR(SYSTEMD_TARGET, "Target for starting this service")
+AS_IF([test "x$SYSTEMD_TARGET" == "x"], [SYSTEMD_TARGET="multi-user.target"])
+
 AC_DEFINE(SYSTEMD_BUSNAME, "org.freedesktop.systemd1", [systemd busname.])
 AC_DEFINE(SYSTEMD_PATH, "/org/freedesktop/systemd1", [systemd path.])
 AC_DEFINE(SYSTEMD_INTERFACE, "org.freedesktop.systemd1.Manager", [systemd interface.])
 
 # Create configured output.
 AC_CONFIG_FILES([Makefile test/Makefile])
+AC_CONFIG_FILES([xyz.openbmc_project.Network.service])
+AC_CONFIG_FILES([xyz.openbmc_project.Network.conf])
 AC_OUTPUT
diff --git a/xyz.openbmc_project.Network.conf.in b/xyz.openbmc_project.Network.conf.in
new file mode 100644
index 0000000..a81f2b0
--- /dev/null
+++ b/xyz.openbmc_project.Network.conf.in
@@ -0,0 +1,8 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+        "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+        <policy user="root">
+                <allow own="@BUSNAME_NETWORK@"/>
+                <allow send_destination="@BUSNAME_NETWORK@"/>
+        </policy>
+</busconfig>
diff --git a/xyz.openbmc_project.Network.service.in b/xyz.openbmc_project.Network.service.in
new file mode 100644
index 0000000..65c57ce
--- /dev/null
+++ b/xyz.openbmc_project.Network.service.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=Phosphor Network Manager
+After=obmc-mapper.target
+
+[Service]
+ExecStart=/usr/bin/env phosphor-network-manager
+SyslogIdentifier=phosphor-network-manager
+Restart=always
+Type=dbus
+BusName=@BUSNAME_NETWORK@
+RuntimeDirectory = network
+RuntimeDirectoryPreserve = yes
+StateDirectory = network
+
+[Install]
+WantedBy=@SYSTEMD_TARGET@