From 0edd66cf60eefbe1fc5130d9ae1935bb5c0c15b5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 16 Sep 2026 11:18:02 +0200 Subject: [PATCH 1/2] cronwrap: Fix whitespace style --- cronwrap/cronwrap | 141 ++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 75 deletions(-) diff --git a/cronwrap/cronwrap b/cronwrap/cronwrap index 9a1276e4..ef78788e 100755 --- a/cronwrap/cronwrap +++ b/cronwrap/cronwrap @@ -1,5 +1,6 @@ -#! /usr/local/system/perl/bin/perl -w +#!/usr/local/system/perl/bin/perl use strict; +use warnings; use Getopt::Std; use Mail::Mailer; @@ -10,58 +11,53 @@ use Mail::Mailer; # -m address : mail to this address (default $LOGNAME) # -v : do send mail - even when exist status signals success -my $logfile="cronwrap.log"; -if (-e $logfile) -{ - open STDOUT,">>$logfile"; - open STDERR,">&STDOUT"; -} -else -{ - open STDOUT,">/dev/null"; - open STDERR,">/dev/null"; +my $logfile = "cronwrap.log"; +if (-e $logfile) { + open STDOUT, ">>$logfile"; + open STDERR, ">&STDOUT"; +} else { + open STDOUT,">/dev/null"; + open STDERR,">/dev/null"; } my %opt; -getopts('m:t:l:v',\%opt); -my $cmd=join " ",@ARGV; -my $start_time=localtime; -my $hostname=`/bin/hostname`; +getopts('m:t:l:v', \%opt); +my $cmd = join " ", @ARGV; +my $start_time = localtime; +my $hostname = `/bin/hostname`; chomp($hostname); warn "+++ $$ $start_time $hostname $0 $cmd\n"; die "no command" if $cmd eq ""; -#warn "environment:\n",map("\t$_ => $ENV{$_}\n",keys %ENV); +#warn "environment:\n", map("\t$_ => $ENV{$_}\n", keys %ENV); -my $tmpdir=$opt{'t'}||'.'; -my $tmpout="$tmpdir/cronwrap.tmp.$$"; +my $tmpdir = $opt{'t'} || '.'; +my $tmpout = "$tmpdir/cronwrap.tmp.$$"; #warn "tempout : $tmpout\n"; -END -{ - $tmpout && -e $tmpout && unlink $tmpout; +END { + $tmpout && -e $tmpout && unlink $tmpout; } -e $tmpout && unlink $tmpout; -my $pid=fork; +my $pid = fork; defined $pid or die "fork failed $!\n"; -unless ($pid) -{ - my $umask=umask 077; - open STDOUT,">$tmpout"; - open STDERR,">&STDOUT"; - umask $umask; - exec {'/bin/sh'} '-sh','-c',$cmd; - die "exec failed : $!\n"; +unless ($pid) { + my $umask = umask 077; + open STDOUT, ">$tmpout"; + open STDERR, ">&STDOUT"; + umask $umask; + exec {'/bin/sh'} '-sh', '-c', $cmd; + die "exec failed : $!\n"; } wait; -my $status=$?; +my $status = $?; if ($tmpout && -e $tmpout && $opt{'l'}) { if (open OUT, ">>$opt{'l'}") { - open T,"<$tmpout"; + open T, "<$tmpout"; while () { print OUT; } @@ -72,51 +68,46 @@ if ($tmpout && -e $tmpout && $opt{'l'}) { } } -if ($status || $opt{v}) -{ - my $subject = ($status ? 'FAIL: ':'')."$cmd"; - my $to=$opt{'m'}||$ENV{'LOGNAME'}||"nobody"; - my @to=split/,/,$to; - @to=map {/@/ ? $_ : "$_ <$_\@molgen.mpg.de>" } @to; +if ($status || $opt{v}) { + my $subject = ($status ? 'FAIL: ' : '') . "$cmd"; + my $to = $opt{'m'} || $ENV{'LOGNAME'} || "nobody"; + my @to = split /,/, $to; + @to = map {/@/ ? $_ : "$_ <$_\@molgen.mpg.de>" } @to; - my $mailer=new Mail::Mailer 'smtp',Server=>'harry.molgen.mpg.de'; - $mailer->open - ( - { - From => "\"cronwrap\@$hostname\" ", - To => \@to, - Subject => $subject, - 'MIME-Version' => '1.0', - 'Content-Type' => 'text/plain; charset=utf-8', - } - ); + my $mailer = new Mail::Mailer 'smtp', Server=>'harry.molgen.mpg.de'; + $mailer->open ({ + From => "\"cronwrap\@$hostname\" ", + To => \@to, + Subject => $subject, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=utf-8', + }); - print $mailer "You cron command $cmd\n"; - print $mailer " started $start_time on $hostname\n"; - print $mailer " completed ".scalar(localtime)."\n"; + print $mailer "You cron command $cmd\n"; + print $mailer " started $start_time on $hostname\n"; + print $mailer " completed " . scalar(localtime)."\n"; - if ($status) { - print $mailer "It terminated with an exit value of ", - $status>>8," and a signal status of ",$status&255,"\n"; - } - if (-s $tmpout) { - print $mailer "It produced the following output:\n\n"; - print $mailer "-"x60,"\n"; - open T,"<$tmpout"; - while () { - $_ eq ".\n" and $_="..\n"; - print $mailer $_; - } - print $mailer "-"x60,"\n\n"; - close T; - } else { - print $mailer "It didn't produce any output.\n"; - } - print $mailer "\n\nYours\n cronwrap.pl\n"; - $mailer->close; - warn "--- $$ ",scalar(localtime),' ',"$hostname completion status: $status - mail sent to $to\n"; + if ($status) { + print $mailer "It terminated with an exit value of ", + $status>>8, " and a signal status of ", $status & 255, "\n"; + } + if (-s $tmpout) { + print $mailer "It produced the following output:\n\n"; + print $mailer "-" x 60,"\n"; + open T, "<$tmpout"; + while () { + $_ eq ".\n" and $_="..\n"; + print $mailer $_; + } + print $mailer "-" x 60, "\n\n"; + close T; + } else { + print $mailer "It didn't produce any output.\n"; + } + print $mailer "\n\nYours\n cronwrap.pl\n"; + $mailer->close; + warn "--- $$ ", scalar(localtime), ' ', "$hostname completion status: $status - mail sent to $to\n"; } -else -{ - warn "--- $$ ",scalar(localtime),' ',"$hostname completion status: $status - no mail sent\n"; +else { + warn "--- $$ ", scalar(localtime), ' ', "$hostname completion status: $status - no mail sent\n"; } From 08bcaa53b9d49c9d00613695750f6bec50932909 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 16 Sep 2026 11:40:52 +0200 Subject: [PATCH 2/2] cronwrap: Use postmaster@molgen.mpg.de as envelope From Fixes https://github.molgen.mpg.de/mariux64/mariux64-issues/issues/230 --- cronwrap/cronwrap | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cronwrap/cronwrap b/cronwrap/cronwrap index ef78788e..9f46fa43 100755 --- a/cronwrap/cronwrap +++ b/cronwrap/cronwrap @@ -74,7 +74,11 @@ if ($status || $opt{v}) { my @to = split /,/, $to; @to = map {/@/ ? $_ : "$_ <$_\@molgen.mpg.de>" } @to; - my $mailer = new Mail::Mailer 'smtp', Server=>'harry.molgen.mpg.de'; + my $mailer = Mail::Mailer->new( + 'smtp', + Server => 'harry.molgen.mpg.de', + From => 'postmaster@molgen.mpg.de' + ); $mailer->open ({ From => "\"cronwrap\@$hostname\" ", To => \@to,