[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: editfiles
From: |
Brendan Strejcek |
Subject: |
Re: editfiles |
Date: |
Mon, 19 Apr 2004 15:41:50 -0500 |
User-agent: |
Mutt/1.3.28i |
David Kewley wrote:
> > Should it really take me 9 lines to code 'Make sure SyslogFacility
> > is set to AUTHPRIV in /etc/ssh/sshd_config' as he does it:
This is what I do:
BeginGroupIfNoLineMatching "^$1.*"
Append "$1$2"
EndGroup
ResetSearch "1"
LocateLineMatching "^$1.*"
BeginGroupIfNoMatch "^$1$2$"
ReplaceLineWith "$1$2"
EndGroup
DeleteLinesAfterThisMatching "^$1.*"
I use m4 to munge this. I hear other people use other preprocessors
(like perl).
> I'm not a guru, just a clever newb :), but here's how I do something
> similar, changing 4 parameters in sshd_config using 8 cfengine
> statements:
>
> HashCommentLinesMatching "[^#]*StrictModes.*$"
> AppendIfNoSuchLine "StrictModes no"
Not good:
$ cat set_variable.cf
#!/usr/sbin/cfagent -qKf
control:
actionsequence = ( editfiles )
file = ( /tmp/junk )
editfiles:
{ ${file}
HashCommentLinesMatching "[^#]*somevar .*$"
AppendIfNoSuchLine "somevar otherval"
}
$ cat /tmp/junk
somevar somevalue
$ ./set_variable.cf
$ cat /tmp/junk
# somevar somevalue
somevar otherval
$ ./set_variable.cf
$ ./set_variable.cf
$ ./set_variable.cf
$ ./set_variable.cf
$ cat /tmp/junk
# somevar somevalue
# somevar otherval
# somevar otherval
# somevar otherval
# somevar otherval
somevar otherval
$
You might need to do log rotation on your config files...
Re: editfiles, Jamie Wilkinson, 2004/04/20