How to copy a single file
First way
I use the file operator to copy a file (compile time check)
file "/etc/init.d/someService" do owner 'root' group 'root' mode 0755 content ::File.open("/home/someService").read action :create end
here:
"/etc/init.d/someService" - the target file,"/home/someService" - source file
You can also wrap ::File.open("/home/someService").read in lazy block
... lazy { ::File.open("/home/someService").read } ...
Second way
remote_file user (runtime check)
remote_file "Copy service file" do path "/etc/init.d/someService" source "file:///home/someService" owner 'root' group 'root' mode 0755 end
Third way
You can also use shell / batch
For each directory
Dir[ "/some/directory/resources/**/*" ].each do |curr_path| file "/some/target/dir/#{Pathname.new(curr_path).basename}" do owner 'root' group 'root' mode 0755 content lazy { IO.read(curr_path, mode: 'rb').read } action :create end if File.file?(curr_path) directory "/some/target/dir/#{File.dirname(curr_path)}" do path curr_path owner 'root' group 'root' mode 0755 action :create end if File.directory?(curr_path) end
This is just an idea because the subparagraphs in this example are not processed correctly.
CAMOBAP 31 Oct '13 at 12:45 2013-10-31 12:45
source share