]> Untitled Git - mpdstream/commitdiff
Add systemd service file
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 31 Mar 2026 19:25:13 +0000 (15:25 -0400)
committerHugo Villeneuve <hvilleneuve@dimonoff.com>
Wed, 1 Apr 2026 23:38:04 +0000 (19:38 -0400)
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
.gitignore
Makefile.am
configure.ac
data/Makefile.am [new file with mode: 0644]
data/mpdstream.service.in [new file with mode: 0644]

index aa8d956832fe1540d1d0fabfbdb3eb0391517a51..1f0e924496a4f8ae17ccdaed7ba0e1b0dff780c8 100644 (file)
@@ -20,3 +20,4 @@ m4/ltversion.m4
 m4/lt~obsolete.m4
 build-aux/ltmain.sh
 libtool
+data/mpdstream.service
index 63bedb7be1586bdb58527025998acb51ec49b8d3..e6c2362e0875eb223af11cf57003f7fca80896e1 100644 (file)
@@ -2,6 +2,7 @@
 
 SUBDIRS = \
     src \
+    data \
     doc
 
 ACLOCAL_AMFLAGS = -I m4
index 4e7aee0b5d810448abf0f4e933fa9f90d5147fea..c20e733f1f0654c33ea0093f64ac6c6732faf7d5 100644 (file)
@@ -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 (file)
index 0000000..42ea057
--- /dev/null
@@ -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 (file)
index 0000000..00cf370
--- /dev/null
@@ -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