如何检查目录是否在Chef中是符号链接 [英] How to check if the directory is symlink in chef

查看:49
本文介绍了如何检查目录是否在Chef中是符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果不是symlnik,我只想删除目录。

I just want to do delete directory if it is not symlnik.

directory "/var/www/html/" do
  action :delete
  only_if ???
end


推荐答案

所选答案将不起作用在Windows或Bash是默认解释器的系统上。您应该使用Ruby解决方案来实现跨平台(并且更快,因为没有进程生成):

The selected answer will not work on Windows or systems where Bash is the default interpreter. You should use a Ruby solution to be cross-platform (and faster, since there's no process spawning):

directory '/var/www/html' do
  action :delete
  not_if { File.symlink?('/var/www/html') }
end

这篇关于如何检查目录是否在Chef中是符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆