From 7c4cea71203f409a2c286728dc8bd8b8c104443d Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 3 Aug 2011 23:55:36 +0200 Subject: finished protype of streams streams/streams: runs given streams by name with zsh start|stop|restart|status|list [streamname] the Makefile has yet to be fixed for that one streams/groove: uses streams to start|stop|restart groovesalad stream --- streams/groove | 19 +++------------ streams/streams | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 15 deletions(-) create mode 100755 streams/streams (limited to 'streams') diff --git a/streams/groove b/streams/groove index 935a16d9..8c2faddd 100755 --- a/streams/groove +++ b/streams/groove @@ -1,25 +1,14 @@ #! /bin/bash set -euf -CMD="exec mplayer http://somafm.com/groovesalad.pls" -function start() { - stop - tmux start-server - tmux new-session -d "$CMD" -} -function stop() -{ - pkill mplayer || : -} - +STR=$PWD/streams case "$1" in start) - start + $STR start groove stop) - stop + $STR stop ;; restart) - stop - start + $STR restart groove ;; *) echo "aidsballs" diff --git a/streams/streams b/streams/streams new file mode 100755 index 00000000..f3cbc300 --- /dev/null +++ b/streams/streams @@ -0,0 +1,76 @@ +#! /bin/sh +URLS="http://somafm.com/groovesalad.pls groove +http://deepmix.ru/deepmix128.pls deepmix +http://streams.xenim.de/radiotux.ogg radiotux" + +function start() { + # start the given stream von $1 + REQ=$1 + tmux start-server + if status; 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 not found!" + exit 1 + fi +} +function stop() +{ + #stops every stream + tmux kill-session -t streams || echo "!! killing session failed" +} + +function status() +{ + tmux has-session -t streams 2>/dev/null + RET=$? + tmux list-sessions 2>/dev/null + return $RET +} +function list() +{ + echo "$URLS" | while read URL NAME ; do + echo "$NAME : $URL" + done + +} + + + + +case "$1" in + start) + start $2 + ;; + stop) + stop + ;; + restart) + stop + start $2 + ;; + status) + if status; then + echo "** stream running" + exit 0 + else + echo "** Stream not running" + exit 1 + fi + ;; + list) + list + ;; + *) + echo "aidsballs" + ;; +esac -- cgit v1.2.3