Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamyanalunas/944284b76a2d40342868e2da6d352f23 to your computer and use it in GitHub Desktop.
Save adamyanalunas/944284b76a2d40342868e2da6d352f23 to your computer and use it in GitHub Desktop.
now = DateTime.now.to_time
# You can test different times, like testing 300 days in the future with: now = (DateTime.now + 300).to_time
provisioning_profile = "~/Library/MobileDevice/Provisioning Profiles/11BBCC...AF21BD2.mobileprovision"
expiration_string = `/usr/libexec/PlistBuddy -c 'Print :ExpirationDate' /dev/stdin <<< $(security cms -D -i #{provisioning_profile})`.chomp
expiration_date = DateTime.strptime(expiration_string, '%a %b %d %H:%M:%S PST %Y').to_time
remaining_days = (expiration_date.to_i - now.to_i) / (3600 * 24)
if remaining_days < 1
# Delete ".red" if you aren’t using the Colorize gem
STDERR.puts "ERROR: #{provisioning_profile} is expired".red
elsif remaining_days < 30
# Delete ".yellow" if you aren’t using the Colorize gem
STDOUT.puts "WARNING: #{provisioning_profile} will expire in less than a month (#{expiration_date})".yellow
else
STDOUT.puts "#{provisioning_profile} is safe to use for #{remaining_days} days"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment