[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Two new editfiles-commands
From: |
Alexander Mattausch |
Subject: |
Two new editfiles-commands |
Date: |
Fri, 26 Oct 2001 18:50:13 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011012 |
Hello!
I have added two new commands to the editfiles section:
BeginGroupIfDefined and BeginGroupIfNotDefined
They both start a group if a certain class is defined (or not defined).
Up to now, class-specific edit commands on the same file had to be done
this way (at least I found no better way ;-):
editfiles:
{ /etc/xyz
commands
}
abc::
{ /etc/xyz
commands
}
With BeginGroupIfDefined it can be done like that.
{ /etc/xyz
commands
BeginGroupIfDefined "abc"
commands
EndGroup
}
IMO this is a more convenient way to do class-specific edit commands and
also allows for more complex constructs, especially in conjunction with
other BeginGroup commands. We use it, for example, to first copy a
standard restrictive hosts.allow in a copy-section and then to open
services again, depending on the classes that are defined.
I have attached a patch for both cfengine 1.6.3 and 2.0.a14. The
1.6.3-patch also contains an addition to the documentation.
Regards,
Alex
--- ../cfengine-1.6.3-orig/doc/cfengine-Reference.texinfo Fri Dec 1
10:51:32 2000
+++ ./doc/cfengine-Reference.texinfo Fri Oct 26 17:07:04 2001
@@ -3298,6 +3298,16 @@
This allows a local override of the @code{Repository} variable, on an item
by item basis. If set to "off" or "none" it cancels the value of a global
repository.
+@item BeginGroupIfDefined @var{quoted-string}
+The lines following, up to the first @code{EndGroup}
+are executed if the quoted class is defined.
+@cindex @code{BeginGroupIfDefined}
+
+@item BeginGroupIfNotDefined @var{quoted-string}
+The lines following, up to the first @code{EndGroup}
+are executed if the quoted class is not defined.
+@cindex @code{BeginGroupIfNotDefined}
+
@item BeginGroupIfFileExists @var{quoted-string}
The lines following, up to the first @code{EndGroup}
are executed if the quoted filename exists (can be statted).
--- ../cfengine-1.6.3-orig/src/cf.defs.h Sun Dec 10 19:16:46 2000
+++ ./src/cf.defs.h Thu Oct 25 19:01:28 2001
@@ -777,6 +777,8 @@
BeginGroupIfFileIsNewer,
BeginGroupIfFileExists,
BeginGroupIfNoLineContaining,
+ BeginGroupIfDefined,
+ BeginGroupIfNotDefined,
AutoCreate,
ForEachLineIn,
EndLoop,
--- ../cfengine-1.6.3-orig/src/edittools.c Thu Feb 15 08:24:22 2001
+++ ./src/edittools.c Fri Oct 26 16:22:30 2001
@@ -911,6 +911,31 @@
EditVerbose("(Begin Group - found file %s)\n",expdata);
}
break;
+
+ case BeginGroupIfDefined:
+ if (!IsExcluded(expdata))
+ {
+ EditVerbose("(Begin Group - class %s defined)\n", expdata);
+ }
+ else
+ {
+ EditVerbose("(Begin Group - class %s not defined -
skipping)\n", expdata);
+ ep = SkipToEndGroup(ep,filename);
+ }
+ break;
+
+ case BeginGroupIfNotDefined:
+ if (IsExcluded(expdata))
+ {
+ EditVerbose("(Begin Group - class %s not defined)\n",
expdata);
+ }
+ else
+ {
+ EditVerbose("(Begin Group - class %s defined - skipping)\n",
expdata);
+ ep = SkipToEndGroup(ep,filename);
+ }
+ break;
+
case EndGroup:
EditVerbose("(End Group)\n");
break;
@@ -1527,6 +1552,8 @@
case BeginGroupIfFileIsNewer:
case BeginGroupIfFileExists:
case BeginGroupIfNoLineContaining:
+ case BeginGroupIfDefined:
+ case BeginGroupIfNotDefined:
level ++;
}
--- ../cfengine-1.6.3-orig/src/globals.c Wed Feb 21 13:06:09 2001
+++ ./src/globals.c Fri Oct 26 16:02:56 2001
@@ -769,6 +769,8 @@
"BeginGroupIfFileIsNewer",
"BeginGroupIfFileExists",
"BeginGroupIfNoLineContaining",
+ "BeginGroupIfDefined",
+ "BeginGroupIfNotDefined",
"AutoCreate",
"ForEachLineIn",
"EndLoop",
--- ../cfengine-1.6.3-orig/src/install.c Fri Feb 16 21:10:29 2001
+++ ./src/install.c Fri Oct 26 16:00:32 2001
@@ -2378,6 +2378,8 @@
case BeginGroupIfNoSuchLine:
case BeginGroupIfFileIsNewer:
case BeginGroupIfFileExists:
+ case BeginGroupIfDefined:
+ case BeginGroupIfNotDefined:
EDITGROUPLEVEL++;
break;
case EndGroup:
--- ../cfengine-2.0.a14-orig/src/cf.defs.h Tue Sep 4 13:32:01 2001
+++ ./src/cf.defs.h Fri Oct 26 16:18:50 2001
@@ -829,6 +829,8 @@
BeginGroupIfFileIsNewer,
BeginGroupIfFileExists,
BeginGroupIfNoLineContaining,
+ BeginGroupIfDefined,
+ BeginGroupIfNotDefined,
AutoCreate,
ForEachLineIn,
EndLoop,
--- ../cfengine-2.0.a14-orig/src/edittools.c Tue Aug 28 10:41:10 2001
+++ ./src/edittools.c Fri Oct 26 16:35:43 2001
@@ -924,6 +924,31 @@
EditVerbose("(Begin Group - found file %s)\n",expdata);
}
break;
+
+ case BeginGroupIfDefined:
+ if (!IsExcluded(expdata))
+ {
+ EditVerbose("(Begin Group - class %s defined)\n", expdata);
+ }
+ else
+ {
+ EditVerbose("(Begin Group - class %s not defined -
skipping)\n", expdata);
+ ep = SkipToEndGroup(ep,filename);
+ }
+ break;
+
+ case BeginGroupIfNotDefined:
+ if (IsExcluded(expdata))
+ {
+ EditVerbose("(Begin Group - class %s not defined)\n",
expdata);
+ }
+ else
+ {
+ EditVerbose("(Begin Group - class %s defined - skipping)\n",
expdata);
+ ep = SkipToEndGroup(ep,filename);
+ }
+ break;
+
case EndGroup:
EditVerbose("(End Group)\n");
break;
@@ -1565,6 +1590,8 @@
case BeginGroupIfFileIsNewer:
case BeginGroupIfFileExists:
case BeginGroupIfNoLineContaining:
+ case BeginGroupIfDefined:
+ case BeginGroupIfNotDefined:
level ++;
}
--- ../cfengine-2.0.a14-orig/src/globals.c Thu Sep 6 13:13:43 2001
+++ ./src/globals.c Fri Oct 26 16:20:56 2001
@@ -788,6 +788,8 @@
"BeginGroupIfFileIsNewer",
"BeginGroupIfFileExists",
"BeginGroupIfNoLineContaining",
+ "BeginGroupIfDefined",
+ "BeginGroupIfNotDefined",
"AutoCreate",
"ForEachLineIn",
"EndLoop",
--- ../cfengine-2.0.a14-orig/src/install.c Tue Sep 4 13:32:58 2001
+++ ./src/install.c Fri Oct 26 16:20:03 2001
@@ -2396,6 +2396,8 @@
case BeginGroupIfNoSuchLine:
case BeginGroupIfFileIsNewer:
case BeginGroupIfFileExists:
+ case BeginGroupIfDefined:
+ case BeginGroupIfNotDefined:
EDITGROUPLEVEL++;
break;
case EndGroup:
- Two new editfiles-commands,
Alexander Mattausch <=