control: Install JSON config files from repo
Install the JSON config files for the machine name provided in the
environment variable "MACHINE" into the application's data directory.
When no "MACHINE" name is given, the entire contents of the
`config_files` directory is installed and when a given "MACHINE" named
directory does not exist, the installation is intended to fail. This
failure of installation is to ensure that the fan application's
necessary JSON config files will exist so the fan application does not
fail to start.
Change-Id: I9d93694ece2fa26cd556f3010f2136d5576f8270
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/configure.ac b/configure.ac
index b03b7a5..62faf98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,6 +157,7 @@
# Use runtime(json) config, otherwise default to compile time(yaml) config
AM_COND_IF([WANT_JSON_CONTROL],
[
+ AC_ARG_VAR(MACHINE, [Machine name to install a particular set of associated config file(s)])
AC_CHECK_HEADER(nlohmann/json.hpp, ,
[AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
# Set config flag for runtime json usage
diff --git a/control/Makefile.am b/control/Makefile.am
index 9ae9b47..aca9c5c 100644
--- a/control/Makefile.am
+++ b/control/Makefile.am
@@ -7,6 +7,21 @@
systemdsystemunit_DATA=
if WANT_JSON_CONTROL
+CONFIGSDIR = "${pkgdatadir}/control/"
+CONFIGSLOC = "${srcdir}/config_files/$(MACHINE)/"
+
+EXTRA_DIST = $(CONFIGSLOC)
+
+# No $(MACHINE) given results in installing entire config_files contents
+install-data-hook:
+ for config in `cd $(CONFIGSLOC) && find * -type f`; do \
+ $(MKDIR_P) "$(DESTDIR)$(CONFIGSDIR)`dirname $${config}`"; \
+ $(INSTALL_DATA) "$(CONFIGSLOC)$${config}" "$(DESTDIR)$(CONFIGSDIR)`dirname $${config}`"; \
+ done
+
+uninstall-hook:
+ rm -rf "$(DESTDIR)$(CONFIGSDIR)"
+
systemdsystemunit_DATA += \
service_files/json/phosphor-fan-control@.service
else