aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-06-30 21:50:17 +0200
committerlaforge <laforge@osmocom.org>2020-07-01 08:29:39 +0000
commite1145c53e344997a6b9776e9ebc2daf3af563ec7 (patch)
tree76ee602d39518c4cefffef95268b777dcdfdc8de
parentd32bd186a3453ee1cb5e4ed1febb5fe84c3cec2d (diff)
add systemd service/unit0.0.1
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac18
-rw-r--r--contrib/Makefile.am1
-rw-r--r--contrib/systemd/Makefile.am6
-rw-r--r--contrib/systemd/osmo-e1d.service12
-rw-r--r--debian/osmo-e1d.install1
6 files changed, 43 insertions, 0 deletions
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