How to check if the directory is symlink in chef

徘徊边缘 提交于 2019-12-10 04:28:21

问题


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

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

回答1:


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



回答2:


How about:

directory "/var/www/html/" do
    action :delete
    not_if "test -L /var/www/html/"
end

test -L $file returns 0 (true) if $file is a symlink.



来源:https://stackoverflow.com/questions/22892284/how-to-check-if-the-directory-is-symlink-in-chef

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!