default.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #
  2. # Cookbook Name:: sysrc
  3. # Provider:: default
  4. #
  5. # Copyright 2012, Douglas Thrift
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. require 'chef/mixin/shell_out'
  20. include Chef::Mixin::ShellOut
  21. def load_current_resource
  22. current_resource = Chef::Resource::Sysrc.new(new_resource.name)
  23. current_resource.variable(new_resource.variable)
  24. current_resource.file(new_resource.file)
  25. current_resource.jail(new_resource.jail)
  26. current_resource.root(new_resource.root)
  27. current_resource
  28. end
  29. action :create do
  30. end
  31. action :delete do
  32. end
  33. private
  34. def sysrc_command(resource, *args)
  35. command = ['sysrc']
  36. if resource.file
  37. files = resource.file.kind_of?(Array) ? resource.file : [resource.file]
  38. files.each {|file| command += ['-f', file]}
  39. end
  40. command += ['-j', resource.jail.to_s] if resource.jail
  41. command += ['-R', resource.root] if resource.root
  42. command + args
  43. end
  44. # vim: shiftwidth=2