Skip to content

Instantly share code, notes, and snippets.

@rockpapergoat
Created January 24, 2012 21:50
Show Gist options
  • Save rockpapergoat/1672927 to your computer and use it in GitHub Desktop.
Save rockpapergoat/1672927 to your computer and use it in GitHub Desktop.
copy user pref files
require 'FileUtils'
require 'pathname'
def stash_user_file(file)
users = get_users
users.each do |u|
if File.directory?(file)
if File.exist?("#{get_homedir(u)}/Library/Preferences/#{File.basename(file)}")
puts "copying files to #{u}\'s homedir."
system "/usr/bin/rsync -rv #{file}/ #{get_homedir(u)}/Library/Preferences/#{File.basename(file)}/"
FileUtils.chown_R("#{u}", nil, "#{get_homedir(u)}/Library/Preferences/#{File.basename(file)}")
else
puts "creating a symlink in #{u}\'s homedir."
set_symlink(file,"#{get_homedir(u)}/Library/Preferences/#{File.basename(file)}")
# the app is pretty dumb with ownership/perms
#FileUtils.chmod_R(0777,file,:verbose => true)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment