aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Meyer <dinoex@FreeBSD.org>2023-11-19 17:33:27 +0000
committerDirk Meyer <dinoex@FreeBSD.org>2023-11-19 17:33:27 +0000
commit1d7b2b3983c9ab9e4b9232b567625ceca3803b27 (patch)
treebea9286ac4cfdcce341fd66a52428d6efbceae37
parentdf331a6ad02866c7d26f79d287bf40c2f8678b06 (diff)
downloadports-1d7b2b3983c9ab9e4b9232b567625ceca3803b27.tar.gz
ports-1d7b2b3983c9ab9e4b9232b567625ceca3803b27.zip
audio/owntone: support for multiple profiles
Submitted by: Raivo Hool
-rw-r--r--audio/owntone/files/owntone.in66
1 files changed, 56 insertions, 10 deletions
diff --git a/audio/owntone/files/owntone.in b/audio/owntone/files/owntone.in
index c4209cf44a0c..0c4173e197e1 100644
--- a/audio/owntone/files/owntone.in
+++ b/audio/owntone/files/owntone.in
@@ -11,23 +11,69 @@
# Set it to YES to enable owntone.
# owntone_config (path): Set to %%PREFIX%%/etc/owntone.conf
# by default.
-# owntone_flags (str): Set to "" by default
+# owntone_flags (str): Set to "" by default
+#
+# for mutiple profiles create an symlink
+# cd %%PREFIX%%/etc/rc.d/ && ln -s owntone NAME
+# and set this lines:
+#
+# NAME_enable (bool): Set to NO by default.
+# Set it to YES to enable owntone.
+# NAME_config="/usr/local/etc/owntone/NAME.conf" # config file
+# NAME_flags (str): Set to "" by default
. /etc/rc.subr
-name=owntone
+# service(8) does not create an authentic environment, try to guess,
+# and as of 10.3-RELEASE-p0, it will not find the indented name
+# assignments below. So give it a default.
+# Trailing semicolon also for service(8)'s benefit:
+name="$file" ;
+rcvar=${name}_enable
+
+case "$0" in
+/etc/rc*)
+ # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
+ # so get the name of the script from $_file
+ name="$_file"
+ ;;
+*/service)
+ # do not use this as $0
+ ;;
+*)
+ name="$0"
+ ;;
+esac
+
+# default name to "owntone" if guessing failed
+# Trailing semicolon also for service(8)'s benefit:
+name="${name:-owntone}" ;
+name="${name##*/}"
rcvar=${name}_enable
-load_rc_config $name
+stop_postcmd()
+{
+ rm -f "$pidfile" || warn "Could not remove $pidfile."
+}
+
+# pidfile
+pidfile="/var/run/${name}.pid"
+
+# command and arguments
+command="/usr/local/sbin/owntone"
+
+# run this last
+stop_postcmd="stop_postcmd"
+
+load_rc_config ${name}
+eval ": \${${name}_enable:=\"NO\"}"
+eval ": \${${name}_config:=\"/usr/local/etc/${name}.conf\"}"
-: ${owntone_enable:="NO"}
-: ${owntone_config:="%%PREFIX%%/etc/owntone.conf"}
-: ${owntone_flags:=""}
+config="$(eval echo \${${name}_config})"
+flags="$(eval echo \${${name}_flags})"
-pidfile="/var/run/owntone.pid"
-required_files="$owntone_config"
+required_files=${config}
-command="%%PREFIX%%/sbin/owntone"
-command_args="-P $pidfile -c $owntone_config $owntone_flags"
+command_args="-P ${pidfile} -c ${config} ${flags}"
run_rc_command "$1"