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

Re: Config file management utility




On 3 Dec 1997, Rob Browning wrote:

> Joey Hess <joey@kitenet.net> writes:
> 
> > Another way, that sould comply with policy, were if cron came with a
> > update-crontab script, that was responsible for modifying /etc/crontab,
> > in a similar fasion to update-inetd.
> 
> I think that this, or something similar, is in the end, the right
> solution.
> 
> Ideally, I think this should be handled like the menu package.
> /etc/crontab would be augmented to have something like:
> 
>   # ==== BEGIN AUTOMATICALLY GENERATED SECTION -- DO NOT EDIT ==== #
> 
> 
>   # ====  END AUTOMATICALLY GENERATED SECTION -- DO NOT EDIT  ==== #
> 
> Then each package would just have a file in /usr/lib/cron/auto (or
> whatever) which would be used to (re)build the contents of this
> section whenever a relevant package was installed.

Well, that's pretty much what I was suggesting in the beginning. The only
difference is that you wouldn't have one, monolithic section. Rather,
you'd have sections placed there by the individual packages. For example:

  echo "42 6 * * * root run-parts /etc/cron.daily" | \
    alter-file /etc/crontab --package=cron

causes /etc/crontab to read:

     # cron BEGIN
     42 6 * * * root run-parts /etc/cron.daily 
     # cron END

And then you could append to sections, like so:

  echo "47 6 * * 7 root run-parts /etc/cron.weekly" | \
    alter-file /etc/crontab --package=cron --append

to give:

     # cron BEGIN
     42 6 * * * root run-parts /etc/cron.daily
     47 6 * * 7 root run-parts /etc/cron.weekly
     # cron END
 
You get the idea. Of course, in real life, you wouldn't do a section a
line at a time. You'd pipe the whole snippet in like so:

  alter-file /etc/crontab --package=cron < /tmp/mysnippet

You could remove a section:

  alter-file /etc/crontab --package=cron --remove

You could also specify that, if removal of a section leaves the file
empty, then remove the file:

  alter-file /etc/crontab --package=mgetty --remove --rm-on-empty

Also, since not all config files use "#" as the comment, you'd be able
to specify alternate comment chars (that the program uses for the BEGIN
and END markers):

  alter-file /etc/someconfig --package=foobar --comment=";" < /etc/snippet

Well, you guys get the idea......

I already have something like this written. One of my company's clients
uses us as an e-mail forwarding service. So we maintain the forwarding
e-mail addresses in an Access database and, periodically, we export it to
a text file and feed it into this script I've got which replaces
everything between "# BEGIN someclient" and "# END someclient" with the
new section. So... it wouldn't be all that difficult to add the other
features I've mentioned.

The only problem is that it uses Perl. I haven't read the Debian policies
so I don't know if Perl (or a stripped down version of it) is one of the
things I can assume is on even the most minimal system. If not, I can do
the same thing with bash/sed, I s'pose.

- Joe

 


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: