summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2003-06-25 12:13:50 +0000
committerivan <ivan>2003-06-25 12:13:50 +0000
commit4d94dfdf5171220e62511e48de6f36b97d5eadfb (patch)
treef96aa3c6cfb7db5c2b2d45915c0e14778d2e6e81
parent7d0906c0b1eb4df0a66371268317e07802abaa2b (diff)
commiting recent changesHEADmaster
-rw-r--r--README5
-rw-r--r--iceplex.conf4
-rw-r--r--plex.pls24
-rw-r--r--yashout26
4 files changed, 49 insertions, 10 deletions
diff --git a/README b/README
index 836545f..be56f95 100644
--- a/README
+++ b/README
@@ -23,9 +23,10 @@ On the central multiplexing server:
- Copy the example iceplex.conf to /etc/iceplex.conf and modify the settings
as appropriate:
- Database location/user/pass
- - Path to mp3 file storage on the icecast servers.
+ - Path to mp3 file storage on the icecast servers
- Icecast port number
- -
+ - Optional database query for file number override
+ - Normal database query for filen number
- Run iceplexd and configure your init scripts to start it upon boot.
- Create an "iceplex" user.
- Run "ssh-keygen -t dsa" as the "iceplex" user to genarate SSH keys.
diff --git a/iceplex.conf b/iceplex.conf
index 9018c84..a80ceab 100644
--- a/iceplex.conf
+++ b/iceplex.conf
@@ -6,8 +6,8 @@
#database connection info
$dsn = 'DBI:mysql:imedia';
-$user = 'imedia';
-$pass = 'imedia';
+$user = 'ivan';
+$pass = '';
#path to mp3 files on icecast servers
$mp3path = '/home/ivan/plexmp3';
diff --git a/plex.pls b/plex.pls
index b3f8d25..4c5ab47 100644
--- a/plex.pls
+++ b/plex.pls
@@ -8,12 +8,15 @@
# the same terms as Perl itself.
use strict;
-use subs qw(pick_server);
+use subs qw(suidsetup pick_server);
use CGI;
use CGI::Carp qw(fatalsToBrowser);
-use Digest::MD5;
+use Digest::MD5 qw(md5_hex);
+use DBI;
use Net::SSH qw(ssh);
+suidsetup();
+
# pull in configuration
use vars qw($dsn $user $pass $mp3path $port);
use vars qw($override_query $fileno_query);
@@ -61,21 +64,34 @@ my $filename = "$mp3path/$customer-$user-$fileno.mp3";
$dbh->disconnect;
#generate a mountpoint
-my $mountpoint = md5_hex($cgi->remote_host. $$. time. int(rand(4294967296)));
+md5_hex($cgi->remote_host. $$. time. int(rand(4294967296))) =~ /^(\w+)$/;
+my $mountpoint = $1;
#signal encoder to start streaming to mountpoint & wait for confirmation
+warn "ssh $server yashout $filename $mountpoint $port\n";
ssh($server, 'yashout', $filename, $mountpoint, $port );
#send file back to client browser
print $cgi->header( -type => $extension2type{$extension} );
-print "[playlist]\nNumberOfEntries=1\n" if $extension eq 'pls';
+print "[playlist]\nNumberOfEntries=1\nFile1=" if $extension eq 'pls';
print "http://$server:$port/$mountpoint\n";
###
# subroutiens
###
+sub suidsetup {
+ $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
+ $ENV{'SHELL'} = '/bin/sh';
+ $ENV{'IFS'} = " \t\n";
+ $ENV{'CDPATH'} = '';
+ $ENV{'ENV'} = '';
+ $ENV{'BASH_ENV'} = '';
+
+ $< = $>; #correct uid for spawned ssh process
+}
+
sub pick_server {
my $sth = $dbh->prepare(
"SELECT servername FROM iceplex_servers ".
diff --git a/yashout b/yashout
index 58868fc..87b5a91 100644
--- a/yashout
+++ b/yashout
@@ -12,8 +12,11 @@
use strict;
use subs qw(daemonize);
+use POSIX qw(:sys_wait_h setsid);
use Shout;
+my $encoder_password = 'haze420';
+
#read options from commandline
my($filename, $mountpoint, $port) = @ARGV;
@@ -21,21 +24,40 @@ my $conn = new Shout (
ip => 'localhost',
port => $port || 8000,
mount => $mountpoint,
+ password => $encoder_password,
icy_compat => 0,
dumpfile => undef,
name => 'Fonestream audio',
url => 'http://www.fonestream.com/',
genre => 'talk',
description => 'The easiest way to webcast.',
- bitrate => 64,
+ bitrate => 16,
ispublic => 0,
);
$conn->connect or die "Failed to connect: ". $conn->error;
+open(SFILE,"</home/ivan/plexmp3/silence.mp3") or die "Can't open silence.mp3: $!";
open(FILE,"<$filename") or die "Can't open $filename: $!";
daemonize(); #fork/disconnect so plex.pls will return to client
+if ( 0 ) {
+
+ #send silence header to server
+ my( $sbuffer, $sbytes ) = ( '', 0 );
+ while ( ( $sbytes = read( SFILE, $sbuffer, 4096 ) ) > 0 ) {
+ $conn->sendData( $sbuffer ) && next;
+ # error handling???
+ print STDERR "Error while sending: ", $conn->error, "\n";
+ last;
+ } continue {
+ $conn->sleep;
+ }
+
+}
+
+sleep 10;
+
#spool file to server
my( $buffer, $bytes ) = ( '', 0 );
while ( ( $bytes = read( FILE, $buffer, 4096 ) ) > 0 ) {
@@ -55,7 +77,7 @@ sub daemonize {
defined(my $pid = fork) or die "Can't fork: $!";
if ( $pid ) {
#print "yashout started with pid $pid\n"; #logging to $log_file\n";
- exit unless $pid_file;
+ #exit unless $pid_file;
#my $pidfh = new IO::File ">$pid_file" or exit;
#print $pidfh "$pid\n";
exit;