Skip to content

Commit

Permalink
Merge pull request #264 from VinceMacBuche/bug_3293/missing_bundle_st…
Browse files Browse the repository at this point in the history
…dlib

Fixes #3293: Add missing bundle in rudder_stdlib
  • Loading branch information
ncharles committed Jan 10, 2014
2 parents 50972c8 + eaa87aa commit bdafec5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions techniques/system/common/1.0/rudder_stdlib.st
Expand Up @@ -113,6 +113,41 @@ body file_select rudder_common_minutes_old(minutes)
file_result => "mtime";
}

# enforce content of section
bundle edit_line rudder_ensure_section_content(section_start, section_end, content)
{
vars:
"csection" string => canonify("$(section_start)");
"escaped_section_start" string => escape(${section_start});
"escaped_section_end" string => escape(${section_end});

classes:
# Detect if section is already there
"has_$(csection)" expression => regline("${escaped_section_start}", "$(edit.filename)");

delete_lines:
".*"
select_region => rudder_section_selector("${escaped_section_start}", "${escaped_section_end}"),
ifvarclass => "has_$(csection)";

insert_lines:
# Insert new, empty section if it doesn't exist already.
"${section_start}
${section_end}"
insert_type => "preserve_block",
ifvarclass => "!has_$(csection)";
# Insert missing lines into the section
"$(content)"
select_region => rudder_section_selector("${escaped_section_start}", "${escaped_section_end}");
}
body select_region rudder_section_selector(section_start, section_end)
{
select_start => "${section_start}";
select_end => "${section_end}";
}
################################################
# Reporting bundles
################################################
Expand Down

0 comments on commit bdafec5

Please sign in to comment.