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() temp_dir = tempfile.mkdtemp() temp_plist = temp_dir + "/localmanifest.plist" manifest = {} manifest["catalogs"] = cataloglist manifest["managed_installs"] = options.install or [] manifest["managed_uninstalls"] = options.uninstall or [] FoundationPlist.writePlist(manifest, temp_plist) updatecheckresult = updatecheck.check(localmanifestpath=temp_plist) if updatecheckresult == 1: need_to_restart = installer.run() if need_to_restart: print("Please restart immediately!") try: shutil.rmtree(temp_dir) except OSError: print("Could not remove temp directory")
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) exit(exit_code) if not options.install and not options.uninstall: exit() manifest = {} manifest["catalogs"] = cataloglist manifest["managed_installs"] = options.install or [] manifest["managed_uninstalls"] = options.uninstall or [] FoundationPlist.writePlist(manifest, "/tmp/localmanifest.plist") updatecheckresult = updatecheck.check(localmanifestpath="/tmp/localmanifest.plist") if updatecheckresult == 1: need_to_restart = installer.run() if need_to_restart: print "Please restart immediately!"