]> git.decadent.org.uk Git - dak.git/blobdiff - tools/debianqueued-0.9/debianqueued
debianqueued
[dak.git] / tools / debianqueued-0.9 / debianqueued
index 72bd603788d89d8419886c207553eb37d12d953b..f9974366950bf075937946fed73117c0c15ad55b 100755 (executable)
@@ -21,6 +21,7 @@ use Net::Ping;
 use Net::FTP;
 use Socket qw( PF_INET AF_INET SOCK_STREAM );
 use Config;
+use Sys::Hostname;
 
 # ---------------------------------------------------------------------------
 #                                                              configuration
@@ -43,6 +44,7 @@ $junk = $conf::upload_delay_2;
 $junk = $conf::ar;
 $junk = $conf::gzip;
 $junk = $conf::cp;
+$junk = $conf::check_md5sum;
 
 #$junk = $conf::ls;
 $junk         = $conf::chmod;
@@ -60,6 +62,8 @@ package main;
 
 ( $main::progname = $0 ) =~ s,.*/,,;
 
+($main::hostname, undef, undef, undef, undef) = gethostbyname(hostname());
+
 my %packages = ();
 
 # extract -r and -k args
@@ -134,7 +138,7 @@ if ( !@ARGV ) {
     POSIX::sigsuspend($sigset);
     waitpid( $pid, WNOHANG );
     if ( kill( 0, $pid ) ) {
-      print "Daemon started in background (pid $pid)\n";
+      print "Daemon (on $main::hostname) started in background (pid $pid)\n";
       exit 0;
     } else {
       exit 1;
@@ -164,9 +168,7 @@ my $parent_pid = $ARGV[1];
 
 do {
   my $version;
-  ( $version =
-'Release: 0.9 $Revision: 1.51 $ $Date: 1999/07/08 09:43:21 $ $Author: ftplinux $'
-  ) =~ s/\$ ?//g;
+  ( $version = 'Release: 0.95' ) =~ s/\$ ?//g;
   print "debianqueued $version\n";
 };
 
@@ -328,7 +330,7 @@ open( STDERR, ">&LOG" )
   or die "$main::progname: Can't redirect stderr to $conf::logfile: $!\n";
 
 # ok, from this point usually no "die" anymore, stderr is gone!
-msg( "log", "daemon (pid $$) started\n" );
+msg( "log", "daemon (pid $$) (on $main::hostname) started\n" );
 
 # initialize variables used by send_status before launching the status daemon
 $main::dstat = "i";
@@ -1490,70 +1492,72 @@ sub copy_to_target(@) {
 
   # check md5sums or sizes on target against our own
   my $have_md5sums = 1;
-  if ( $conf::upload_method eq "ssh" ) {
-    ( $msgs, $stat ) = ssh_cmd("md5sum @files");
-    goto err if $stat;
-    @md5sum = split( "\n", $msgs );
-  } elsif ( $conf::upload_method eq "ftp" ) {
-    my ( $rv, $err, $file );
-    foreach $file (@files) {
-      ( $rv, $err ) = ftp_cmd( "quot", "site", "md5sum", $file );
-      if ($err) {
-        next if ftp_code() == 550;    # file not found
-        if ( ftp_code() == 500 ) {    # unimplemented
-          $have_md5sums = 0;
-          goto get_sizes_instead;
-        }
-        $msgs = $err;
-        goto err;
-      } ## end if ($err)
-      chomp( my $t = ftp_response() );
-      push( @md5sum, $t );
-    } ## end foreach $file (@files)
-    if ( !$have_md5sums ) {
-    get_sizes_instead:
+  if ($conf::check_md5sum) {
+    if ( $conf::upload_method eq "ssh" ) {
+      ( $msgs, $stat ) = ssh_cmd("md5sum @files");
+      goto err if $stat;
+      @md5sum = split( "\n", $msgs );
+    } elsif ( $conf::upload_method eq "ftp" ) {
+      my ( $rv, $err, $file );
       foreach $file (@files) {
-        ( $rv, $err ) = ftp_cmd( "size", $file );
+        ( $rv, $err ) = ftp_cmd( "quot", "site", "md5sum", $file );
         if ($err) {
           next if ftp_code() == 550;    # file not found
+          if ( ftp_code() == 500 ) {    # unimplemented
+            $have_md5sums = 0;
+            goto get_sizes_instead;
+          }
           $msgs = $err;
           goto err;
-        }
-        push( @md5sum, "$rv $file" );
+        } ## end if ($err)
+        chomp( my $t = ftp_response() );
+        push( @md5sum, $t );
       } ## end foreach $file (@files)
-    } ## end if ( !$have_md5sums )
-  } else {
-    ( $msgs, $stat ) = local_cmd("$conf::md5sum @files");
-    goto err if $stat;
-    @md5sum = split( "\n", $msgs );
-  }
+      if ( !$have_md5sums ) {
+      get_sizes_instead:
+        foreach $file (@files) {
+          ( $rv, $err ) = ftp_cmd( "size", $file );
+          if ($err) {
+            next if ftp_code() == 550;    # file not found
+            $msgs = $err;
+            goto err;
+          }
+          push( @md5sum, "$rv $file" );
+        } ## end foreach $file (@files)
+      } ## end if ( !$have_md5sums )
+    } else {
+      ( $msgs, $stat ) = local_cmd("$conf::md5sum @files");
+      goto err if $stat;
+      @md5sum = split( "\n", $msgs );
+    }
 
-  @expected_files = @files;
-  foreach (@md5sum) {
-    chomp;
-    ( $sum, $name ) = split;
-    next if !grep { $_ eq $name } @files;    # a file we didn't upload??
-    next if $sum eq "md5sum:";               # looks like an error message
-    if (    ( $have_md5sums && $sum ne md5sum($name) )
-         || ( !$have_md5sums && $sum != ( -s $name ) ) )
-    {
-      msg(
-           "log,mail",
-           "Upload of $name to $conf::target failed ",
-           "(" . ( $have_md5sums ? "md5sum" : "size" ) . " mismatch)\n"
-         );
+    @expected_files = @files;
+    foreach (@md5sum) {
+      chomp;
+      ( $sum, $name ) = split;
+      next if !grep { $_ eq $name } @files;    # a file we didn't upload??
+      next if $sum eq "md5sum:";               # looks like an error message
+      if (    ( $have_md5sums && $sum ne md5sum($name) )
+           || ( !$have_md5sums && $sum != ( -s $name ) ) )
+      {
+        msg(
+             "log,mail",
+             "Upload of $name to $conf::target failed ",
+             "(" . ( $have_md5sums ? "md5sum" : "size" ) . " mismatch)\n"
+           );
+        goto err;
+      } ## end if ( ( $have_md5sums &&...
+
+      # seen that file, remove it from expect list
+      @expected_files = map { $_ eq $name ? () : $_ } @expected_files;
+    } ## end foreach (@md5sum)
+    if (@expected_files) {
+      msg( "log,mail", "Failed to upload the files\n" );
+      msg( "log,mail", "  ", join( ", ", @expected_files ), "\n" );
+      msg( "log,mail", "(Not present on target after upload)\n" );
       goto err;
-    } ## end if ( ( $have_md5sums &&...
-
-    # seen that file, remove it from expect list
-    @expected_files = map { $_ eq $name ? () : $_ } @expected_files;
-  } ## end foreach (@md5sum)
-  if (@expected_files) {
-    msg( "log,mail", "Failed to upload the files\n" );
-    msg( "log,mail", "  ", join( ", ", @expected_files ), "\n" );
-    msg( "log,mail", "(Not present on target after upload)\n" );
-    goto err;
-  } ## end if (@expected_files)
+    } ## end if (@expected_files)
+  } ## end if ($conf::check_md5sum)
 
   if ($conf::chmod_on_target) {
 
@@ -1890,7 +1894,8 @@ sub ftp_open() {
           Net::FTP->new(
                          $conf::target,
                          Debug   => $conf::ftpdebug,
-                         Timeout => $conf::ftptimeout
+                         Timeout => $conf::ftptimeout,
+                         Passive => 1,
                        )
         )
      )
@@ -2335,7 +2340,7 @@ __MESSAGE__
   }
 
   $message .= "\n$text";
-  $message .= "\nGreetings,\n\n\tYour Debian queue daemon\n";
+  $message .= "\nGreetings,\n\n\tYour Debian queue daemon (running on host $main::hostname)\n";
 
   my $mail = Email::Send->new;
   for (qw[Sendmail SMTP]) {