Created
January 24, 2012 21:50
-
-
Save rockpapergoat/1672927 to your computer and use it in GitHub Desktop.
copy user pref files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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