This repository has been archived by the owner on Aug 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup_assistant_profiler.py
executable file
·39 lines (31 loc) · 1.44 KB
/
setup_assistant_profiler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
import sys
import plistlib
import subprocess
# Assume that the profile we want to modify is stored in this path:
profilePath = "/Library/Profiles/SetupAssistant.mobileconfig"
try:
plistContent = plistlib.readPlist(profilePath)
except IOError:
print >> sys.stderr, "Error: can't read profile at %s" % profilePath
sys.exit(1)
cmd = ['/usr/bin/sw_vers', '-productVersion']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(productOut, productErr) = proc.communicate()
cmd = ['/usr/bin/sw_vers', '-buildVersion']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(buildOut, buildErr) = proc.communicate()
plistContent['PayloadContent'][0]['PayloadContent']['com.apple.SetupAssistant']['Set-Once'][0]['mcx_preference_settings']['LastSeenCloudProductVersion'] = productOut.strip()
plistContent['PayloadContent'][0]['PayloadContent']['com.apple.SetupAssistant']['Set-Once'][0]['mcx_preference_settings']['LastSeenBuddyBuildVersion'] = buildOut.strip()
try:
plistlib.writePlist(plistContent, profilePath)
except IOError:
print >> sys.stderr, "Error: can't write profile at %s" % profilePath
sys.exit(1)
cmd = ['/usr/bin/profiles', '-IvF', profilePath]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(profileOut, profileErr) = proc.communicate()
if profileErr:
print >> sys.stderr, 'Error: %s' % profileErr
sys.exit(1)
print profileOut