Created
April 1, 2011 18:27
-
-
Save glarizza/898612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # munkicli <action> packagename repoURL <args> | |
| # | |
| # Actions: install, uninstall, status | |
| # Args: --version, | |
| # | |
| # Process - accept the package name, query the manifest for package info (package id plist), | |
| # check if installed (and version), install/update/uninstall package or list status. | |
| import os | |
| import subprocess | |
| from munkilib import munkicommon | |
| from munkilib import updatecheck | |
| from munkilib import installer | |
| from munkilib import munkistatus | |
| from munkilib import appleupdates | |
| from munkilib import FoundationPlist | |
| from munkilib import utils | |
| import Foundation | |
| localmanifest = '/Users/glarizza/Desktop/curl/testing' | |
| filepathurl = 'http://helpdesk.huronhs.com/munki/manifests/testing' | |
| filepath = '/Users/glarizza/Desktop/testing.txt' | |
| pkgpath = '/Users/glarizza/Desktop/puppet-2.6.2.pkg' | |
| ppkgsinfo = 'http://helpdesk.huronhs.com/munki/pkgsinfo/puppet-2.6.4.pkginfo' | |
| localpkgsinfo = '/Users/glarizza/Desktop/curl/puppet-2.6.4.pkginfo' | |
| p264 = '/Users/glarizza/Desktop/Puppet_Installer-2.6.4.pkg' | |
| pplist = 'com.puppetlabs.Puppet_Installer' | |
| fplist = 'com.reductivelabs.facter' | |
| pkginfo = munkicommon.getInstallerPkgInfo(pkgpath) | |
| preceipt = munkicommon.getInstalledPackageVersion(pplist) | |
| freceipt = munkicommon.getInstalledPackageVersion(fplist) | |
| # Pull Testing manifest to a directory | |
| if not os.path.exists(localmanifest): | |
| print "It's not here - downloading manifest" | |
| updatecheck.curl(filepathurl, localmanifest) | |
| else: | |
| print "Manifest exists." | |
| # Pull puppet pkgsinfo to a directory | |
| if not os.path.exists(localpkgsinfo): | |
| print "It's not here - downloading pkgsinfo" | |
| updatecheck.curl(ppkgsinfo, localpkgsinfo) | |
| else: | |
| print "Pkgsinfo exists." | |
| # Find and print plist info | |
| manifestplist = FoundationPlist.readPlist(localmanifest) | |
| pkgsinfoplist = FoundationPlist.readPlist(localpkgsinfo) | |
| print manifestplist['managed_installs'] | |
| print pkgsinfoplist | |
| #print pkgsinfoplist['receipts']['packageid'] | |
| # Gets a list of all installed packages and their versions | |
| updatecheck.getInstalledPackages() | |
| try: | |
| print updatecheck.INSTALLEDPKGS['com.doohicky.org'] | |
| except KeyError: | |
| print "Your package wasn't found." | |
| # updatecheck.processOptionalInstall --> checks installed state | |
| # Accept | |
| ##InstallInfo.plist | |
| # server = munkicommon.pref('ManifestURL') or \ | |
| # munkicommon.pref('SoftwareRepoURL') | |
| # | |
| # server = 'http://helpdesk.huronhs.com/munki/manifests' | |
| # result = updatecheck.checkServer(server) | |
| # if result != (0, 'OK'): | |
| # munkicommon.display_error( | |
| # 'managedsoftwareupdate: server check for %s failed: %s' | |
| # % (server, str(result))) | |
| # if options.manualcheck: | |
| # # record our result | |
| # recordUpdateCheckResult(-1) | |
| # # connect to socket and quit | |
| # munkistatus.activate() | |
| # munkistatus.quit() | |
| # munkicommon.cleanUpTmpDir() | |
| # exit(-1) | |
| # else: | |
| # print "It's okay!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment