Sha256: e222b0f3171d5dc241ad1af85b2b40a7cd8bc48ae4add5168dbee42c848570fc

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 KB

Contents

        def symlink_dir(from, to)
          run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
        end

        def delete_files_from_dir1_which_exist_in_dir2(delete_from_dir, exist_in_dir)
          run "find #{exist_in_dir} -type f  | xargs -n1 basename | xargs -I{} bash -c 'test -f #{delete_from_dir}/{} && rm -v #{delete_from_dir}/{} || echo no file #{delete_from_dir}/{} to delete'"
        end

        def symlink_files_in_dir(from_dir,to_dir)  
          delete_files_from_dir1_which_exist_in_dir2(to_dir, from_dir)
  
          run "(#{sudo} test -d #{from_dir} && ( find #{from_dir}/ -mindepth 1  -print | xargs --verbose #{sudo} ln -s -f -t #{to_dir} ) ) || echo 'nothing to link'"
        end

        def mkdir_unless_exists( dir )
          run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
        end

        def symlink_dir(from, to)
          run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
        end

        def mkdir_unless_exists( dir )
          run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
        end
        
        def remove_file_if_exists( file )
          run "(test -f #{file} && #{sudo} rm #{file}) || echo 'no existing #{file} file to remove'"
        end
        
        def remove_dir_if_exists( dir )
          run "(test -d #{dir} && #{sudo} rm -rf #{dir}) || echo 'no existing #{dir} dir to remove'"
        end
        
        def set_permissions_on_files_in_dir( opts )
          if opts[:ownership]
            run "(test -d #{opts[:dir]} && #{sudo} chown #{opts[:ownership]} #{opts[:dir]}/* ) || echo couldnt find #{opts[:dir]}"
          end
          if opts[:permissions]
            run "(test -d #{opts[:dir]} && #{sudo} chmod #{opts[:permissions]} #{opts[:dir]}/* ) || echo couldnt find #{opts[:dir]}"
          end
        end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itrigga-cap_deploy-0.1.4 lib/itrigga/cap_deploy/filesystem_utils.rb