[augeas-devel] howto create a new conf file and save it

Dominic Cleal dcleal at redhat.com
Mon Feb 27 09:28:48 UTC 2012


On 27/02/12 06:50, zzs wrote:
> My config file format just like xorg.aug
> Readind config files all ok.
> Modify some fields then write ok too.
> 
> But I wonder :
> 
> 1. Can I create a new config file and save it to disk using augtool or c
>    code?
>    If yes, Howto do it,

If the new config file is in the autoloaded file list in the lens, then
just by setting the node in Augeas, it'll create the file.  For example:

$ ls etc/securetty
ls: cannot access etc/securetty: No such file or directory
$ augtool -r . -s set /files/etc/securetty/01 tty1
Saved 1 file(s)
$ cat etc/securetty
tty1

> 2. How can I create new node(e.g. a section like in xorg.conf) and let
>    augeas known use which lense to manage it

You can change the /augeas tree to load files with a particular lens:
http://augeas.net/page/Loading_specific_files

Raphael has a useful "augload" utility that sets this up too:
https://github.com/raphink/augeas-sandbox/blob/master/augload

Regards,

-- 
Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113




More information about the augeas-devel mailing list