Skip to content

Commit

Permalink
Add systemd unit file
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
  • Loading branch information
troglobit committed Dec 16, 2018
1 parent b8a0083 commit 18f0fe7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -35,6 +35,7 @@ missing
map-mbone
mrinfo
mrouted
mrouted.service
mtrace
stamp-h1
cfparse.c
Expand Down
6 changes: 6 additions & 0 deletions Makefile.am
@@ -1,8 +1,14 @@
DISTCHECK_CONFIGURE_FLAGS = --with-systemd=$$dc_install_base/$(systemd)

doc_DATA = README.md ChangeLog.org LICENSE mrouted.conf
EXTRA_DIST = README.md ChangeLog.org LICENSE mrouted.conf
DISTCLEANFILES = *~ DEADJOE semantic.cache *.gdb *.elf core core.* *.d
SUBDIRS = src man

if SYSTEMD
systemd_DATA = mrouted.service
endif

## Generate MD5 checksum file
MD5 = md5sum
md5-dist:
Expand Down
35 changes: 34 additions & 1 deletion configure.ac
Expand Up @@ -5,13 +5,16 @@ AM_SILENT_RULES([yes])

AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile mrouted.service])

# Check for standard programs, headers, and functions
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_YACC

# Required to check for libsystemd-dev
PKG_PROG_PKG_CONFIG

# Check for linux/netlink.h is only to be able to define LINUX below
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h ifaddrs.h netinet/igmp.h sys/time.h linux/netlink.h])
Expand Down Expand Up @@ -45,12 +48,42 @@ AC_ARG_ENABLE(rsrr,
http://tools.ietf.org/html/draft-ietf-rsvp-routing-02]),,
enable_rsrr=no)

AC_ARG_WITH([systemd],
[AS_HELP_STRING([--with-systemd=DIR], [Directory for systemd service files])],,
[with_systemd=auto])

# Create config.h from selected features and fallback defautls
AS_IF([test "x$enable_rsrr" = "xyes"], [
AC_DEFINE(RSRR, 1, [Routing Support for Resource Reservation.])])

AS_IF([test "x$with_systemd" = "xyes" -o "x$with_systemd" = "xauto"], [
def_systemd=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
AS_IF([test "x$def_systemd" = "x"],
[AS_IF([test "x$with_systemd" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemd=no], [with_systemd="$def_systemd"])])
AS_IF([test "x$with_systemd" != "xno"],
[AC_SUBST([systemddir], [$with_systemd])])

AM_CONDITIONAL(BSD, [test "x$ac_cv_header_net_if_dl_h" = "xyes"])
AM_CONDITIONAL(LINUX, [test "x$ac_cv_header_linux_netlink_h" = "xyes"])
AM_CONDITIONAL(RSRR, [test "x$enable_rsrr" = "xyes"])
AM_CONDITIONAL(SYSTEMD, [test "x$with_systemd" != "xno"])

# Expand $sbindir early, into $SBINDIR, for systemd unit file
# NOTE: This does *not* take prefix/exec_prefix override at "make
# install" into account, unfortunately.
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
DOCDIR=`eval echo $docdir`
DOCDIR=`eval echo $DOCDIR`
AC_SUBST(DOCDIR)
SYSCONFDIR=`eval echo $sysconfdir`
SYSCONFDIR=`eval echo $SYSCONFDIR`
AC_SUBST(SYSCONFDIR)
SBINDIR=`eval echo $sbindir`
SBINDIR=`eval echo $SBINDIR`
AC_SUBST(SBINDIR)

# Generate all files
AC_OUTPUT
Expand Down
16 changes: 16 additions & 0 deletions mrouted.service.in
@@ -0,0 +1,16 @@
[Unit]
Description=Multicast routing daemon, mrouted
Documentation=man:mrouted
Documentation=file:@DOCDIR@/README.md
Documentation=https://github.com/troglobit/mrouted
# ConditionPathExists=@SYSCONFDIR@/mrouted.conf
After=network-online.target
Requires=network-online.target

[Service]
Type=simple
ExecStartPre=-/sbin/modprobe ipip
ExecStart=@SBINDIR@/mrouted -f

[Install]
WantedBy=multi-user.target

0 comments on commit 18f0fe7

Please sign in to comment.