Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from arubdesu/omnibus
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
arubdesu committed Feb 16, 2016
2 parents 870b95f + 9e65de2 commit e097e6a
Showing 1 changed file with 53 additions and 37 deletions.
90 changes: 53 additions & 37 deletions extinguish.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,31 @@
import uuid


def build_payload(bundle_id, payload_id, in_uuid):
def build_payload(bundle_id):
"""populates payload with bundle_id, returns array"""
forced_dict = {"mcx_preference_settings": {"SUAutomaticallyUpdate": False,
"SUEnableAutomaticChecks": False,
"SUFeedURL": "https://127.0.0.1"}
}
bundle_dict = {"Forced": [forced_dict]}
content_dict = {bundle_id: bundle_dict}
payload_dict = {"PayloadContent": content_dict,
"PayloadEnabled": True,
"PayloadIdentifier": payload_id,
"PayloadType": "com.apple.ManagedClient.preferences",
"PayloadUUID": in_uuid,
"PayloadVersion": 1,
}
return payload_dict
return content_dict


def integrate_whole(payload, github_acct, org, out_uuid):
def integrate_whole(payload, org, out_uuid, group):
"""integrates payload into whole of profile, returns dict"""
if type(payload) != list:
payload = [payload]
if group:
in_uuid = str(uuid.uuid4())
nested = {"PayloadContent": payload,
"PayloadEnabled": True,
"PayloadIdentifier": 'SparkleDisabler',
"PayloadType": "com.apple.ManagedClient.preferences",
"PayloadUUID": in_uuid,
"PayloadVersion": 1,
}
payload = [nested]
else:
payload = payload
finished_profile = {"PayloadContent": payload,
"PayloadOrganization": org,
"PayloadRemovalDisallowed": True,
Expand Down Expand Up @@ -76,6 +79,7 @@ def main():
options = parser.parse_args()
#build_payload, handling one-off drag-drops first
out_uuid = str(uuid.uuid4())
group = False
if options.app_bundle:
if options.app_bundle.endswith('.app'):
try:
Expand All @@ -84,17 +88,23 @@ def main():
appname = bundle_id.split('.')[-1]
in_uuid = str(uuid.uuid4())
payload_id = "SparkleDisabler." + out_uuid + ".alacarte.customsettings." + in_uuid
payload = build_payload(bundle_id, payload_id, in_uuid)
whole = integrate_whole(payload, options.profile_id,
options.org, out_uuid)
payload = build_payload(bundle_id)
payload_dict = {"PayloadContent": payload,
"PayloadEnabled": True,
"PayloadIdentifier": payload_id,
"PayloadType": "com.apple.ManagedClient.preferences",
"PayloadUUID": in_uuid,
"PayloadVersion": 1,
}
inside_dict = [payload_dict]
whole = integrate_whole(inside_dict, options.org, out_uuid, group)
extend_dict = {"PayloadDescription": "Custom settings to disable "
"sparkle updates for %s.app" % appname,
"PayloadDisplayName": "SparkleDisabler: %s" % bundle_id,
"PayloadIdentifier": options.profile_id + '.' + appname,
}
whole.update(extend_dict)

mobilecfg_path = ('').join([os.getcwd(), '/disable_autoupdates_',
mobilecfg_path = ''.join([os.getcwd(), '/disable_autoupdates_',
bundle_id.split('.')[-1], '.mobileconfig'])
with open(mobilecfg_path, 'w') as final:
plistlib.writePlist(whole, final)
Expand All @@ -110,44 +120,50 @@ def main():
if not to_process:
print parser.print_help()
sys.exit(0)
mobilecfg_path, whole = '', ''
if options.group:
mobilecfg_path = ('').join([os.getcwd(), '/disable_all_sparkle_',
'autoupdates.mobileconfig'])
payload_list = []
payload_list = {}
for bundle_id in to_process:
#gen uuid's for containing profile and payload
appname = bundle_id.split('.')[-1]
if options.group:
in_uuid = str(uuid.uuid4())
payload_id = ('').join(["SparkleDisabler.", out_uuid,
".alacarte.customsettings.", in_uuid])
payload = build_payload(bundle_id, payload_id, in_uuid)
payload_list.append(payload)
else:
payload = build_payload(bundle_id)
if not options.group:
in_uuid, out_uuid = str(uuid.uuid4()), str(uuid.uuid4())
payload_id = ('').join(["SparkleDisabler.", out_uuid,
payload_id = ''.join(["SparkleDisabler.", out_uuid,
".alacarte.customsettings.", in_uuid])
payload = build_payload(bundle_id, payload_id, in_uuid)
whole = integrate_whole(payload, options.profile_id,
options.org, out_uuid)
payload_dict = {"PayloadContent": payload,
"PayloadEnabled": True,
"PayloadIdentifier": payload_id,
"PayloadType": "com.apple.ManagedClient.preferences",
"PayloadUUID": in_uuid,
"PayloadVersion": 1,
}
inside_dict = [payload_dict]
whole = integrate_whole(inside_dict, options.org, out_uuid, group)
extend_dict = {"PayloadDescription": "Custom settings to disable "
"sparkle updates for %s.app" % appname,
"PayloadDisplayName": "SparkleDisabler: %s" % bundle_id,
"PayloadIdentifier": options.profile_id + '.' + appname,
}
whole.update(extend_dict)
mobilecfg_path = ('').join([os.getcwd(), '/disable_autoupdates_',
mobilecfg_path = ''.join([os.getcwd(), '/disable_autoupdates_',
bundle_id.split('.')[-1], '.mobileconfig'])
with open(mobilecfg_path, 'w') as final:
plistlib.writePlist(whole, final)

else:
payload_list[bundle_id] = payload[bundle_id]
if options.group:
whole = integrate_whole(payload_list, options.profile_id,
options.org, out_uuid)
group = True
mobilecfg_path = ''.join([os.getcwd(), '/disable_all_sparkle_',
'autoupdates.mobileconfig'])
out_uuid = str(uuid.uuid4())
payload_id = ''.join(["SparkleDisabler.", out_uuid,
".alacarte.customsettings"])

whole = integrate_whole(payload_list, options.org, out_uuid, group)
extend_dict = {"PayloadDescription": "Custom settings to disable "
"all sparkle apps from updating over http",
"PayloadDisplayName": "ExtinguishGeneratedSparkleDisabler",
"PayloadIdentifier": options.profile_id
"PayloadIdentifier": payload_id
}
whole.update(extend_dict)
with open(mobilecfg_path, 'w') as final:
Expand Down

0 comments on commit e097e6a

Please sign in to comment.