Created
April 28, 2017 18:46
-
-
Save nmcspadden/5263eafaa882b046d535fb7b9a4366c5 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
"""Verify the date because Apple can't.""" | |
import datetime | |
import shell_tools | |
import sys_tools | |
current_year = int(datetime.datetime.now().year) | |
sys_tools.log('CPE-date_verification', 'Year is: %s' % current_year) | |
if current_year > 2017: | |
# If the date is > 2017, then Apple has fucked up again | |
sys_tools.log('CPE-date_verification', 'Year is > 2017: %s' % current_year) | |
# Manually set the current date to something reasonable, because if it's | |
# too far in advance, ntpdate can't fix itself | |
system_results = shell_tools.run_subp([ | |
'/usr/bin/systemsetup', | |
'-setdate', | |
'04/20/17' | |
]) | |
if not system_results['success']: | |
sys_tools.log('CPE-date_verification', "Fixing the date didn't work!") | |
results = shell_tools.run_subp([ | |
'ntpdate', | |
'ntp.vip.facebook.com', | |
]) | |
if not results['success']: | |
sys_tools.log('CPE-date_verification', "ntpdate didn't work!") | |
sys_tools.log( | |
'CPE-date_verification', | |
'Adjusted time. Current year is: %s ' % int(datetime.datetime.now().year) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment