summaryrefslogtreecommitdiffstats
path: root/streams/streams
blob: f3cbc300130d4c70bdca2afc38f949605c479d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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