我想按照以下方式做一些事情:
set /files/etc/exports/dir[. = '/export/home'][client = '10.0.0.0/8'] /export/home set /files/etc/exports/dir[. = '/export/home'][client = '10.0.0.0/8']/client 10.0.0.0/8
如果我运行上述操作,会发生什么情况是第二个命令创build了另一个新节点,没有设置任何dir值。 我的挑战是/ export / home share不是一个独特的目录,因为客户端为了可读性而添加到新的行中。 我需要目录和客户端search选项来find一个独特的节点。
如何在命令1中引用(可能)新创build的节点,使得最终结果为:
/export/home 10.0.0.0/8()
Augeas有一些名为defnode的函数 ,它执行set命令,并将生成的节点存储在指定的variables中。
解决我的问题:
defnode newdir /files/etc/exports/dir[. = '/export/home' and client = '10.0.0.0/8'] /export/home set $newdir/client 10.0.0.0/8 set $newdir/client/option[1] rw set $newdir/client/option[2] async set $newdir/client/option[3] no_subtree_check
*编辑 :改变][为了更好的可读性