Use common service file for avahi

Use variable substitution to simplify service file for optional avahi.

This will also help to simplify adding future service dependencies.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
This commit is contained in:
Hugo Villeneuve
2026-01-26 10:24:22 -05:00
committed by Hugo Villeneuve
parent 23e8504579
commit 6a94eeb926
5 changed files with 15 additions and 29 deletions
-1
View File
@@ -25,7 +25,6 @@ stamp-h1
man/Makefile
man/Makefile.in
scripts/shairport-sync.service
scripts/shairport-sync.service-avahi
scripts/shairport-sync
shairport-sync.core
gitversion-stamp
-4
View File
@@ -277,11 +277,7 @@ endif # INSTALL_SYSTEMV_STARTUP
if INSTALL_SYSTEMD_STARTUP
if USE_AVAHI
SYSTEMD_SERVICE = shairport-sync.service-avahi
else
SYSTEMD_SERVICE = shairport-sync.service
endif # USE_AVAHI
INSTALL_SYSTEMD_TARGET = install-systemd-local
+13 -4
View File
@@ -228,9 +228,8 @@ if test "x$with_avahi" = "xyes" ; then
AC_DEFINE([CONFIG_AVAHI], 1, [Include Avahi-based mDNS support.])
AC_CHECK_LIB([avahi-client], [avahi_client_new], , AC_MSG_ERROR(Avahi support requires the avahi-client library!))
AC_CHECK_LIB([avahi-common],[avahi_strerror], , AC_MSG_ERROR(Avahi support requires the avahi-common library!))
AC_CONFIG_FILES([scripts/shairport-sync.service-avahi])
else
AC_CONFIG_FILES([scripts/shairport-sync.service])
systemd_after_args="${systemd_after_args} avahi-daemon.service"
systemd_requires_args="${systemd_requires_args} avahi-daemon.service"
fi
AM_CONDITIONAL([USE_AVAHI], [test "x$with_avahi" = "xyes"])
@@ -558,12 +557,22 @@ AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_CHECK_FUNCS([atexit clock_gettime gethostname inet_ntoa memchr memmove memset mkfifo pow select socket stpcpy strcasecmp strchr strdup strerror strstr strtol strtoul])
# Note -- there are AC_CONFIG_FILES directives further back, conditional on Avahi
if test "x${systemd_after_args}" != x ; then
systemd_after_args="After=${systemd_after_args}"
fi
if test "x${systemd_requires_args}" != x ; then
systemd_requires_args="Requires=${systemd_requires_args}"
fi
AC_SUBST([SYSTEMD_AFTER_ARGS], [${systemd_after_args}])
AC_SUBST([SYSTEMD_REQUIRES_ARGS], [${systemd_requires_args}])
# The man directory will not be recursively made unless you set the SUBDIR in Makefile.am.
# But leave this as is to enable a distclean to be done.
AC_CONFIG_FILES([Makefile man/Makefile])
AC_CONFIG_FILES([scripts/shairport-sync.service])
AC_CONFIG_FILES([scripts/shairport-sync],[chmod +x scripts/shairport-sync])
AC_OUTPUT
-20
View File
@@ -1,20 +0,0 @@
[Unit]
Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target
StartLimitIntervalSec=300
StartLimitBurst=5
[Service]
ExecStart=@prefix@/bin/shairport-sync --log-to-syslog
User=shairport-sync
Group=shairport-sync
LimitRTPRIO=5
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
+2
View File
@@ -3,6 +3,8 @@ Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target
Wants=network-online.target
After=network.target network-online.target
@SYSTEMD_AFTER_ARGS@
@SYSTEMD_REQUIRES_ARGS@
StartLimitIntervalSec=300
StartLimitBurst=5