summaryrefslogtreecommitdiffstats
path: root/streams
diff options
context:
space:
mode:
Diffstat (limited to 'streams')
-rw-r--r--streams/Makefile11
-rw-r--r--streams/README10
-rwxr-xr-xstreams/stream-starter19
-rw-r--r--streams/stream.db5
-rwxr-xr-xstreams/streams122
5 files changed, 167 insertions, 0 deletions
diff --git a/streams/Makefile b/streams/Makefile
new file mode 100644
index 00000000..0922e38f
--- /dev/null
+++ b/streams/Makefile
@@ -0,0 +1,11 @@
+INITD = $(shell test -e /etc/rc.d/ && echo /etc/rc.d/ || echo /etc/init.d/)
+streams = $(shell cut -d\ -f2 stream.db)
+CURRDIR = ${PWD}
+.PHONY: all $(streams)
+
+all: $(streams)
+ @update-rc.d groove defaults 2>/dev/null || echo "** put groove daemon in DAEMONS in /etc/rc.conf"
+
+$(streams):
+ @test -L $(INITD)$@ || test ! -e $(INITD)$@ && \
+ ln -n -s -f $$PWD/stream-starter $(INITD)$@ && echo "writing $@ to $(INITD)"
diff --git a/streams/README b/streams/README
new file mode 100644
index 00000000..82300c24
--- /dev/null
+++ b/streams/README
@@ -0,0 +1,10 @@
+streams done right
+
+deepmix,groovesalad and radiotux are now init.d scrips which can be
+started and stopped.
+
+scripts are dumped into /etc/init.d and groovesalad will be set as
+default via update-rc.d
+
+mplayer will be started in a tmux session either by creating a new
+session or starting a new window inside the first existing one
diff --git a/streams/stream-starter b/streams/stream-starter
new file mode 100755
index 00000000..4d3a406f
--- /dev/null
+++ b/streams/stream-starter
@@ -0,0 +1,19 @@
+#! /bin/bash
+set -euf
+HERE=$(dirname $(readlink -f $0))
+STR=$HERE/streams
+NAME=`basename $0`
+case "$1" in
+ start)
+ $STR start $NAME
+ ;;
+ stop)
+ $STR stop
+ ;;
+ restart)
+ $STR restart $NAME
+ ;;
+ *)
+ echo "aidsballs"
+ ;;
+esac
diff --git a/streams/stream.db b/streams/stream.db
new file mode 100644
index 00000000..6ca9a627
--- /dev/null
+++ b/streams/stream.db
@@ -0,0 +1,5 @@
+http://somafm.com/groovesalad.pls groove
+http://deepmix.ru/deepmix128.pls deepmix
+http://streams.xenim.de/radiotux.ogg radiotux
+http://bassdrive.com/v2/streams/BassDrive.pls bassdrive
+http://somafm.com/illstreet.pls illstreet
diff --git a/streams/streams b/streams/streams
new file mode 100755
index 00000000..607fd9e5
--- /dev/null
+++ b/streams/streams
@@ -0,0 +1,122 @@
+#! /bin/bash
+HERE=$(dirname $(readlink -f $0))
+URLS=`cat $HERE/stream.db`
+CURRENT_STREAM="no stream" #will be set when calling `status`
+if [ ! `id -u` -eq "0" ]; then
+ exec sudo "$0" "$@"
+fi
+
+#if [ ! `id -u` -eq "0" ]; then
+# echo "we are going sudo..."
+# exec sudo "$0" "$@"
+#fi
+
+function start() {
+ # start the given stream von $1
+ REQ=$1
+ tmux start-server
+ if status &>/dev/null ; then
+ echo "!! Stream already running!"
+ exit 1
+ fi
+
+ if echo "$URLS" | while read URL NAME; do
+ if [ "$NAME" = "$REQ" ];then
+ tmux new-session -s streams -n streams -d "exec mplayer $URL"
+ echo "** $REQ started"
+ exit 1
+ fi
+ done; then
+ echo "!! Stream '$REQ' not found!"
+ exit 1
+ fi
+}
+function stop()
+{
+ #stops every stream
+ if status &>/dev/null; then
+ status | cut -d\ -f2 | xargs printf "** killing %s\n"
+ tmux kill-session -t streams 2>/dev/null || echo "!! killing session failed"
+ else
+ echo "** no stream running";
+ return 1
+ fi
+}
+
+function status()
+{
+ #tmux has-session -t streams 2>/dev/null
+ #RET=$?
+
+ #tmux list-sessions 2>/dev/null
+ #return $RET
+ EV="`ps -ef | grep mplayer`"
+ if echo "$URLS" | while read URL NAME; do
+ if [ "`echo "$EV" | grep \"$URL\"`" ] ;then
+ echo "** $NAME running ($URL)"
+ exit 1
+ fi
+ done; then
+ echo "** no stream running"
+ return 1
+ else
+ return 0
+ fi
+}
+function current()
+{
+
+ return 1
+}
+function list()
+{
+ echo "$URLS" | while read URL NAME ; do
+ echo "$NAME : $URL"
+ done
+
+}
+
+function shorthelp()
+{
+ echo "start|stop|restart|status|list [audio stream]"
+}
+function longhelp()
+{
+ B=`basename $0`
+ echo -n "Usage: $B "
+ shorthelp
+ echo " get all available streams with '/$B list'
+Examples:
+ $B list
+ $B start groove
+ $B restart deepmix
+ $B status
+ $B stop"
+}
+
+
+case "$1" in
+ start)
+ start $2
+ ;;
+ stop)
+ stop
+ ;;
+ (switch|restart)
+ stop
+ start $2
+ ;;
+ status)
+ status
+ exit $?
+ ;;
+ list)
+ list
+ ;;
+ (--help)
+ shorthelp
+ ;;
+ *)
+ longhelp
+ ;;
+esac