Skip to content

Instantly share code, notes, and snippets.

@roustem
Created January 19, 2012 19:20
Show Gist options
  • Save roustem/1641953 to your computer and use it in GitHub Desktop.
Save roustem/1641953 to your computer and use it in GitHub Desktop.
run_onepassword_beta.rb
#!/usr/bin/env ruby
BETA_URL = "http://i.agilebits.com/dist/1P/mas/1PasswordBeta.app.zip"
local_timestamp_filename = File.expand_path("~/.onepassword_beta_timestamp")
last_modified_local = ""
if File.exists?("/Applications/1PasswordBeta.app")
File.open(local_timestamp_filename, "r") { |f| last_modified_local = f.read() } rescue nil
end
server_info = `curl -sI #{BETA_URL}`
last_modified_server = $1 if server_info =~ /Last-Modified: (.*?)(\n|\r)/m
if last_modified_server == last_modified_local
puts "You already have the latest 1PasswordBeta.app installed."
else
puts "Downloading new build of 1PasswordBeta...\n"
`rm -rf /tmp/1PasswordBeta.app; rm -rf /tmp/1PasswordBeta.app.zip; cd /tmp; curl -O #{BETA_URL}; unzip 1PasswordBeta.app.zip`
if File.exists?("/tmp/1PasswordBeta.app")
`rm -rf /Applications/1PasswordBeta.app; mv /tmp/1PasswordBeta.app /Applications/`
end
if File.exists?("/tmp/1PasswordBeta.app")
File.open(local_timestamp_filename, "w") { |f| f.write(last_modified_server) }
end
end
puts "Running asctl command for container folders..."
`/usr/bin/asctl container acl add -file /Applications/1PasswordBeta.app; /usr/bin/asctl container acl add -file /Applications/1PasswordBeta.app/Contents/Library/LoginItems/1Password\\ Helper.app; /usr/bin/asctl container acl add -file /Applications/1PasswordBeta.app/Contents/Library/LoginItems/1Password\\ Helper.app/Contents/XPCServices/ThumbnailService.xpc`
puts "Starting 1PasswordBeta...\n"
`open /Applications/1PasswordBeta.app`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment