From: Mike Brady Date: Sat, 22 Apr 2017 17:09:56 +0000 (+0100) Subject: Improve startup script and make it optional X-Git-Tag: 3.1d16~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6eca4ca6eef53b67057b06300fd45662f7ffd12;p=thirdparty%2Fshairport-sync.git Improve startup script and make it optional --- diff --git a/Makefile.am b/Makefile.am index 91b64cd3..908b34cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -74,19 +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 BUILD_FOR_SYSTEMV +if INSTALL_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 BUILD_FOR_SYSTEMD +if INSTALL_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 +if INSTALL_FREEBSD_SERVICE 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 + [ -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 diff --git a/configure.ac b/configure.ac index d35eb2fb..93b0f4aa 100644 --- a/configure.ac +++ b/configure.ac @@ -10,11 +10,11 @@ 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])) -if test "z$with_os_type" = "z"; then - with_os_type="linux" +AC_ARG_WITH(os, AS_HELP_STRING([--with-os=OSType],[Specify the distribution to target: One of linux freebsd or darwin])) +if test "z$with_os" = "z"; then + with_os="linux" fi -with_os_type=`echo ${with_os_type} | tr '[[:upper:]]' '[[:lower:]]' ` +with_os=`echo ${with_os} | tr '[[:upper:]]' '[[:lower:]]' ` # Checks for programs. AC_PROG_CC @@ -24,11 +24,11 @@ AC_PROG_INSTALL PKG_PROG_PKG_CONFIG([0.9.0]) # Checks for libraries. -if test "x${with_os_type}" = xlinux -o "x${with_os_type}" = xfreebsd ; then +if test "x${with_os}" = xlinux -o "x${with_os}" = 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 ]) +AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "x${with_os}" = 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,17 @@ 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([BUILD_FOR_SYSTEMV], [test "x$with_systemv" = "xyes"]) +AM_CONDITIONAL([INSTALL_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([BUILD_FOR_SYSTEMD], [test "x$with_systemd" = "xyes"]) +[ --with-systemd = install a systemd startup script during a make install], , ) +AM_CONDITIONAL([INSTALL_SYSTEMD], [test "x$with_systemd" = "xyes"]) + +AC_ARG_WITH([freebsd-service], +[ --with-freebsd-service = install a FreeBSD startup script during a make install], , ) +AM_CONDITIONAL([INSTALL_FREEBSD_SERVICE], [test "x$with_freebsd_service" = "xyes"]) # Add the libconfig package if test "x${with_pkg_config}" = xyes ; then diff --git a/scripts/shairport-sync.freebsd b/scripts/shairport-sync.freebsd index 779a1eb2..9088bd82 100644 --- a/scripts/shairport-sync.freebsd +++ b/scripts/shairport-sync.freebsd @@ -1,25 +1,27 @@ #!/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 +# PROVIDE: shairport_sync +# REQUIRE: FILESYSTEMS DAEMON hostname avahi_daemon . /etc/rc.subr -name="shairport-sync" +name="shairport_sync" +rcvar="shairport_sync_enable" + start_cmd="${name}_start" stop_cmd="${name}_stop" -shairport-sync_start() +shairport_sync_start() { - su -m shairport-sync -c "/usr/local/bin/shairport-sync -d" + checkyesno shairport_sync_enable && echo "Starting shairport-sync." && \ + su -m shairport-sync -c "/usr/local/bin/shairport-sync -d" } -shairport-sync_stop() +shairport_sync_stop() { - su -m shairport-sync -c "/usr/local/bin/shairport-sync -k" + checkyesno shairport_sync_enable && echo "Stopping shairport-sync." && \ + /usr/local/bin/shairport-sync -k } load_rc_config $name