[BACK]Return to OpenBSDTorrents.pm CVS log [TXT][DIR] Up to [local] / openbsd / OpenBSDTorrents / lib

Diff for /openbsd/OpenBSDTorrents/lib/OpenBSDTorrents.pm between version 1.4 and 1.5

version 1.4, 2005/03/24 19:51:50 version 1.5, 2005/03/25 03:11:38
Line 12 
Line 12 
   
 our @EXPORT = qw(  our @EXPORT = qw(
         $BaseDir          $BaseDir
           $HomeDir
         $TorrentDir          $TorrentDir
         $BaseName          $BaseName
         $Tracker          $Tracker
         &Name_Torrent          &Name_Torrent
         &Get_Files_and_Dirs          &Get_Files_and_Dirs
           &justme
 );  );
   
 our $BaseDir    = '/home/ftp/pub';  our $BaseDir    = '/home/ftp/pub';
   our $HomeDir    = '/home/andrew/OpenBSDTorrents';
 our $TorrentDir = '/home/andrew/torrents';  our $TorrentDir = '/home/andrew/torrents';
 our $BaseName   = 'OpenBSD';  our $BaseName   = 'OpenBSD';
 our $Tracker    = 'http://OpenBSD.somedomain.net/announce.php';  our $Tracker    = 'http://OpenBSD.somedomain.net/announce.php';
Line 79 
Line 82 
         }          }
         return join '-', ($year, $mon, $mday, $hour . $min);          return join '-', ($year, $mon, $mday, $hour . $min);
 }  }
   
   # "There can be only one."  --the Highlander
   sub justme {
   
           my $myname;
   
           if ($0 =~ m#([^/]+$)#) {
                   $myname = $1;
           } else {
                   die "Couldn't figure out myname";
           }
   
           my $SEMA = "$HomeDir/$myname.pid";
           if (open SEMA, "<", $SEMA) {
                   my $pid = <SEMA>;
                   if (defined $pid) {
                           chomp $pid;
                           if ($pid =~ /^(\d+)$/) {
                                   $pid = $1;
                           } else {
                                   die "invalid pid read '$pid'";
                           }
                           if (kill(0, $pid)) {
                                 print "$0 already running (pid $pid), bailing out\n";
                                 exit 253;
                           }
                   }
                   close SEMA;
           }
           open (SEMA, ">", $SEMA)      or die "can't write $SEMA: $!";
           print SEMA "$$\n";
           close(SEMA)                    or die "can't close $SEMA: $!";
   }
   
   
 1;  1;
 __END__  __END__

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

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