【问题标题】:augtool fails to update writeable fileaugtool 无法更新可写文件
【发布时间】:2013-09-19 16:38:34
【问题描述】:

我在我的 CentOS 机器上安装了 Augeas,但我从 augtool 得到了意想不到的行为。

对白,

[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

现在我想使用augtool 将OptionOne 从no 更改为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 没有将配置更改写入文件。我没有看到任何错误。我做错了什么?

【问题讨论】:

    标签: linux centos augeas


    【解决方案1】:

    /tmp/my.conf 不是任何 conffile 的标准位置,因此您需要指定要使用的镜头(即解析器),以便 Augeas 知道要应用哪种语法(有大量不同的 conffile 语法,Augeas 目前支持超过150 个开箱即用!)。

    如果您知道要使用哪个镜头并且您正在使用 Augeas >= 1.0.0,则可以为此使用 --transform

    Sshd.lns 镜头看起来与您的格式相似,因此您可能想要使用这个。

    还有:

    • --autosave 是提交更改所必需的,因为您没有明确调用 save 命令;
    • 您需要使用/files/tmp/my.conf/OptionOne 来更改节点的值,因为映射文件在 Augeas 树中的/files 下公开。

    所以:

    # 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
    

    【讨论】:

    • 升级到 augeas 1.0.x 来完成这项工作。谢谢。
    猜你喜欢
    • 2013-10-30
    • 2020-08-10
    • 1970-01-01
    • 2011-12-17
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 2021-04-03
    相关资源
    最近更新 更多