سؤال

I installed Augeas on my CentOS box and am getting unexpected behaviour from augtool.

To whit,

[root@boxen tmp]# ll
-rw-r--r--. 1 root root     27 Sep 19 11:58 /tmp/my.conf

[root@boxen tmp]# cat /tmp/my.conf 
OptionOne no
OptionTwo yes

Now I want to use augtool to change OptionOne from no to yes.

[root@boxen tmp]# augtool set /tmp/my.conf/OptionOne yes
[root@boxen tmp]# augtool save

[root@boxen tmp]# cat my.conf 
OptionOne no
OptionTwo yes

augtool is not writing the config change to the file. I'm not seeing any errors. What am I doing wrong?

هل كانت مفيدة؟

المحلول

/tmp/my.conf is not a standard location for any conffile, so you need to specify which lens (i.e. parser) you want to use so Augeas knows which syntax to apply (there's tons of different conffile syntaxes, Augeas currently supports more than 150 out of the box!).

If you know which lens you want to use and you're using Augeas >= 1.0.0, you can use --transform for that.

The Sshd.lns lens looks similar to your format, so you might want to use this one.

Also:

  • --autosave is necessary to commit your changes, since you're not calling the save command explicitely;
  • you need to use /files/tmp/my.conf/OptionOne to change the value of the node, since mapped files are exposed under /files in the Augeas tree.

So:

# augtool --autosave --transform "Sshd.lns incl /tmp/my.conf" set /files/tmp/my.conf/OptionOne yes
Saved 1 file(s)
# cat /tmp/my.conf
OptionOne yes
OptionTwo yes
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top