]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Stop using libdaemon and use FreeBSD's daemon utility to deamonise and control shairp...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 20 May 2022 11:30:08 +0000 (12:30 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 20 May 2022 11:30:08 +0000 (12:30 +0100)
scripts/shairport-sync.freebsd

index 4e812dd00eb54322d338c9c067de0482612bb64e..0b74f95032027eb6be29ce451e8477aec0762015 100644 (file)
@@ -9,20 +9,16 @@
 name="shairport_sync"
 rcvar="shairport_sync_enable"
 
-start_cmd="${name}_start"
-stop_cmd="${name}_stop"
+# NOTE the difference between the service name shairport_sync and the application and script file names shairport-sync.
+# This seems to be necessary in FreeBSD, as the startup system doesn't seem to like dashes ("-") in service names.
 
-shairport_sync_start()
-{
-    checkyesno shairport_sync_enable && echo "Starting shairport-sync." && \
-    su -m shairport-sync -c "/usr/local/bin/shairport-sync -d"
-}
+pidfile="/var/run/shairport-sync.pid"
+apptodaemonise="/usr/local/bin/shairport-sync"
 
-shairport_sync_stop()
-{
-    checkyesno shairport_sync_enable && echo "Stopping shairport-sync." && \
-    /usr/local/bin/shairport-sync -k
-}
+command="/usr/sbin/daemon"
+# -S log to syslog; -P store the supervisor PID; -u to specify the user to run the service under
+command_args="-u shairport-sync -S -T shairport-sync -P ${pidfile} ${apptodaemonise}"
 
 load_rc_config $name
 run_rc_command "$1"
+