Created
June 25, 2019 00:10
-
-
Save adamyanalunas/944284b76a2d40342868e2da6d352f23 to your computer and use it in GitHub Desktop.
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
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