aboutsummaryrefslogtreecommitdiff
path: root/audio/linux-musicipserver
diff options
context:
space:
mode:
authorGiuseppe Pilichi <jacula@FreeBSD.org>2010-08-08 13:36:48 +0000
committerGiuseppe Pilichi <jacula@FreeBSD.org>2010-08-08 13:36:48 +0000
commit0a313e7621f712ed690878ac3928271046e0a0bb (patch)
treeb49593b91922c436853708d00c4abe7bff9452e4 /audio/linux-musicipserver
parent130ba0dabf13b16b7c15f658a447d52ebe6f126b (diff)
downloadports-0a313e7621f712ed690878ac3928271046e0a0bb.tar.gz
ports-0a313e7621f712ed690878ac3928271046e0a0bb.zip
Notes
Diffstat (limited to 'audio/linux-musicipserver')
-rw-r--r--audio/linux-musicipserver/Makefile91
-rw-r--r--audio/linux-musicipserver/distinfo6
-rw-r--r--audio/linux-musicipserver/files/musicipserver.in191
-rw-r--r--audio/linux-musicipserver/files/pkg-deinstall.in25
-rw-r--r--audio/linux-musicipserver/files/pkg-install.in120
-rw-r--r--audio/linux-musicipserver/files/recipes.xml.sample4
-rw-r--r--audio/linux-musicipserver/pkg-descr3
-rw-r--r--audio/linux-musicipserver/pkg-plist16
8 files changed, 456 insertions, 0 deletions
diff --git a/audio/linux-musicipserver/Makefile b/audio/linux-musicipserver/Makefile
new file mode 100644
index 000000000000..145266972736
--- /dev/null
+++ b/audio/linux-musicipserver/Makefile
@@ -0,0 +1,91 @@
+# New ports collection makefile for: musicipserver
+# Date created: 2009-03-24
+# Whom: Christopher Key <cjk32@cam.ac.uk>
+#
+# $FreeBSD$
+#
+
+PORTNAME= musicipserver
+PORTVERSION= 1.8
+CATEGORIES= audio linux
+MASTER_SITES= http://www.amplifindmusicservices.com/downloads/:musicip \
+ http://spicefly.com/images/file/:spicefly
+PKGNAMEPREFIX= linux-
+DISTNAME= MusicMixer_x86_${PORTVERSION}
+DISTFILES= ${DISTNAME}.tgz:musicip
+DIST_SUBDIR= musicip
+EXTRACT_ONLY= ${DISTNAME}.tgz
+
+MAINTAINER= cjk32@cam.ac.uk
+COMMENT= Application for generating playlists based upon musical content
+
+RUN_DEPENDS= empty:${PORTSDIR}/net/empty \
+ flog:${PORTSDIR}/sysutils/flog \
+ ${LOCALBASE}/libexec/mipcore:${PORTSDIR}/audio/linux-genpuid
+
+OPTIONS= SPICEFLY_SKIN "Install Spicefly skin" on
+
+WRKSRC= ${WRKDIR}/MusicIP/MusicMagicMixer/
+
+USE_RC_SUBR= musicipserver
+USE_LINUX= yes
+NO_BUILD= yes
+IA32_BINARY_PORT= yes
+
+LICENSE= EULA
+LICENSE_PERMS= dist-mirror pkg-mirror auto-accept
+LICENSE_NAME= END-USER LICENSE AGREEMENT FOR MUSICIP MIXER
+LICENSE_FILE= ${WRKSRC}/notes.txt
+LICENSE_DISTFILES= ${DISTNAME}.tgz
+
+MUSICIPSERVERDBDIR?= /var/db/${PORTNAME}
+MUSICIPSERVERLOGDIR?= /var/log/${PORTNAME}
+MUSICIPSERVERRUNDIR?= /var/run/${PORTNAME}
+
+MUSICIPSERVERUSER?= mipserv
+MUSICIPSERVERGROUP?= ${MUSICIPSERVERUSER}
+
+SUB_FILES= pkg-install pkg-deinstall
+SUB_LIST= PORTNAME=${PORTNAME} \
+ MUSICIPSERVERDBDIR=${MUSICIPSERVERDBDIR} \
+ MUSICIPSERVERLOGDIR=${MUSICIPSERVERLOGDIR} \
+ MUSICIPSERVERRUNDIR=${MUSICIPSERVERRUNDIR} \
+ MUSICIPSERVERUSER=${MUSICIPSERVERUSER} \
+ MUSICIPSERVERGROUP=${MUSICIPSERVERGROUP}
+PLIST_SUB= MUSICIPSERVERDBDIR=${MUSICIPSERVERDBDIR} \
+ MUSICIPSERVERLOGDIR=${MUSICIPSERVERLOGDIR} \
+ MUSICIPSERVERRUNDIR=${MUSICIPSERVERRUNDIR}
+
+.include <bsd.port.options.mk>
+
+.if defined(WITH_SPICEFLY_SKIN) && !defined(WITHOUT_SPICEFLY_SKIN)
+EXTRACT_DEPENDS+= unzip:${PORTSDIR}/archivers/unzip
+DISTFILES+= index-1.1.zip:spicefly
+.endif
+
+.if defined(WITH_SPICEFLY_SKIN) && !defined(WITHOUT_SPICEFLY_SKIN)
+post-extract:
+ @cd ${WRKDIR} && ${UNZIP_CMD} -qo ${_DISTDIR}/index-1.1.zip -d ${WRKDIR}/spicefly
+.endif
+
+pre-install:
+ @PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+
+do-install:
+ @${INSTALL_PROGRAM} ${WRKSRC}/MusicMagicServer ${PREFIX}/bin
+ @${MKDIR} ${DATADIR}
+ @${LN} -fhs ${LOCALBASE}/libexec/mipcore ${DATADIR}/mipcore
+.if defined(WITH_SPICEFLY_SKIN) && !defined(WITHOUT_SPICEFLY_SKIN)
+ @${MKDIR} ${DATADIR}/server
+ @${INSTALL_DATA} ${WRKDIR}/spicefly/index.html ${DATADIR}/server
+.else
+ @cd ${WRKSRC} && ${COPYTREE_SHARE} server ${DATADIR}
+.endif
+ @${MKDIR} ${EXAMPLESDIR}
+ @${INSTALL_DATA} ${WRKSRC}/mmm.ini ${EXAMPLESDIR}/mmm.ini.sample
+ @${INSTALL_DATA} ${FILESDIR}/recipes.xml.sample ${EXAMPLESDIR}/recipes.xml.sample
+
+post-install:
+ @PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+
+.include <bsd.port.mk>
diff --git a/audio/linux-musicipserver/distinfo b/audio/linux-musicipserver/distinfo
new file mode 100644
index 000000000000..faa807ea7d1d
--- /dev/null
+++ b/audio/linux-musicipserver/distinfo
@@ -0,0 +1,6 @@
+MD5 (musicip/MusicMixer_x86_1.8.tgz) = cc8d9945251b94c16fcb7b9443743008
+SHA256 (musicip/MusicMixer_x86_1.8.tgz) = 05394616166356b9f919a645cd6cd363388349be5790b8775c584a005db258b9
+SIZE (musicip/MusicMixer_x86_1.8.tgz) = 4610204
+MD5 (musicip/index-1.1.zip) = d93ee17e75cfa2e1f8d96fe650abd6ca
+SHA256 (musicip/index-1.1.zip) = b114ae63241423fb73051f4c9d6dfe5b6f7e8ae63c2535ace6e4a0516b86a0d8
+SIZE (musicip/index-1.1.zip) = 1971
diff --git a/audio/linux-musicipserver/files/musicipserver.in b/audio/linux-musicipserver/files/musicipserver.in
new file mode 100644
index 000000000000..351b316f312a
--- /dev/null
+++ b/audio/linux-musicipserver/files/musicipserver.in
@@ -0,0 +1,191 @@
+#!/bin/sh
+#
+# $Id: musicipserver.in 2458 2010-07-21 11:52:43Z chris $
+#
+
+# PROVIDE: musicipserver
+# BEFORE: squeezeboxserver
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable musicipserver:
+#
+#musicipserver_enable="YES"
+#
+
+. /etc/rc.subr
+
+name="%%PORTNAME%%"
+procname="%%PREFIX%%/bin/MusicMagicServer"
+status_cmd="${name}_status_cmd"
+start_cmd="${name}_start_cmd"
+stop_cmd="${name}_stop_cmd"
+
+examplesdir="%%EXAMPLESDIR%%"
+datadir="%%DATADIR%%"
+logdir="%%MUSICIPSERVERLOGDIR%%"
+rundir="%%MUSICIPSERVERRUNDIR%%"
+statedir="%%MUSICIPSERVERDBDIR%%"
+
+serverlogfile=${logdir}/server.log
+mipcorelogfile=${logdir}/mipcore.log
+pidfile=${rundir}/${name}.pid
+serverflogpidfile=${rundir}/${name}-server-flog.pid
+mipcoreflogpidfile=${rundir}/${name}-mipcore-flog.pid
+mipcoretailpidfile=${rundir}/${name}-mipcore-tail.pid
+serverinfifo=${rundir}/${name}-fifo-in
+serveroutfifo=${rundir}/${name}-fifo-out
+mipcorelogfifo=${rundir}/${name}-mipcore-fifo
+
+empty="%%LOCALBASE%%/bin/empty"
+flog="%%LOCALBASE%%/bin/flog"
+tail="/usr/bin/tail"
+
+load_rc_config $name
+musicip_enable=${musicip_enable:-"NO"}
+musicip_user="%%MUSICIPSERVERUSER%%"
+musicip_group="%%MUSICIPSERVERGROUP%%"
+musicip_port="10002" # Should probably pull this in from mmm.ini
+
+musicipserver_check_pidfile()
+{
+ check_pidfile ${pidfile} ${empty}
+}
+
+musicipserver_status_cmd()
+{
+
+ pid=$(musicipserver_check_pidfile)
+
+ if [ -n "${pid}" ]; then
+ echo "${name} is running as pid ${pid}."
+ else
+ echo "${name} is not running."
+ return 1
+ fi
+}
+
+musicipserver_start_cmd()
+{
+ # Check whether we're already running
+ pid=$(musicipserver_check_pidfile)
+
+ if [ -n "${pid}" ]; then
+ echo "${name} already running? (pid=${pid})."
+ return 1
+ fi
+
+ echo "Starting ${name}."
+
+ # MusicIP server will fail to start if there are any sockets still active on port 10002.
+ waited=0
+ while netstat -n \
+ | egrep "^tcp4 +[[:digit:]]+ +[[:digit:]]+ +([[:digit:]]+\.){4}$musicip_port +([[:digit:]]+\.){4}[[:digit:]]+ +TIME_WAIT\$" \
+ > /dev/null; do
+
+ if [ $waited = 0 ]; then
+ echo -n "Waiting on sockets"
+ waited=1
+ else
+ echo -n "."
+ fi
+
+ sleep 1
+ done
+
+ if [ $waited = 1 ]; then
+ echo "."
+ fi
+
+
+ mkfifo ${mipcorelogfifo} \
+ && chown ${musicip_user}:${musicip_group} ${mipcorelogfifo} \
+ && chmod 600 ${mipcorelogfifo}
+
+ daemon -c -f -p ${mipcoretailpidfile} -u ${musicip_user} \
+ "sh" "-c" "exec ${tail} -f ${statedir}/log.txt > ${mipcorelogfifo}"
+
+ daemon -c -f -p ${mipcoreflogpidfile} -u ${musicip_user} \
+ "sh" "-c" "exec ${flog} -t -T '%b %d %T ' ${mipcorelogfile} < ${mipcorelogfifo}"
+
+ su -m ${musicip_user} -c \
+ "cd / && < /dev/null >& /dev/null ${empty} -f -i ${serverinfifo} -o ${serveroutfifo} -p ${pidfile} ${procname} -exec ${datadir} -data ${statedir} -verbose -logex start" \
+ && chmod -x ${serverinfifo} ${serveroutfifo} ${pidfile}
+
+ daemon -c -f -p ${serverflogpidfile} -u ${musicip_user} \
+ "sh" "-c" "exec ${flog} -t -T '%b %d %T ' ${serverlogfile} < ${serveroutfifo}"
+
+
+ # "MusicMagicServer start" either exits is there is an error, or forks is there isn't.
+ # To check whether musicipserver starter successfully, we watch the 'empty' process we
+ # created, using its pidfile. If it disappears, we know that musicipserver failed, else
+ # if it two or more child processes, we know it started successfully.
+
+ while true; do
+
+ pid=$(musicipserver_check_pidfile)
+
+ if [ -z "${pid}" ]; then
+ echo "${name} failed to start."
+ _musicipserver_stop_cmd
+ return 1
+ break;
+ elif [ $(pgrep -P ${pid} | wc -l) -gt 1 ]; then
+ break
+ fi
+
+ sleep 1
+
+ done
+
+}
+
+musicipserver_stop_cmd()
+{
+
+ echo "Stopping ${name}."
+
+ _musicipserver_stop_cmd
+
+}
+
+_musicipserver_stop_cmd()
+{
+
+ pid=$(musicipserver_check_pidfile)
+ if [ -n "${pid}" ]; then
+ su -m ${musicip_user} -c "${procname} stop" > /dev/null 2>&1 \
+ && wait_for_pids ${pid}
+ fi
+
+
+ pid=$(check_pidfile ${serverflogpidfile} ${flog})
+ if [ -n "{$pid}" ]; then
+ kill ${pid} > /dev/null 2>&1 \
+ && wait_for_pids ${pid} \
+ && rm ${serverflogpidfile}
+ fi
+
+ pid=$(check_pidfile ${mipcoretailpidfile} ${tail})
+ if [ -n "{$pid}" ]; then
+ kill ${pid} > /dev/null 2>&1 \
+ && wait_for_pids ${pid} \
+ && rm ${mipcoretailpidfile}
+
+ fi
+
+ pid=$(check_pidfile ${mipcoreflogpidfile} ${flog})
+ if [ -n "{$pid}" ]; then
+ kill ${pid} > /dev/null 2>&1 \
+ && wait_for_pids ${pid} \
+ && rm ${mipcoreflogpidfile}
+ fi
+
+ if [ -p ${mipcorelogfifo} ]; then
+ rm ${mipcorelogfifo}
+ fi
+
+}
+
+run_rc_command "$1"
diff --git a/audio/linux-musicipserver/files/pkg-deinstall.in b/audio/linux-musicipserver/files/pkg-deinstall.in
new file mode 100644
index 000000000000..217de0bad448
--- /dev/null
+++ b/audio/linux-musicipserver/files/pkg-deinstall.in
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+if [ "$2" != "POST-DEINSTALL" ]; then
+ exit 0
+fi
+
+MUSICIPSERVERUSER=%%MUSICIPSERVERUSER%%
+
+echo
+echo "============================================================"
+echo
+echo "If you want remove musicipserver permanently from you system"
+echo "execute following commands:"
+echo
+echo " # rm -rf %%MUSICIPSERVERLOGDIR%%"
+echo " # rm -rf %%MUSICIPSERVERRUNDIR%%"
+echo " # rm -rf %%MUSICIPSERVERDBDIR%%"
+if pw usershow "%%MUSICIPSERVERUSER%%" 2>/dev/null 1>&2; then
+ echo " # pw userdel %%MUSICIPSERVERUSER%%"
+fi
+echo
+echo "============================================================"
+echo
+
+exit 0
diff --git a/audio/linux-musicipserver/files/pkg-install.in b/audio/linux-musicipserver/files/pkg-install.in
new file mode 100644
index 000000000000..0b1cb349c612
--- /dev/null
+++ b/audio/linux-musicipserver/files/pkg-install.in
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+name=%%PORTNAME%%
+examplesdir=%%EXAMPLESDIR%%
+datadir=%%DATADIR%%
+logdir=%%MUSICIPSERVERLOGDIR%%
+rundir=%%MUSICIPSERVERRUNDIR%%
+statedir=%%MUSICIPSERVERDBDIR%%
+
+serverlogfile=${logdir}/server.log
+mipcorelogfile=${logdir}/mipcore.log
+pidfile=${rundir}/${name}.pid
+serverflogpidfile=${rundir}/${name}-server-flog.pid
+mipcoreflogpidfile=${rundir}/${name}-mipcore-flog.pid
+mipcoretailpidfile=${rundir}/${name}-mipcore-tail.pid
+serverinfifo=${rundir}/${name}-fifo-in
+serveroutfifo=${rundir}/${name}-fifo-out
+mipcorelogfifo=${rundir}/${name}-mipcore-fifo
+
+u=%%MUSICIPSERVERUSER%%
+g=%%MUSICIPSERVERGROUP%%
+ugid=10002
+homedir=/nonexistent
+shell=/sbin/nologin
+comment="MusicIP pseudo-user"
+
+newsyslogfile=/etc/newsyslog.conf
+logcomment="# added by audio/${name} port"
+serverlogline="${serverlogfile} ${u}:${g} 644 3 100 * J ${serverflogpidfile}"
+mipcorelogline="${mipcorelogfile} ${u}:${g} 644 3 100 * J ${mipcoreflogpidfile}"
+
+case $2 in
+PRE-INSTALL)
+ if pw group show "${g}" >/dev/null 2>&1; then
+ echo "Using existing group \"${g}\"."
+ else
+ echo "Creating group \"${g}\", (gid: ${ugid})."
+ pw groupadd ${g} -g ${ugid}
+ if [ $? != 0 ]; then
+ echo "Failed to add group \"${g}\"."
+ exit 1
+ fi
+ fi
+ if pw user show "${u}" >/dev/null 2>&1; then
+ echo "Using existing user \"${u}\"."
+ else
+ echo "Creating user \"${u}\", (uid: ${ugid})."
+ pw useradd ${u} -u ${ugid} -g ${ugid} -h - \
+ -d ${homedir} -s ${shell} -c "${comment}"
+ if [ $? != 0 ]; then
+ echo "Failed to add user \"${u}\"."
+ exit 1
+ fi
+ fi
+ ;;
+POST-INSTALL)
+ if egrep -q "^${serverlogfile}\>" ${newsyslogfile}; then
+ echo "Using existing ${serverlogfile} entry in ${newsyslogfile}."
+ else
+ echo "Adding ${serverlogfile} entry to ${newsyslogfile}."
+ echo "$logcomment" >> ${newsyslogfile}
+ echo "$serverlogline" >> ${newsyslogfile}
+ fi
+
+ if egrep -q "^${mipcorelogfile}\>" ${newsyslogfile}; then
+ echo "Using existing ${mipcorelogfile} entry in ${newsyslogfile}."
+ else
+ echo "Adding ${mipcorelogfile} entry to ${newsyslogfile}."
+ echo "$logcomment" >> ${newsyslogfile}
+ echo "$mipcorelogline" >> ${newsyslogfile}
+ fi
+
+ if [ ! -d ${logdir} ]; then
+ mkdir ${logdir}
+ chown ${u}:${g} ${logdir}
+ chmod 755 ${logdir}
+ fi
+ if [ ! -d ${rundir} ]; then
+ mkdir ${rundir}
+ chown ${u}:${g} ${rundir}
+ chmod 755 ${rundir}
+ fi
+ if [ ! -d ${statedir} ]; then
+ mkdir ${statedir}
+ chown ${u}:${g} ${statedir}
+ chmod 755 ${statedir}
+ fi
+
+ if [ ! -f ${serverlogfile} ]; then
+ touch ${serverlogfile}
+ chown ${u}:${g} ${serverlogfile}
+ chmod 644 ${serverlogfile}
+ fi
+
+ if [ ! -f ${mipcorelogfile} ]; then
+ touch ${mipcorelogfile}
+ chown ${u}:${g} ${mipcorelogfile}
+ chmod 644 ${mipcorelogfile}
+ fi
+
+ if [ ! -p ${statedir}/log.txt ]; then
+ mkfifo ${statedir}/log.txt
+ chown ${u}:${g} ${statedir}/log.txt
+ chmod 644 ${statedir}/log.txt
+ fi
+
+ if [ ! -e ${statedir}/mmm.ini ]; then
+ cp ${examplesdir}/mmm.ini.sample ${statedir}/mmm.ini
+ chown ${u}:${g} ${statedir}/mmm.ini
+ chmod 644 ${statedir}/mmm.ini
+ fi
+
+ if [ ! -e ${statedir}/recipes.xml ]; then
+ cp ${examplesdir}/recipes.xml.sample ${statedir}/recipes.xml
+ chown ${u}:${g} ${statedir}/recipes.xml
+ chmod 644 ${statedir}/recipes.xml
+ fi
+
+ ;;
+esac
diff --git a/audio/linux-musicipserver/files/recipes.xml.sample b/audio/linux-musicipserver/files/recipes.xml.sample
new file mode 100644
index 000000000000..76338ed8e705
--- /dev/null
+++ b/audio/linux-musicipserver/files/recipes.xml.sample
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<recipe name="Sample Recipe">
+<constraint>0</constraint>
+</recipe>
diff --git a/audio/linux-musicipserver/pkg-descr b/audio/linux-musicipserver/pkg-descr
new file mode 100644
index 000000000000..4251235b8f47
--- /dev/null
+++ b/audio/linux-musicipserver/pkg-descr
@@ -0,0 +1,3 @@
+This is an application for generating playlists based upon musical content.
+
+WWW: http://www.amplifiedmusicservices.com/
diff --git a/audio/linux-musicipserver/pkg-plist b/audio/linux-musicipserver/pkg-plist
new file mode 100644
index 000000000000..8aa0da01771a
--- /dev/null
+++ b/audio/linux-musicipserver/pkg-plist
@@ -0,0 +1,16 @@
+bin/MusicMagicServer
+%%EXAMPLESDIR%%/mmm.ini.sample
+%%EXAMPLESDIR%%/recipes.xml.sample
+%%DATADIR%%/mipcore
+%%DATADIR%%/server/index.html
+@unexec if cmp -s %%MUSICIPSERVERDBDIR%%/mmm.ini %D/%%EXAMPLESDIR%%/mmm.ini.sample; then rm -f %%MUSICIPSERVERDBDIR%%/mmm.ini; fi
+@unexec if cmp -s %%MUSICIPSERVERDBDIR%%/recipes.xml %D/%%EXAMPLESDIR%%/recipes.xml.sample; then rm -f %%MUSICIPSERVERDBDIR%%/recipes.xml; fi
+@unexec rm -f %%MUSICIPSERVERDBDIR%%/log.txt
+@cwd /
+@dirrmtry %%MUSICIPSERVERDBDIR%%
+@dirrmtry %%MUSICIPSERVERLOGDIR%%
+@dirrmtry %%MUSICIPSERVERRUNDIR%%
+@cwd
+@dirrm %%DATADIR%%/server
+@dirrm %%DATADIR%%
+@dirrm %%EXAMPLESDIR%%