help-cfengine
[Top][All Lists]
Advanced

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

Re: [Cfengine] Removing *all* occurrences of a set of lines.


From: Bas van der Vlies
Subject: Re: [Cfengine] Removing *all* occurrences of a set of lines.
Date: Tue, 14 Jan 2003 14:42:43 +0100

Daniel,

 What i would have done is to have a directory with all the files in in it
  <some_dir>/imap.access
  <some_dir>/pop.access

In pseudo cfengine commands:

copy:
   <some_dir_where_tcpd_files_are>/
     dest=<some_dir>
     define=create_host_file

shellcommands:
   create_host_file::
        "cat * > /etc/hosts.allow"

OR

editfiles:
   create_host_file::
        { /etc/hosts.allow 
                EmptyEntireFilePlease
                InsertFile "<some_dir>/imap.access>"
                InsertFile "<some_dir>/pop.access>"
        }

You can do this on the central server and generate the hosts.allow file
there and then distribute the hosts.allow file to the clients or generate
the hosts.allow file on the clients.

        Regards
 

On Tue, 14 Jan 2003 23:45:41 +1100
Daniel Pittman <daniel@rimspace.net> wrote:

> I am trying to work out how the 'editfiles' action can be used to
> implement a particular operation and having no luck. I figure that
> someone here will either tell me how it's done or suggest a better way
> of doing it.
> 
> 
> To manage /etc/hosts.allow[1], I want to be able to add a delimited
> block of settings in the style:
> 
> # IMAP start $Revision 1.3$
> imap: 1.2.3.4/255.0.0.0
> imap: 127.0.0.1
> # IMAP end
> 
> The $Revision...$ tag is, of course, updated when the configuration file
> is checked out of the RCS repository and, as such, an automatic
> indicator that the file has been changed.[2]
> 
> 
> What I am having trouble with is working out how to remove *all* the
> outdated sections from the file. I use the following code:
> 
>          BeginGroupIfNoLineContaining "# IMAP support $Revision: 1.12 $"
>             # Remove any old block
>             LocateLineMatching   "^# IMAP support.*"
>             DeleteToLineMatching "^# IMAP support end.*"
>             DeleteNLines "1"            # remove the endpoint line too.
>             CatchAbort                  # jump to here on failure
>             DeleteLinesStarting "imap:"
> 
>             Append "# IMAP support $Revision: 1.12 $"
>             Append "imap: 1.2.3.4/255.0.0.0"
>             Append "imap: 127.0.0.1"
>             Append "# IMAP support end"
>          EndGroup
> 
> That takes care of the first old block in the file, plus any stray perit
> lines.
> 
> Since I managed to screw up the 'LocateLineMatching' statement at first,
> though, I ended up with about five revisions worth of the start and end
> lines...
> 
> So, can anyone suggest a better way of implementing this?
> 
>     Daniel
> 
> 
> Footnotes: 
> [1]  ...and other files, but that's the one I am testing this technique on.
> 
> [2]  I kept forgetting to update the manual serial numbers on the
>      editfiles sections. This means some excess work, but not much, and
>      never too little.
> 
> -- 
> C makes it easy to shoot yourself in the foot.
> C++ makes it harder, but when you do, it blows away your whole leg.
>         -- Bjarne Stroustrup
> 
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine
> _______________________________________________
> Cfengine mailing list
> Cfengine@mailgate.sara.nl
> http://mailgate.sara.nl/mailman/listinfo/cfengine


--
********************************************************************
*                                                                  *
*  Bas van der Vlies                     e-mail: basv@sara.nl      *
*  SARA - Academic Computing Services    phone:  +31 20 592 8012   *
*  Kruislaan 415                         fax:    +31 20 6683167    *
*  1098 SJ Amsterdam                                               *
*                                                                  *
********************************************************************




reply via email to

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