@@ -17,7 +17,8 @@ libdir() {
args="--prefix=/usr \
--sysconfdir=/etc \
---libdir=$(libdir /usr/lib)"
+--libdir=$(libdir /usr/lib) \
+--with-systemd-unit-dir"
echo
echo "----------------------------------------------------------------"
@@ -135,6 +135,27 @@ AC_CHECK_FUNCS([ \
secure_getenv\
])
+PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([systemd-unit-dir],
+ AS_HELP_STRING([--with-systemd-unit-dir[=DIR]],
+ [Directory for systemd service files]),
+ [],
+ [with_systemd_unit_dir=yes])
+
+if test "x$with_systemd_unit_dir" = "xyes"; then
+ def_systemd_unit_dir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+ if test "x$def_systemd_unit_dir" = "x"; then
+ AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])
+ with_systemd_unit_dir=no
+ else
+ with_systemd_unit_dir="$def_systemd_unit_dir"
+ fi
+fi
+
+AS_IF([test "x$with_systemd_unit_dir" != "xno"],
+ [AC_SUBST([SYSTEMD_UNIT_DIR], [$with_systemd_unit_dir])])
+AM_CONDITIONAL([ENABLE_SYSTEMD_UNIT_DIR], [test "x$with_systemd_unit_dir" != "xno"])
+
my_CFLAGS="\
-Wall \
-Wchar-subscripts \
@@ -172,6 +193,7 @@ AC_MSG_RESULT([
sysconfdir: ${sysconfdir}
libdir: ${libdir}
includedir: ${includedir}
+ systemd-unit-dir: ${SYSTEMD_UNIT_DIR}
compiler: ${CC}
cflags: ${CFLAGS}
@@ -47,3 +47,7 @@ monitor_config_file = monitor.conf
monitor_configdir = /etc/ndctl/
monitor_config_DATA = $(monitor_config_file)
EXTRA_DIST += $(monitor_config_file)
+
+if ENABLE_SYSTEMD_UNIT_DIR
+systemd_unitDATA = ndctl-monitor.service
+endif
new file mode 100644
@@ -0,0 +1,7 @@
+[Unit]
+Description=Ndctl Monitor Daemon
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/ndctl monitor --daemon
+ExecStop=/bin/kill ${MAINPID}
This patch adds the systemd unit file for ndctl-monitor service. The systemd unit directory can be configured by setting environment variable "--with-systemd-unit-dir[=DIR]". Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com> --- autogen.sh | 3 ++- configure.ac | 22 ++++++++++++++++++++++ ndctl/Makefile.am | 4 ++++ ndctl/ndctl-monitor.service | 7 +++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ndctl/ndctl-monitor.service