Example #1
0
File: distrib.py Project: vinc/oct
def install(packages, verbosity):
    distribution = get_distrib()
    cmd = list()
    if distribution == "debian":
        os.putenv("SKIP_IPLIKE_INSTALL", "1")
        system.exec_cmd(["/usr/bin/debconf-set-selections"],
                   "sun-java6-jre shared/accepted-sun-dlj-v1-1 select true")
        cmd.extend(["/usr/bin/apt-get", "install", "--assume-yes", "--force-yes"])
        # "--force-yes" is not a good idea... Used during upgrade.
        if verbosity == 0:
           cmd.extend(["--quiet", "2"])
        elif verbosity == 1:
          cmd.extend(["--quiet", "1"])
    elif distribution == "redhat":
        cmd.extend(["/usr/bin/yum", "install", "-y"])
        #if verbosity == 0:
        #   cmd.extend(["--quiet"])
        if verbosity > 1:
          cmd.extend(["--verbose"])
    cmd.extend(packages)
    system.exec_cmd(cmd, verbosity=verbosity)
Example #2
0
File: distrib.py Project: vinc/oct
     # In Python < 2.6 there is no timeout for urllib2.urlopen()
     default_timeout = socket.getdefaulttimeout()
     socket.setdefaulttimeout(5) # so we have to fixe one
     uri = "http://debian.opennms.org/OPENNMS-GPG-KEY"
     try:
         url = urllib2.urlopen(uri) # Get the repository key
     except urllib2.URLError, e:
         sys.exit("Failed to connect to '%s': %s" % (uri, e))
     socket.setdefaulttimeout(default_timeout)
     key = ""
     for line in url.readlines(): # Read the repository key
         key += line
     if verbosity > 1:
         print key
     print "Exporting the key to APT keyring..."
     system.exec_cmd(["/usr/bin/apt-key", "add", "-"], key)
     print
     print "Updating the system..."
     cmd = ["/usr/bin/apt-get", "update", "--yes"]
     if verbosity == 0:
         cmd.extend(["--quiet", "2"])
     elif verbosity == 1:
         cmd.extend(["--quiet", "1"])
     system.exec_cmd(cmd)
 elif distribution == "redhat":
     assert version == "stable" or version == "testing" or \
            version == "unstable"
     cmd = ["/bin/rpm", "--upgrade",
            "http://yum.opennms.org/repofiles/" \
            "opennms-repo-%s-rhel5.noarch.rpm" % version]
     if verbosity > 0: