Add FreeBSD service and installation. Change default PID file directory. SystemV and SystemD scripts should be updated.
This commit is contained in:
+15
-3
@@ -4,7 +4,11 @@ bin_PROGRAMS = shairport-sync
|
||||
shairport_sync_SOURCES = shairport.c rtsp.c mdns.c mdns_external.c common.c rtp.c player.c alac.c audio.c loudness.c
|
||||
|
||||
AM_CFLAGS = -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\" -O2
|
||||
AM_CPPFLAGS = -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\" -O2
|
||||
if BUILD_FOR_FREEBSD
|
||||
AM_CPPFLAGS = -I/usr/local/include -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\" -O2
|
||||
else
|
||||
AM_CPPFLAGS = -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\" -O2
|
||||
endif
|
||||
|
||||
if USE_APPLE_ALAC
|
||||
shairport_sync_SOURCES += apple_alac.cpp
|
||||
@@ -70,11 +74,19 @@ if INSTALL_CONFIG_FILES
|
||||
cp scripts/shairport-sync.conf $(DESTDIR)$(sysconfdir)/shairport-sync.conf.sample
|
||||
[ -f $(DESTDIR)$(sysconfdir)/shairport-sync.conf ] || cp scripts/shairport-sync.conf $(DESTDIR)$(sysconfdir)/shairport-sync.conf
|
||||
endif
|
||||
if INSTALL_SYSTEMV
|
||||
if BUILD_FOR_SYSTEMV
|
||||
[ -e $(DESTDIR)$(sysconfdir)/init.d ] || mkdir -p $(DESTDIR)$(sysconfdir)/init.d
|
||||
[ -f $(DESTDIR)$(sysconfdir)/init.d/shairport-sync ] || cp scripts/shairport-sync $(DESTDIR)$(sysconfdir)/init.d/
|
||||
endif
|
||||
if INSTALL_SYSTEMD
|
||||
if BUILD_FOR_SYSTEMD
|
||||
[ -e $(DESTDIR)$(systemdsystemunitdir) ] || mkdir -p $(DESTDIR)$(systemdsystemunitdir)
|
||||
[ -f $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || cp scripts/shairport-sync.service $(DESTDIR)$(systemdsystemunitdir)
|
||||
endif
|
||||
if BUILD_FOR_FREEBSD
|
||||
pw showgroup shairport-sync > /dev/null 2>&1 || pw addgroup shairport-sync > /dev/null 2>&1
|
||||
pw showuser shairport-sync > /dev/null 2>&1 || pw adduser shairport-sync > /dev/null 2>&1
|
||||
[ -e /var/run/shairport-sync ] || mkdir -p /var/run/shairport-sync
|
||||
chown shairport-sync:shairport-sync /var/run/shairport-sync
|
||||
[ -f /usr/local/etc/rc.d/shairport-sync ] || cp scripts/shairport-sync.freebsd /usr/local/etc/rc.d/shairport-sync
|
||||
chmod 555 /usr/local/etc/rc.d/shairport-sync
|
||||
endif
|
||||
|
||||
+4
-4
@@ -8,8 +8,6 @@ AC_CONFIG_SRCDIR([shairport.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
# Derived from the Avahi configure.ac file
|
||||
#
|
||||
#
|
||||
# Specifying the OS type, defaulting to linux.
|
||||
#
|
||||
AC_ARG_WITH(os_type, AS_HELP_STRING([--with-os-type=OSType],[Specify the distribution to target: One of linux freebsd or darwin]))
|
||||
@@ -30,6 +28,8 @@ if test "x${with_os_type}" = xlinux -o "x${with_os_type}" = xfreebsd ; then
|
||||
AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed))
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "x${with_os_type}" = xfreebsd ])
|
||||
|
||||
##### Some build systems are not fully using pkg-config, so we can use the flag ${with_pkg_config} on a case-by-case basis
|
||||
##### to control how to deal with them
|
||||
|
||||
@@ -73,13 +73,13 @@ AM_CONDITIONAL([USE_PIPE], [test "x$with_pipe" = "xyes" ])
|
||||
|
||||
AC_ARG_WITH([systemv],
|
||||
[ --with-systemv = install a System V startup script during a make install], , )
|
||||
AM_CONDITIONAL([INSTALL_SYSTEMV], [test "x$with_systemv" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_FOR_SYSTEMV], [test "x$with_systemv" = "xyes"])
|
||||
|
||||
# Check to see if we should include the systemd stuff to define it as a service
|
||||
|
||||
AC_ARG_WITH([systemd],
|
||||
[ --with-systemd = install a systemd service description file during a make install], , )
|
||||
AM_CONDITIONAL([INSTALL_SYSTEMD], [test "x$with_systemd" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_FOR_SYSTEMD], [test "x$with_systemd" = "xyes"])
|
||||
|
||||
# Add the libconfig package
|
||||
if test "x${with_pkg_config}" = xyes ; then
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD: releng/11.0/etc/rc.d/motd 298514 2016-04-23 16:10:54Z lme $
|
||||
#
|
||||
|
||||
# PROVIDE: shairport-sync
|
||||
# REQUIRE: FILESYSTEMS DAEMON hostname
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="shairport-sync"
|
||||
start_cmd="${name}_start"
|
||||
stop_cmd="${name}_stop"
|
||||
|
||||
shairport-sync_start()
|
||||
{
|
||||
su -m shairport-sync -c "/usr/local/bin/shairport-sync -d"
|
||||
}
|
||||
|
||||
shairport-sync_stop()
|
||||
{
|
||||
su -m shairport-sync -c "/usr/local/bin/shairport-sync -k"
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
||||
+14
-7
@@ -873,9 +873,9 @@ void shairport_startup_complete(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_CUSTOM_PID_DIR
|
||||
|
||||
const char *pid_file_proc(void) {
|
||||
#ifdef USE_CUSTOM_PID_DIR
|
||||
#ifdef HAVE_ASPRINTF
|
||||
static char *fn = NULL;
|
||||
asprintf(&fn, "%s/%s.pid", PIDDIR, daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
|
||||
@@ -884,10 +884,18 @@ const char *pid_file_proc(void) {
|
||||
snprintf(fn, sizeof(fn), "%s/%s.pid", PIDDIR,
|
||||
daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifdef HAVE_ASPRINTF
|
||||
static char *fn = NULL;
|
||||
asprintf(&fn, "/var/run/shairport-sync/%s.pid", daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
|
||||
#else
|
||||
static char fn[8192];
|
||||
snprintf(fn, sizeof(fn), "/var/run/shairport-sync/%s.pid",
|
||||
daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
|
||||
#endif
|
||||
#endif
|
||||
return fn;
|
||||
}
|
||||
#endif
|
||||
|
||||
void exit_function() {
|
||||
if (config.cfg)
|
||||
@@ -1005,11 +1013,10 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if USE_CUSTOM_PID_DIR
|
||||
debug(1, "Locating custom pid dir at \"%s\"", PIDDIR);
|
||||
/* Point to a function to help locate where the PID file will go */
|
||||
// Point to a function to help locate where the PID file will go
|
||||
// We always use this function because the default location
|
||||
// is unsatisfactory. By default we want to use /var/run/shairport-sync/.
|
||||
daemon_pid_file_proc = pid_file_proc;
|
||||
#endif
|
||||
|
||||
/* Set indentification string for the daemon for both syslog and PID file */
|
||||
daemon_pid_file_ident = daemon_log_ident = daemon_ident_from_argv0(argv[0]);
|
||||
|
||||
Reference in New Issue
Block a user