def main(arglist=[]): if not len(arglist): arglist = sys.argv[1:] try: optlist, args = getopt.getopt(arglist, 'h', ['help', 'version', 'username='******'password='******'cryptedpassword='******'orgid=','orgpassword='******'profilename=', 'nopackages', 'nohardware', 'norhnsd', 'activationkey=', 'serialnumber=', 'serverUrl=', 'noSSLServerURL=', 'useNoSSLForPackages', 'proxy=', 'proxyUser='******'proxyPassword='******'sslCACert=', 'contactinfo', 'email=',"force",]) except getopt.error, e: print _("Error parsing command list arguments: %s") % e printUsage() sys.exit(1)
def showHelp(): print _("Usage: rhn_check [options]") print "" print _("Available command line options:") print _("-h, --help - this help ") print _("-v, --verbose - increasing verbosity ") print ""
def generateProfileName(hardwareList): hostname = None ipaddr = None profileName = None for hw in hardwareList: if hw['class'] == 'NETINFO': hostname = hw.get('hostname') ipaddr = hw.get('ipaddr') if hostname: profileName = hostname else: if ipaddr: profileName = ipaddr if not profileName: print _("A profilename was not specified, "\ "and hostname and IP address could not be determined "\ "to use as a profilename, please specify one.") sys.exit(-1) return profileName
def showVersion(): print "Red Hat Network Registration Agent "\ "(Kickstart Version) v%s" % rhnReg.version() print "Copyright (c) 1999-2002 Red Hat, Inc." print _("Licensed under terms of the GPL.")
def printUsage(): print _("Usage: rhnreg_ks [options]") print "" print _("Available command line options:") print _("-h, --help - this help ") print _(" --profilename=<value> - specify a profilename") print _(" --username=<value> - specify a username ") print _(" --password=<value> - specify a password ") print _(" --orgid=<value> - specify a organizational id ") print _(" --orgpassword=<value> - specify a organizational password") print _(" --noSSLServerURL=<url> - specify a url for a non ssl server") print _(" --useNoSSLForPackages - dont use ssl to download packages") print _(" --sslCACert=<path> - specify a file to use as the ssl CA cert") print _(" --serverUrl=<URL> - specify a url to use as a server") print _(" --email=<value> - specify a email address ") print _(" --activationkey=<value> - specify an activation key ") print _(" --contactinfo - read contact info from stdin ") print _(" --nohardware - do not probe or upload any hardware info ") print _(" --nopackages - do not profile or upload any package info ") print _(" --force - register the system even if it is already registered") print _(" --version - display the version ") print _(" --proxy - specify an http proxy to use ") print _(" --proxyUser=<value> - specify a username to use with an authenticated http proxy") print _(" --proxyPassword=<value> - specify a password to use with an authenticated http proxy") print ""
# rhnReg.cfg.set("sslCACert", opt[1]) save_cfg = 1 if opt[0] == "--contactinfo": contactinfo = readContactInfo() if opt[0] == "--version": showVersion() sys.exit(-1) if ca_certs: rhnReg.cfg.set("sslCACert", ca_certs) if save_cfg: rhnReg.cfg.save() if rhnReg.registered() and not force: print _("This system is already registered. Use --force to override") sys.exit(-1) if not serialnumber and (not username or not password and not email): print _("A username, password and email address are required "\ "to register a system.") sys.exit(-1) rhnReg.getCaps() if not serialnumber: # reserver the username ret = rhnReg.reserveUser(username, password) rhnReg.registerUser(username, password, email, orgid, orgPassword) # FIXME (20050422): On Solaris we need call into smartpm for this
### # Init ### # quick check for other instances of up2date/rhn_check ##lock = None ##try: ## lock = rhnLockfile.Lockfile('/var/run/up2date.pid') ##except rhnLockfile.LockfileLockedException, e: ## sys.stderr.write("Attempting to run more than one instance of up2date/rhn_check. Exiting.\n") ## sys.exit(0) try: opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "verbose"]) except getopt.error, e: print _("Error parsing command list arguments: %s") % e showHelp() sys.exit(1) for (opt, val) in opts: if opt in ["--verbose", "-v"]: cfg["debug"] = cfg["debug"] + 1 elif opt in ["--help", "-h"]: showHelp() sys.exit(0) # if we're disabled, go down (almost) quietly if os.path.exists(DISABLE_FILE): print "RHN service is disabled. Check %s" % DISABLE_FILE sys.exit(0)