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: Tod Oace
Subject: Re: editfiles problem - revisited - Still nobody having an idea what goes wrong?
Date: Fri, 3 Sep 2004 13:46:28 -0700

On Sep 3, 2004, at 13:12, Sven Mueller wrote:

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

How about something like this:

{ /etc/passwd
        BeginGroupIfNoSuchLine "test::::::"
                DeleteLinesMatching "^test:.*$"
                Append "test::::::"
        EndGroup
        DefineClasses "restart_whatever"
}

-Tod


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

--
Tod Oace, Intel Corporation <tod@intel.com>




reply via email to

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