From patchwork Fri Jul 13 23:33:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: QI Fuli X-Patchwork-Id: 10524267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C79A6032C for ; Fri, 13 Jul 2018 23:34:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1870A29B6F for ; Fri, 13 Jul 2018 23:34:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C7F129BF8; Fri, 13 Jul 2018 23:34:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,URIBL_BLACK autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E644429B6F for ; Fri, 13 Jul 2018 23:34:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DDB5220985988; Fri, 13 Jul 2018 16:34:08 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=202.219.69.170; helo=mgwkm03.jp.fujitsu.com; envelope-from=qi.fuli@jp.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from mgwkm03.jp.fujitsu.com (mgwkm03.jp.fujitsu.com [202.219.69.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AB63021B02845 for ; Fri, 13 Jul 2018 16:34:06 -0700 (PDT) Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm03.jp.fujitsu.com with smtp id 0c6c_040d_b0df87ba_3070_4f11_ae76_b71b6245e00e; Sat, 14 Jul 2018 08:34:01 +0900 Received: from m3051.s.css.fujitsu.com (m3051.s.css.fujitsu.com [10.134.21.209]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 23254AC020C for ; Sat, 14 Jul 2018 08:34:01 +0900 (JST) Received: from qi-fedora.fujitsu.com (unknown [10.124.196.110]) by m3051.s.css.fujitsu.com (Postfix) with ESMTP id F25F8349; Sat, 14 Jul 2018 08:34:00 +0900 (JST) From: QI Fuli To: linux-nvdimm@lists.01.org Subject: [ndctl PATCH v13 3/5] ndctl, monitor: add the unit file of systemd for ndctl-monitor service Date: Sat, 14 Jul 2018 08:33:48 +0900 Message-Id: <20180713233350.7148-4-qi.fuli@jp.fujitsu.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180713233350.7148-1-qi.fuli@jp.fujitsu.com> References: <20180713233350.7148-1-qi.fuli@jp.fujitsu.com> X-TM-AS-MML: disable X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tokunaga.keiich@jp.fujitsu.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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]". A monitor daemon can be started as a system service: # systemctl start ndctl-monitor.service Signed-off-by: QI Fuli --- autogen.sh | 3 ++- configure.ac | 22 ++++++++++++++++++++++ ndctl.spec.in | 2 ++ ndctl/Makefile.am | 4 ++++ ndctl/ndctl-monitor.service | 7 +++++++ 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 ndctl/ndctl-monitor.service diff --git a/autogen.sh b/autogen.sh index 2a52688..21b0e25 100755 --- a/autogen.sh +++ b/autogen.sh @@ -17,7 +17,8 @@ libdir() { args="--prefix=/usr \ --sysconfdir=/etc \ ---libdir=$(libdir /usr/lib)" +--libdir=$(libdir /usr/lib) \ +--with-systemd-unit-dir" echo echo "----------------------------------------------------------------" diff --git a/configure.ac b/configure.ac index ff0096d..e242334 100644 --- a/configure.ac +++ b/configure.ac @@ -143,6 +143,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_unitdir], [$with_systemd_unit_dir])]) +AM_CONDITIONAL([ENABLE_SYSTEMD_UNIT_DIR], [test "x$with_systemd_unit_dir" != "xno"]) + my_CFLAGS="\ -D DEF_CONF_FILE='\"${sysconfdir}/ndctl/monitor.conf\"' \ -Wall \ @@ -185,6 +206,7 @@ AC_MSG_RESULT([ sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} + systemd-unit-dir: ${systemd_unitdir} compiler: ${CC} cflags: ${CFLAGS} diff --git a/ndctl.spec.in b/ndctl.spec.in index 41a1d59..17152c1 100644 --- a/ndctl.spec.in +++ b/ndctl.spec.in @@ -20,6 +20,7 @@ BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(bash-completion) +BuildRequires: systemd %description Utility library for managing the "libnvdimm" subsystem. The "libnvdimm" @@ -117,6 +118,7 @@ make check %{_mandir}/man1/ndctl* %{bashcompdir}/ %{_sysconfdir}/ndctl/monitor.conf +%{_unitdir}/ndctl-monitor.service %files -n daxctl %defattr(-,root,root) diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am index 58b747a..0f9bb43 100644 --- a/ndctl/Makefile.am +++ b/ndctl/Makefile.am @@ -47,3 +47,7 @@ monitor_config_file = monitor.conf monitor_configdir = $(sysconfdir)/ndctl/ monitor_config_DATA = $(monitor_config_file) EXTRA_DIST += $(monitor_config_file) + +if ENABLE_SYSTEMD_UNIT_DIR +systemd_unit_DATA = ndctl-monitor.service +endif diff --git a/ndctl/ndctl-monitor.service b/ndctl/ndctl-monitor.service new file mode 100644 index 0000000..44f9326 --- /dev/null +++ b/ndctl/ndctl-monitor.service @@ -0,0 +1,7 @@ +[Unit] +Description=Ndctl Monitor Daemon + +[Service] +Type=forking +ExecStart=/usr/bin/ndctl monitor --daemon +ExecStop=/bin/kill ${MAINPID}