Statistics
| Branch: | Tag: | Revision:

dvbd / utils / cgi / streammusic.cgi @ 723fa73a

History | View | Annotate | Download (1.28 KB)

1
#!/usr/bin/perl
2
use CGI;
3
use POSIX 'setsid';
4

    
5
%stations=('music1' => "http://www.m1live.com/listen/musicone_hi.pls",
6
	   'groovesalad' => "http://www.somafm.com/groovesalad.pls",
7
	   'secretagent' => "http://www.somafm.com/secretagent.pls",
8
	   'rfi' => "http://www.tv-radio.com/ondemand/rfi/mere/francais/../../../../station/rfi/rfi-20k.asx",
9
	   'userdef' => "userdef" );
10
	   
11
$q = new CGI;
12
print $q->header;
13
print "<pre>";
14
$station = $q->param('station');
15
if ($station eq "userdef") { 
16
	$stationurl= $q->param('stationurl');
17
}
18
else {
19
	$stationurl = $stations{$station};
20
}
21
unless (defined($stationurl)) {
22
    print("<pre>Unknown station $station (edit streammusic.cgi to add)</pre>");
23
    exit 1;
24
}
25

    
26
print "<pre>Play Web $station from $stationurl...\n</pre>";
27
$SIG{'CHLD'}="IGNORE";
28
if (fork() == 0) {
29
    daemonize();
30
    exec("/home/jak/bin/streammusic", $stationurl);
31
}
32

    
33
sub daemonize {
34
    chdir '/'               or die "Can't chdir to /: $!";
35
    open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
36
    open STDOUT, '>/dev/null'
37
		   or die "Can't write to /dev/null: $!";
38
    defined(my $pid = fork) or die "Can't fork: $!";
39
    exit if $pid;
40
    setsid                  or die "Can't start a new session: $!";
41
    open STDERR, '>&STDOUT' or die "Can't dup http://www.somafm.com/secstdout: $!";
42
}
43