-
Notifications
You must be signed in to change notification settings - Fork 6
/
dropbox_helper.rb
executable file
·43 lines (36 loc) · 1.32 KB
/
dropbox_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/ruby
#####################################################################
# Name: Dropbox Helper
# Author: [email protected]
# Date: March 29, 2013
# Version: 0.1.0
# Description: Places the files Dropbox needs to modify folder icons,
# which prevents Dropbox from asking for an Administrator password.
#####################################################################
require 'fileutils'
dropbox_tgz = '/Applications/Dropbox.app/Contents/Resources/DropboxHelperInstaller.tgz'
dropbox_script_path = '/Library/DropboxHelperTools'
dropbox_script = "#{dropbox_script_path}/DropboxHelperInstaller"
unless Process.euid == 0
puts 'This must be run as root.'
exit 1
end
# Don't need to do anything
exit 0 if File.exists?(dropbox_script)
if File.exists?(dropbox_tgz)
begin
FileUtils.mkdir(dropbox_script_path, :mode => 0755)
Dir.chdir(dropbox_script_path)
system("/usr/bin/tar xfz #{dropbox_tgz}")
FileUtils.chmod(04511, dropbox_script)
system("xattr -d com.apple.quarantine #{dropbox_script}")
FileUtils.chown('root', 'wheel', dropbox_script)
rescue Exception => e
message = 'An error occured:' + "\n\n" + "Error Message: " + e.message + "\n" + "Backtrace: " + e.backtrace.inspect
puts message
end
else
puts "#{dropbox_tgz} doesn't seem to exist."
exit 1
end
exit 0