[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Three-Line service comments
From: |
Tim Auckland |
Subject: |
Three-Line service comments |
Date: |
Wed, 01 Aug 2001 21:28:54 -0700 |
A common format for labeling services in, eg, inetd.conf is to add
a comment group just before the service.
For example:
#
# GNATS
#
support stream tcp nowait gnats /usr/libexec/gnats/gnatsd gnatsd
If I have cfengine add and delete this service according to class,
then I would like it to add and delete the comment as well. I could
just have cfengine blindly remove the preceeding three lines, but
this seems rather unsafe. I would rather make at least some attempt
to make sure they contained the comment I wish to delete.
Here's an attempt, but it's rather ugly. Is there a better way?
editfiles:
GnatsServers::
{ /etc/inet/inetd.conf
UnCommentLinesContaining "gnatsd"
BeginGroupIfNoLineContaining "gnatsd"
Append "#"
Append "# GNATS"
Append "#"
Append "support stream tcp nowait gnats
/usr/libexec/gnats/gnatsd gnatsd"
EndGroup
}
!GnatsServers::
{ /etc/inet/inetd.conf
DeleteLinesContaining "gnatsd"
ResetSearch "1"
LocateLineMatching "# GNATS$"
DeleteNLines "1"
BeginGroupIfNoMatch "^#$"
LocateLineMatching "!Abort!"
EndGroup
DeleteNLines "1"
IncrementPointer "-1"
BeginGroupIfNoMatch "^#$"
LocateLineMatching "!Abort!"
EndGroup
DeleteNLines "1"
CatchAbort
}
--
Tim.Auckland@Procket.com