[BACK]Return to NewTorrents.pl CVS log [TXT][DIR] Up to [local] / openbsd / OpenBSDTorrents

Diff for /openbsd/OpenBSDTorrents/NewTorrents.pl between version 1.1 and 1.4

version 1.1, 2005/03/24 05:28:08 version 1.4, 2005/03/28 23:36:44
Line 7 
Line 7 
 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;
Line 20 
Line 24 
                 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 = "$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($HomeDir . '/regen.sh', "$dir");
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>