-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEA_from_munki-fact_Example-highest_OS_suported.py
More file actions
40 lines (33 loc) · 1.31 KB
/
EA_from_munki-fact_Example-highest_OS_suported.py
File metadata and controls
40 lines (33 loc) · 1.31 KB
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
40
#!/usr/local/munki/munki-python
import os
import sys
sys.path.append('/usr/local/munki')
try:
from munkilib import FoundationPlist
except ImportError:
print('<result>ERROR: Cannot import FoundationPlist</result>')
sys.exit(1)
managed_installs = "/Library/Managed Installs"
report_plist = f'{managed_installs}/ManagedInstallReport.plist'
highest_supported = None
if os.path.exists(report_plist):
try:
msu_report = FoundationPlist.readPlist(report_plist)
except FoundationPlist.NSPropertyListSerializationException:
print(f'<result>ERROR: Cannot read {report_plist}</result>')
sys.exit(1)
monterey_supported = msu_report['Conditions']['monterey_upgrade_supported']
ventura_supported = msu_report['Conditions']['ventura_upgrade_supported']
sonoma_supported = msu_report['Conditions']['sonoma_upgrade_supported']
sequoia_supported = msu_report['Conditions']['sequoia_upgrade_supported']
if sequoia_supported:
highest_supported = "Sequoia"
elif sonoma_supported:
highest_supported = "Sonoma"
elif ventura_supported:
highest_supported = "Ventura"
elif monterey_supported:
highest_supported = "Monterey"
if not highest_supported:
highest_supported = "No valid Upgrades available"
print(f'<result>{highest_supported}</result>')