from munkilib import installer from munkilib import munkicommon p = optparse.OptionParser() p.add_option("--catalog", "-c", action="append", help="Which catalog to consult. May be specified multiple times.") p.add_option("--install", "-i", action="append", help="An item to install. May be specified multiple times.") p.add_option("--uninstall", "-u", action="append", help="An item to uninstall. May be specified multiple times.") p.add_option("--checkstate", action="append", help="Check the state of an item. May be specified multiple times.") options, arguments = p.parse_args() cataloglist = options.catalog or ["production"] if options.checkstate: updatecheck.MACHINE = munkicommon.getMachineFacts() updatecheck.CONDITIONS = munkicommon.getConditions() updatecheck.getCatalogs(cataloglist) for check_item in options.checkstate: installed_state = "unknown" item_pl = updatecheck.getItemDetail(check_item, cataloglist) if item_pl: if updatecheck.installedState(item_pl): installed_state = "installed" exit_code = 0 else: installed_state = "not installed" exit_code = 1 print("%s: %s") % (check_item, installed_state) sys.exit(exit_code) if not options.install and not options.uninstall: sys.exit()
# for the ManagedInstalls domain. If there are additional secure preferences such as HTTP Basic # Auth stored in /private/var/root, you would need to run this as root. import os import sys sys.path.append('/usr/local/munki') sys.path.append( '/Applications/Utilities/Managed Software Update.app/Contents/Resources') from munki import humanReadable from munkilib import updatecheck CATALOGS = ['testing', 'production'] PKGS_ROOT = '/Volumes/munki_repo/pkgs' updatecheck.getCatalogs(CATALOGS) defined_locations = [] for c in CATALOGS: for item in updatecheck.CATALOG[c]['items']: for path_key in [ 'installer_item_location', 'uninstaller_item_location' ]: if path_key in item.keys(): report_item = {} report_item['path'] = os.path.join(PKGS_ROOT, item[path_key]) report_item['size'] = item['installer_item_size'] defined_locations.append(report_item) totalbytes = 0 print "%-100s %-16s" % ("Path", "Size") print
# therefore requires that all client tools are installed and a valid configuration exists # for the ManagedInstalls domain. If there are additional secure preferences such as HTTP Basic # Auth stored in /private/var/root, you would need to run this as root. import os import sys sys.path.append('/usr/local/munki') sys.path.append('/Applications/Utilities/Managed Software Update.app/Contents/Resources') from munki import humanReadable from munkilib import updatecheck CATALOGS = ['testing', 'production', 'adobe', 'deprecated'] PKGS_ROOT = '/Volumes/munki_repo/pkgs' updatecheck.getCatalogs(CATALOGS) defined_locations = [] for c in CATALOGS: for item in updatecheck.CATALOG[c]['items']: for path_key in ['installer_item_location', 'uninstaller_item_location']: if path_key in item.keys(): report_item = {} report_item['path'] = os.path.join(PKGS_ROOT, item[path_key]) report_item['size'] = item['installer_item_size'] defined_locations.append(report_item) totalbytes = 0 print "%-100s %-16s" % ("Path", "Size") print for r, d, f in os.walk(PKGS_ROOT):