Changeset 10790


Ignore:
Timestamp:
2005-10-28T16:16:42+13:00 (19 years ago)
Author:
mdewsnip
Message:

Now with support for e-mailing the administrator when a collection build finishes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/cgi-bin/gliserver

    r10727 r10790  
    1010my $authentication_enabled = 1;
    1111my $debugging_enabled = 0;
     12
     13my $mail_enabled = 1;
     14my $mail_to_address = "user\@server";  # Set this appropriately
     15my $mail_from_address = "user\@server";  # Set this appropriately
     16my $mail_smtp_server = "smtp.server";  # Set this appropriately
    1217
    1318
     
    642647    $gsdl_cgi->generate_error("Perl failed: $perl_command\n--\nExit status: " . ($perl_status / 256));
    643648    }
     649    elsif ($mail_enabled) {
     650    if ($script eq "buildcol.pl") {
     651        &send_mail("Remote Greenstone building event", "Build of collection '$collection' complete.");
     652    }
     653    }
    644654}
    645655
     
    747757
    748758
     759sub send_mail
     760{
     761    my $mail_subject = shift(@_);
     762    my $mail_content = shift(@_);
     763
     764    my $sendmail_command = "perl -S sendmail.pl";
     765    $sendmail_command .= " -to \"" . $mail_to_address . "\"";
     766    $sendmail_command .= " -from \"" . $mail_from_address . "\"";
     767    $sendmail_command .= " -smtp \"" . $mail_smtp_server . "\"";
     768    $sendmail_command .= " -subject \"" . $mail_subject . "\"";
     769
     770    if (!open(POUT, "| $sendmail_command")) {
     771    $gsdl_cgi->generate_error("Unable to execute command: $sendmail_command");
     772    }
     773    print POUT $mail_content . "\n";
     774    close(POUT);
     775}
     776
     777
    749778&main();
Note: See TracChangeset for help on using the changeset viewer.