Ejemplo n.º 1
0
def install_oracle_java(ver='1.6.0_27'):
    
    if ver != '1.6.0_27':
        raise RuntimeError("Only '1.6.0_27' version of java support by now")
    
    JAVAC = check_cmd('javac')
    JAVA_RT = check_cmd('java')
    
    if JAVAC and JAVA_RT:
        return
    
    JAVAH = '/usr/local/java'
    
    JDK_DIR = os.path.join(JAVAH, 'jdk1.6.0_27')
    JRE_DIR = os.path.join(JAVAH, 'jre1.6.0_27')
    
    JDK_URL = 'http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jdk-6u27-linux-x64.bin'
    JRE_URL = 'http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jre-6u27-linux-x64.bin'
    
    if not exists(JAVAH):
        sudo('mkdir ' + JAVAH)

    with cd(JAVAH):
        expect_cmd = 'spawn sh {0};' + \
                     ' expect "Press Enter to continue.....\\n"; send "\\n"'
        
        if not exists(os.path.join(JDK_DIR,'bin/javac')):
            
            if exists(JDK_DIR):
                sudo('rm -rf {0}/*'.format(JDK_DIR))
                
            wget(JDK_URL, use_sudo=True)    
            sudo("expect -c '{0}'".format(
                expect_cmd.format('jdk-6u27-linux-x64.bin')))
            sudo('rm ' + 'jdk-6u27-linux-x64.bin')
            
        if not exists(os.path.join(JRE_DIR,'bin/java')):
            
            if exists(JRE_DIR):
                sudo('rm -rf {0}/*'.format(JRE_DIR))
            
            wget(JRE_URL, use_sudo=True)    
            sudo("expect -c '{0}'".format(
                expect_cmd.format('jre-6u27-linux-x64.bin')))
            sudo('rm ' + 'jre-6u27-linux-x64.bin')
    ln1 = 'export JAVA_HOME=' + JRE_DIR
    ln2 = 'export PATH="$PATH:{0}/bin:{1}/bin"'.format(JRE_DIR, JDK_DIR)
    
    profile = get_rf('/etc/profile')
    put_rf('/etc/profile',
           "\n".join((profile, ln1, ln2, '')),
           use_sudo=True)
Ejemplo n.º 2
0
def install_src(ver='0.8.7'):
    cas_install_root = '/opt/cassandra'
    if exists(os.path.join(cas_install_root,
                           'apache-cassandra-{0}/bin/cassandra'.format(ver))):
        return
    
    if not exists(cas_install_root):
        sudo('mkdir ' + cas_install_root)
        
    fname = "apache-cassandra-{0}-bin.tar.gz".format(ver)
    wget('http://apache.vc.ukrtel.net//cassandra/{0}/{1}'.format(ver, fname))
    sudo('mv {0} {1}'.format(fname, cas_install_root))
    with cd(cas_install_root):
        sudo('tar -zxvf ' + fname)
        sudo('rm ' + fname)
        with cd('apache-cassandra-{0}'.format(ver)):
            sudo('mkdir -p /var/log/cassandra')
            name = str(run('whoami'))
            sudo('chown -R {0} /var/log/cassandra'.format(name))
            sudo('mkdir -p /var/lib/cassandra')
            sudo('chown -R {0} /var/lib/cassandra'.format(name))
            sudo(('ln -s /opt/cassandra/apache-cassandra-{0} ' + \
                     '/opt/cassandra/curr').format(ver))