Install systemd services with autotools

Change-Id: Ic4875b74bcf2b6232d915070b77fc202a03ef997
This commit is contained in:
Pau Espin 2018-12-12 19:53:27 +01:00
parent ae25399f75
commit ae6ca31516
5 changed files with 41 additions and 1 deletions

View File

@ -1,3 +1,6 @@
SUBDIRS = doc src
SUBDIRS = contrib doc src
ACLOCAL_AMFLAGS = -I m4
AM_DISTCHECK_CONFIGURE_FLAGS = \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)

View File

@ -120,6 +120,23 @@ then
CPPFLAGS="$CPPFLAGS -pg"
fi
# https://www.freedesktop.org/software/systemd/man/daemon.html
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_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
@ -127,6 +144,8 @@ dnl Generate the output
AM_CONFIG_HEADER(config.h)
AC_OUTPUT(
contrib/Makefile
contrib/systemd/Makefile
doc/Makefile
doc/examples/Makefile
src/Makefile

1
contrib/Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = systemd

View File

@ -0,0 +1,6 @@
EXTRA_DIST = osmo-sysmon.service
if HAVE_SYSTEMD
systemdsystemunit_DATA = \
osmo-sysmon.service
endif

View File

@ -0,0 +1,11 @@
[Unit]
Description=Osmocom System Monitoring daemon
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/osmo-sysmon -c /etc/osmocom/osmo-sysmon.cfg
RestartSec=2
[Install]
WantedBy=multi-user.target