[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Adding OR editing line only if not present
From: |
Florian Thiel |
Subject: |
Adding OR editing line only if not present |
Date: |
Thu, 6 Feb 2003 14:42:29 +0100 |
User-agent: |
tin/1.5.14-20020917 ("Chop Suey!") (UNIX) (Linux/2.4.19-ck10-aa-int-ipsec-lids (i686)) |
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
- Adding OR editing line only if not present,
Florian Thiel <=