coren has submitted this change and it was merged.
Change subject: Tool Labs: correctly handle comments in crontab
......................................................................
Tool Labs: correctly handle comments in crontab
Right now, comments are only recognized when they start at
the beginning of the line; this will retain comments verbatim
even if they are preceeded by whitespace.
Bug: T75256
Change-Id: I4cfab67012299ee7e60899575b4ae6a854d36eec
---
M modules/toollabs/templates/crontab.erb
1 file changed, 13 insertions(+), 2 deletions(-)
Approvals:
Anomie: Looks good to me, but someone else must approve
coren: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/toollabs/templates/crontab.erb
b/modules/toollabs/templates/crontab.erb
index 846a035..dbd056e 100755
--- a/modules/toollabs/templates/crontab.erb
+++ b/modules/toollabs/templates/crontab.erb
@@ -160,7 +160,18 @@
my $modified = 0;
if(open NEW, "| /usr/bin/ssh <%= @cron_host %> /usr/bin/crontab$dashu -") {
foreach my $line (@crontab) {
- if($line =~ m/^([^#][^=\t
]+\s+\S+\s+\S+\s+\S+\s+\S+\s+|\@\S+\s+)([^#\n]*)(#.*)?\n?$/) {
+ # Skip comments
+ if($line =~ m/^\s*#/) {
+ print NEW $line;
+ next;
+ }
+ # Skip environment variables
+ if($line =~ m/^\s*\S+\s*=/) {
+ print NEW $line;
+ next;
+ }
+
+ if($line =~
m/^\s*(\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+|\@\S+\s+)([^#\n]*)(#.*)?\n?$/) {
$crlino++;
my($sched, $cmd, $cmt) = ($1, $2, $3);
my $prefix = '';
@@ -176,7 +187,7 @@
$line .= "\n";
}
}
- print NEW "$line";
+ print NEW $line;
}
close NEW;
} else {
--
To view, visit https://gerrit.wikimedia.org/r/197325
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4cfab67012299ee7e60899575b4ae6a854d36eec
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: coren <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: coren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits