version 1.1, 2005/03/24 05:28:08 |
version 1.6, 2005/04/07 00:00:31 |
|
|
use lib 'lib'; |
use lib 'lib'; |
use OpenBSDTorrents; |
use OpenBSDTorrents; |
|
|
|
use POSIX 'setsid'; |
|
|
%ENV = (); |
%ENV = (); |
|
|
use YAML; |
use YAML; |
|
|
|
# *** This requires --log-format="%t [%p] %o %f %l" on the rsync command |
|
|
my $last_dir = ''; |
my $last_dir = ''; |
while (<>) { |
while (<>) { |
chomp; |
chomp; |
|
|
my ($dir, $file) = $file =~ m#^(.*)/([^/]+)#; |
my ($dir, $file) = $file =~ m#^(.*)/([^/]+)#; |
#print "$dir - $file\n"; |
#print "$dir - $file\n"; |
if ($last_dir && $last_dir ne $dir) { |
if ($last_dir && $last_dir ne $dir) { |
# This actually needs to be a sub that forks off |
StartTorrent($last_dir); |
# the generation of this, and the running of the update script. |
|
print "MakeTorrent.pl $BaseName/$dir\n"; |
|
} |
} |
$last_dir = $dir; |
$last_dir = $dir; |
} else { |
} else { |
#print $_; |
#print $_; |
} |
} |
|
} |
|
StartTorrent($last_dir); |
|
|
|
sleep(300); |
|
|
|
StartTorrent('skip'); |
|
|
|
|
|
sub StartTorrent |
|
{ |
|
my $dir = shift; |
|
return undef unless $dir; |
|
|
|
if ($dir ne 'skip') { |
|
$dir = $OBT->{BASENAME} . "/$dir"; |
|
} else { |
|
$dir = ''; |
|
} |
|
|
|
# This actually needs to be a sub that forks off |
|
# the generation of this, and the running of the update script. |
|
|
|
#defined(my $pid = fork) or die "Can't fork: $!"; |
|
|
|
#return if $pid; |
|
|
|
#chdir $HomeDir or die "Can't chdir to $HomeDir: $!"; |
|
|
|
#setsid or die "Can't start a new session: $!"; |
|
##open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; |
|
##open STDOUT, '>/dev/null' |
|
## or die "Can't write /dev/null: $!"; |
|
##open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; |
|
|
|
print "Making torrents for $dir\n"; |
|
exec($OBT->{DIR_HOME} . '/regen.sh' . " $dir &"); |
|
#exec($HomeDir . '/regen.sh', "$dir"); |
} |
} |