Bernd Kalbfuss-Zimmermann
unread,Jun 16, 2017, 3:50:43 PM6/16/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to help-c...@googlegroups.com
Hello everyone,
I am pretty new to cfengine and am currently taken my first steps. So
please forgive my ignorance. As a first challenge I am trying to install
an apache2 web server, mysql and the vimbadmin mail adminstration
frontend. So far so good. I have been able to install the apache2, mysql
and vimbadmin. I am able to create the vimbadmin configuration file, but
I am stuck with editing the ini style configuration file.
I am using a copy of the set_quoted_values edit_line bundle of the
standard library (v3.5) in order to adjust parameter settings (see end
of message). The only change in the edit_line bundle I have made is to
replace the "#" for an ";" to indicate comments in the file. Works
pretty well, however, I am having troubles with a single parameter.
Specifically, I am trying to edit "defaults.mailbox.maildir" to match
the following value:
defaults.mailbox.maildir = "maildir:/srv/vmail/%d/%u/mail:LAYOUT=fs"
What I get instead is:
defaults.mailbox.maildir = "maildir:/srv/vmail/%d/%u/mail:LAYOUT=fs"=fs"
When I checked the distribution config file, from which the
configuration is intialized, I found that the parameter is already set
to the string I intend it to set to. What seems to be happening is that
the second "=" in the string is recognized as additional field
separater. Consequently, col("=","2",' "$($(v)[$(index)])"',"set") only
replaces the part between the two equal signs and not the complete
string on the RHS. So I believe I identified the root cause, but how can
I fix?
I assume I am not the first person who has stumbled over this problem.
Any recommendations?
Cheers,
Bernd
--
bundle edit_line va_set_quoted_values(v)
{
# Sets the RHS of variables in shell-like files
# that is:
# LHS="RHS"
# Adds a new line if no LHS exists
# repairs RHS values if one does exist
# If the line is commented out with ;, it gets uncommented first.
#
# To use:
# 1) Define an array, where the keys are the LHS and the values
are the RHS
# "stuff[lhs-1]" string => "rhs1";
# "stuff[lhs-2]" string => "rhs2";
# 2) The parameter passed to the edit_line promise is the fully
qualified
# name of the array (i.e., "bundlename.stuff") WITHOUT any
"$" or "@"
vars:
"index" slist => getindices("$(v)");
# Be careful if the index string contains funny chars
"cindex[$(index)]" string => canonify("$(index)");
field_edits:
# If the line is there, but commented out, first uncomment it
";+\s*$(index)\s*=.*"
edit_field => col("=","1","$(index)","set");
# match a line starting like the key = something
"\s*$(index)\s*=.*"
edit_field => col("=","2",' "$($(v)[$(index)])"',"set"),
classes => if_ok("$(cindex[$(index)])_in_file"),
comment => "Match a line starting like key = something";
replace_patterns:
"\s*$(index)\s*=.*"
replace_with => value('$(index) = "$($(v)[$(index)])"');
insert_lines:
'$(index) = "$($(v)[$(index)])"'
comment => "Insert a variable definition",
ifvarclass => "!$(cindex[$(index)])_in_file";
}