help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: editfiles problem - revisited - Still nobody having an idea what goe


From: Sven Mueller
Subject: Re: editfiles problem - revisited - Still nobody having an idea what goes wrong?
Date: Fri, 03 Sep 2004 23:47:34 +0200
User-agent: Thunderbird 0.7.3 (Windows/20040803)

Mark.Burgess@iu.hio.no [u] wrote on 03/09/2004 22:40:

Why can't you Define a class on edit, and then call a restart in processes?

Because all ways of achieving the basic editing task (replace exiting lines with the same first field, append line if none matched) I or others on the list found so far results in _always_ editing the files and _always_ defining that class. using

editfiles:
        { /tmp/aliases
                SetLine "root:xxxxx"
                ReplaceLinesMatchingField 1
                AppendIfNoLineMatching "ThisLine"
                DefineClasses "file edited"
        }

should do the job in theory (from all I read in the documentation), but that doesn't work as expected, instead it:
- doesn't replace existing lines and
- always appends the line in question if it wasn't found by exact match.

cu,
sven

On  3 Sep, Sven Mueller wrote:

Sven Mueller [u] wrote on 02/09/2004 16:00:

Still nobody having an idea of how to solve my problem?

In short my problem was that I _need_ to restart a program if I changed it's config file. But for various reasons, I have to avoid restarting it, if I didn't change it.

The only way I have come up with is using a temporary file, and with various shellcommands I shouldn't even have available on the machine in question (diff among them).

I am desperately looking for a solution which is maintainable even when (potentially) updating hundreds of lines in a file.

Please also see my additions inserted between the quotes below:


Josef Wolf [u] wrote on 02/09/2004 14:25:



On Thu, Sep 02, 2004 at 01:52:12PM +0200, Sven Mueller wrote:




test:x:1:1::/tmp/:/bin/bash
test2:x:2:2::/tmp/:/bin/bash

Here is what cfagent.conf looks like:

control:
     actionsequence = ( editfiles )

editfiles:
     { /tmp/passwd
             Backup "Off"
             SplitOn ":"
             ReplaceLinesMatchingField 1
             SetLine "test::::::"
             AppendIfNoLineMatching "ThisLine"
     }

AFAICS, the ThisLine notation works only in a ForEachLineIn loop.

Hmm, this didn't make a difference. Also, the documentation says:
'If "ThisLine" is given as the argument, the current value of the line buffer is assumed.'
The documentation of "ForEachLineIn" says:
'The result is like using SetLine for each line in the file'
And while the SetLine documentation says nothing about a line buffer (but ForEachLineIn doesn't either), what I gather from the above two snippets is that 'AppendIfNoLineMatching "ThisLine"' should do exactly what I expected. But it doesn't.

>> You need to give a regexp to AppendIfNoLineMatching. Further,
>> ReplaceLinesMatching requires either a ForEachLineIn loop or a SetLine.

So please try:

       { /tmp/passwd
               Backup "Off"
               SplitOn ":"
               SetLine "test::::::"
               ReplaceLinesMatchingField 1
               AppendIfNoLineMatching "test:.*"
       }


Changing it this way still doesn't replace an existing "test:x:1:1::/tmp/:/bin/bash" line with the "test::::::" line.

It doesn't seem to matter wether the ReplaceLinesMatchingField instruction is given before or after SetLine. It doesn't do what the documentation suggests in either case.

I'm really out of wits on this problem.

cu,
sven


_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
http://lists.gnu.org/mailman/listinfo/help-cfengine




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  Mark.Burgess@iu.hio.no
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






reply via email to

[Prev in Thread] Current Thread [Next in Thread]