]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Improve startup script and make it optional
authorMike Brady <mikebrady@eircom.net>
Sat, 22 Apr 2017 17:09:56 +0000 (18:09 +0100)
committerMike Brady <mikebrady@eircom.net>
Sat, 22 Apr 2017 17:09:56 +0000 (18:09 +0100)
Makefile.am
configure.ac
scripts/shairport-sync.freebsd

index 91b64cd3839ca3c031808ea550e694a84ea3ed7e..908b34cc3868b351a808a51b089f766819c8165d 100644 (file)
@@ -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
index d35eb2fbf2d68d9ac38e2ecdbc648bd050364a10..93b0f4aa8bf98bb39a14d2338bb316dffdbb321c 100644 (file)
@@ -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
index 779a1eb271f0746a2b4cedca595d8386262a5ecf..9088bd825b848aa8635a00e7a7e425060aabd66c 100644 (file)
@@ -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