diff --git a/Makefile.am b/Makefile.am index 40dff3f..3f87824 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 SUBDIRS = \ + contrib \ doc \ src \ include \ @@ -16,6 +17,10 @@ EXTRA_DIST = \ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libosmo-e1d.pc +AM_DISTCHECK_CONFIGURE_FLAGS = \ + --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) + + @RELMAKE@ BUILT_SOURCES = $(top_srcdir)/.version diff --git a/configure.ac b/configure.ac index 0320b6f..548cc68 100644 --- a/configure.ac +++ b/configure.ac @@ -72,8 +72,26 @@ then CPPFLAGS="$CPPFLAGS $WERROR_FLAGS" fi +# https://www.freedesktop.org/software/systemd/man/daemon.html +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_OUTPUT( Makefile + contrib/Makefile + contrib/systemd/Makefile doc/Makefile doc/examples/Makefile src/Makefile diff --git a/contrib/Makefile.am b/contrib/Makefile.am new file mode 100644 index 0000000..3439c97 --- /dev/null +++ b/contrib/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = systemd diff --git a/contrib/systemd/Makefile.am b/contrib/systemd/Makefile.am new file mode 100644 index 0000000..54c6c6e --- /dev/null +++ b/contrib/systemd/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = osmo-e1d.service + +if HAVE_SYSTEMD +systemdsystemunit_DATA = \ + osmo-e1d.service +endif diff --git a/contrib/systemd/osmo-e1d.service b/contrib/systemd/osmo-e1d.service new file mode 100644 index 0000000..03ac643 --- /dev/null +++ b/contrib/systemd/osmo-e1d.service @@ -0,0 +1,12 @@ +[Unit] +Description=Osmocom E1 Interface Daemon +Wants=osmo-e1d.service + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/osmo-e1d -c /etc/osmocom/osmo-e1d.cfg +RestartSec=2 + +[Install] +WantedBy=multi-user.target diff --git a/debian/osmo-e1d.install b/debian/osmo-e1d.install index 7aeba92..80bd25a 100644 --- a/debian/osmo-e1d.install +++ b/debian/osmo-e1d.install @@ -1,2 +1,3 @@ /etc/osmocom/osmo-e1d.cfg +lib/systemd/system/osmo-e1d.service usr/bin/osmo-e1d