Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deploy-vhost] Allow multiple emails in crontab MAILTO #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions bin/deploy-vhost
Original file line number Diff line number Diff line change
Expand Up @@ -950,17 +950,22 @@ sub install_or_remove_crontab {
open CRON, $tmp_crontab or die "can't open $tmp_crontab: $!";
while (<CRON>) {
if (/^MAILTO=(.*)$/) {
system("/data/mysociety/bin/lookup_google_apps_email.sh $1");
my $result = $? >> 8;
if ($result == 1) {
unlink $tmp_crontab;
die "MAILTO=$1: not a valid address in crontab";
} elsif ($result == 2) {
warn "Google Apps API not working; can't check MAILTO address";
} elsif ($result != 0) {
warn "unexpected result code $result from lookup_google_apps_email.sh";
my $found_external;
foreach my $mailto (split(',', $1)) {
next if $mailto =~ /\@${hostname}/;
$found_external = 1;
system("/data/mysociety/bin/lookup_google_apps_email.sh $mailto");
my $result = $? >> 8;
if ($result == 1) {
unlink $tmp_crontab;
die "MAILTO=$mailto: not a valid address in crontab";
} elsif ($result == 2) {
warn "Google Apps API not working; can't check MAILTO address";
} elsif ($result != 0) {
warn "unexpected result code $result from lookup_google_apps_email.sh";
}
}

warn "No external email found in MAILTO" unless ($found_external);
last;
}
}
Expand Down