OpenWrt/Music: Difference between revisions

From Wiki
No edit summary
No edit summary
Line 14: Line 14:
<pre>
<pre>
mkdir /etc/scripts
mkdir /etc/scripts
touch madplay.sh
touch /etc/scripts/madplay.sh
chmod madplay.sh +x
chmod /etc/scripts/madplay.sh +x
vi madplay.sh
vi /etc/scripts/madplay.sh
</pre>
</pre>
</blockquote>
</blockquote>


== madplay.sh ==
== /etc/scripts/madplay.sh ==
<blockquote>
<blockquote>
<pre>
<pre>
Line 30: Line 30:
     sleep 30
     sleep 30
  done
  done
</pre>
</blockquote>
== create madplay init.d script ==
<blockquote>
<pre>
touch /etc/init.d/madplay
chmod /etc/init.d/madplay +x
vi /etc/init.d/madplay.sh
</pre>
</blockquote>
== /etc/init.d/madplay ==
<blockquote>
<pre>
#!/bin/sh /etc/rc.common
# madplay script
START=99
DAEMON=/etc/scripts/madplay.sh
DAEMONNAME=madplay
PIDFILE=/var/run/madplay.pid
start() {
echo waiting 1s
sleep 1 
echo -n "starting: $DAEMONNAME"
if [ -f $PIDFILE ] ; then
  echo
  echo "$DAEMONNAME already running (PID=`cat $PIDFILE`)"
  exit
fi
touch $PIDFILE
start-stop-daemon -S -p $PIDFILE -m -b -x $DAEMON
echo "(PID=`cat $PIDFILE`)"
}
stop() {
if [ ! -f $PIDFILE ] ; then
  echo "$DAEMONNAME is not running"
  exit
fi
PID=`cat $PIDFILE`
echo "stopping: $DAEMONNAME(PID=$PID)"
kill -INT $PID
pkill -INT -P $PID
rm -f $PIDFILE
}
</pre>
</pre>
</blockquote>
</blockquote>

Revision as of 18:17, 27 September 2012

OpenWrt music streaming

Streaming music via OpenWrt on 4MB flash router

Install packages

opkg update
opkg install kmod-usb-audio kmod-usb-ohci kmod-usb-core kmod-sound-core madplay

create "madplay.sh"

mkdir /etc/scripts
touch /etc/scripts/madplay.sh
chmod /etc/scripts/madplay.sh +x
vi /etc/scripts/madplay.sh

/etc/scripts/madplay.sh

#! /bin/sh

while true
 do
    wget -O - http://192.168.111.10:8000 | madplay -
    sleep 30
 done

create madplay init.d script

touch /etc/init.d/madplay
chmod /etc/init.d/madplay +x
vi /etc/init.d/madplay.sh

/etc/init.d/madplay

#!/bin/sh /etc/rc.common
# madplay script

START=99

DAEMON=/etc/scripts/madplay.sh
DAEMONNAME=madplay
PIDFILE=/var/run/madplay.pid

start() {
	echo waiting 1s
	sleep 1  
	
	echo -n "starting: $DAEMONNAME" 

	if [ -f $PIDFILE ] ; then
	   echo
	   echo "$DAEMONNAME already running (PID=`cat $PIDFILE`)"
	   exit
	fi	

	touch $PIDFILE
	start-stop-daemon -S -p $PIDFILE -m -b -x $DAEMON
	echo "(PID=`cat $PIDFILE`)"
}

stop() {
	if [ ! -f $PIDFILE ] ; then
	   echo "$DAEMONNAME is not running"
	   exit
	fi

	PID=`cat $PIDFILE`
	echo "stopping: $DAEMONNAME(PID=$PID)"
		
	kill -INT $PID
	pkill -INT -P $PID

	rm -f $PIDFILE
}