From 562d72d003b891ebb03a0b260081d423f610b646 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Tue, 31 Mar 2026 15:25:13 -0400 Subject: [PATCH] Add systemd service file Signed-off-by: Hugo Villeneuve --- .gitignore | 1 + Makefile.am | 1 + configure.ac | 21 +++++++++++++++++++++ data/Makefile.am | 13 +++++++++++++ data/mpdstream.service.in | 14 ++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 data/Makefile.am create mode 100644 data/mpdstream.service.in diff --git a/.gitignore b/.gitignore index aa8d956..1f0e924 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ m4/ltversion.m4 m4/lt~obsolete.m4 build-aux/ltmain.sh libtool +data/mpdstream.service diff --git a/Makefile.am b/Makefile.am index 63bedb7..e6c2362 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,7 @@ SUBDIRS = \ src \ + data \ doc ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 4e7aee0..c20e733 100644 --- a/configure.ac +++ b/configure.ac @@ -43,11 +43,32 @@ else AC_MSG_ERROR([Please install libmpdclient and libmpdclient-devel packages]) fi +dnl Check if we should install the systemd file: +AC_ARG_WITH([systemd],[AS_HELP_STRING([--with-systemd],[install systemd service file])]) +AM_CONDITIONAL([INSTALL_SYSTEMD], [test "x$with_systemd" = "xyes"]) + +dnl On Debian, may require: +dnl sudo apt install systemd-dev +if test "x${with_systemd}" = xyes ; then + dnl Check for systemd unit directory using pkgconfig: + PKG_CHECK_VAR([systemdsystemunitdir], [systemd], [systemdsystemunitdir]) + + dnl Allow users to override the path (e.g., ./configure --with-systemdsystemunitdir=/tmp) + AC_ARG_WITH([systemdsystemunitdir], + [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], + [with_systemdsystemunitdir=$withval], [with_systemdsystemunitdir=$systemdsystemunitdir]) + + dnl Make the variable available in Makefiles + AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) +fi + AC_SUBST(WARNINGCFLAGS) AC_SUBST(ac_aux_dir) dnl Creating output file(s) AC_CONFIG_FILES([Makefile + data/Makefile + data/mpdstream.service doc/Makefile src/Makefile ]) diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..42ea057 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,13 @@ +# This file is processed by GNU automake to generate Makefile.in + +systemdsystemunit_DATA = mpdstream.service + +systemdsystemunitdir = @systemdsystemunitdir@ + +EXTRA_DIST = \ + mpdstream.service + +CLEANFILES = *~ + +MAINTAINERCLEANFILES = \ + Makefile.in diff --git a/data/mpdstream.service.in b/data/mpdstream.service.in new file mode 100644 index 0000000..00cf370 --- /dev/null +++ b/data/mpdstream.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=mpdstream service +After=mpd.service +StartLimitIntervalSec=60 +StartLimitBurst=5 + +[Service] +Type=simple +ExecStart=@prefix@/bin/mpdstream +Restart=on-failure +RestartSec=10s + +[Install] +WantedBy=multi-user.target -- 2.47.3