help-cfengine
[Top][All Lists]
Advanced

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

RE: Adding OR editing line only if not present


From: Andrews, Martin
Subject: RE: Adding OR editing line only if not present
Date: Fri, 7 Feb 2003 23:03:47 -0500

I usually use something like this (it does move lines when editing them
though):

control:
    cvspserver_inet = (
        "cvspserver stream tcp nowait root /opt/ngscript/bin/cvs-pserver
cvs" )

# Add cvs to inet configuration.

editfiles:
    { /etc/inetd.conf
        BeginGroupIfNoSuchLine "$(cvspserver_inet)"
            DeleteLinesMatching "^cvspserver.*"
            Append "$(cvspserver_inet)"
        EndGroup
        DefineClasses inet_updated
    }


Martin
----
Martin Andrews
martin.andrews@lionbioscience.com 

> -----Original Message-----
> From: Florian Thiel [mailto:noroute@web.de]
> Sent: Thursday, February 06, 2003 8:42 AM
> To: help-cfengine@gnu.org
> Subject: Adding OR editing line only if not present
> 
> 
> Hi!
> 
> I'm trying to configure services with cfengine and I don't want to use
> DeleteLines/AppendLines constructs because that changes config files
> every cfengine run.
> 
> What I want to do is the following:
> Append a certain line if it's not already there. If it's there, see if
> it maches a certain regexp. If it doesn't, replace it.
> 
> I'm trying to do it like this:
> 
> --snip--
> SetLine "allow=10.$(nr).0.0/255.255.0.0 127.0.0.1"
> AppendIfNoLineMatching "^allow="
> 
> # the part before this adds the line if it's missing; that 
> should work.
> # The problem is that LocateLineMatching exits if it doesn't find a
> # line.
> 
> LocateLineMatching "^allow="
> BeginGroupIfNoMatch "^allow=10\.\$(nr)\.0\.0/255\.255\.0\.0 
> 127\.0\.0\.1"
>   ReplaceLineWith "allow=10\.$(nr)\.0\.0/255\.255\.0\.0 127\.0\.0\.1"
> EndGroup
> DefineClasses "restart_webmin"
> --snip--
> 
> Any suggestions on how to do this more elegantly or at least in a way
> that works?
> 
> tia,
>    Florian
> -- 
> Florian Thiel - Medienzentrum Kassel
> Systembetreuung Internet- und Kommunikationstechnik
> Kasseler Schulen am Netz - http://www.medienzentrum-kassel.de
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine
> 




reply via email to

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