version 1.2, 2005/03/24 05:32:49 |
version 1.4, 2005/03/28 23:36:44 |
|
|
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; |
|
|
} |
} |
StartTorrent($last_dir); |
StartTorrent($last_dir); |
|
|
|
sleep(300); |
|
|
|
StartTorrent('skip'); |
|
|
|
|
sub StartTorrent |
sub StartTorrent |
{ |
{ |
my $dir = shift; |
my $dir = shift; |
|
return undef unless $dir; |
|
|
|
if ($dir ne 'skip') { |
|
$dir = "$BaseName/$dir"; |
|
} else { |
|
$dir = ''; |
|
} |
|
|
# This actually needs to be a sub that forks off |
# This actually needs to be a sub that forks off |
# the generation of this, and the running of the update script. |
# the generation of this, and the running of the update script. |
print "MakeTorrents.pl $BaseName/$dir\n"; |
|
|
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($HomeDir . '/regen.sh', "$dir"); |
} |
} |