Beispiel #1
0
def version():
    print "Cpnginx  Version : " + cpnginx_version()
    nginxversion = backport.check_output(['/usr/local/nginx/sbin/nginx -v'],
                                         shell=True)
    apacheversion = backport.check_output(
        ["httpd -v | head -1  | awk '{ print $3 }'"], shell=True)
    print "Apache version : " + apacheversion.strip()
Beispiel #2
0
def ea4_default_php_fpm():
    rpms = conf.cpphpfpm_rpms
    package = ""
    for rpm in rpms:
        package += "ea-" + rpm + "-php-fpm ea-" + rpm + "-php-cli "
    command = 'yum -y install ' + package
    print "Installing  php-fpm(s)  .. " + shellcolor.green + "starting" + shellcolor.end
    subprocess.call(command, shell=True)
    fpmfinal = {}
    defaultphp = backport.check_output(["php", "-r", "echo phpversion();"])
    for rpm in rpms:
        phpfpm = "/opt/cpanel/ea-" + rpm + "/root/usr/sbin/php-fpm"
        if os.path.exists(phpfpm):
            print "PHP-FPM  found .. " + shellcolor.green + phpfpm + shellcolor.end
            pversioncmd = "/opt/cpanel/ea-" + rpm + "/root/usr/bin/php"
            pversion = backport.check_output(
                [pversioncmd, "-r", "echo phpversion();"])
            if pversion == defaultphp:
                print shellcolor.green + " ===== This is the server default php version " + pversion + "==========" + shellcolor.end
                default = "1"
            else:
                default = "0"
            version = pversion.split(".")
            conffile = "/opt/cpanel/ea-" + rpm + "/root/etc/php-fpm.conf"
            confdir = "/opt/cpanel/ea-" + rpm + "/root/etc/php-fpm.d"
            service = "ea-" + rpm + "-php-fpm.service"
            serviceold = "ea-" + rpm + "-php-fpm"
            fpmfinal[rpm] = [
                version[0], version[1], version[2], phpfpm, conffile, confdir,
                service, default
            ]
            enable_service = "systemctl enable ea-" + rpm + "-php-fpm.service"
            enable_service_old = "chkconfig --add ea-" + rpm + "-php-fpm && chkconfig ea-" + rpm + "-php-fpm on"
            copypool = "cp -f /etc/cpnginx/build/templates/fpm/www.conf /opt/cpanel/ea-" + rpm + "/root/etc/php-fpm.d/"
            startfpm = "systemctl restart  ea-" + rpm + "-php-fpm.service && systemctl status ea-" + rpm + "-php-fpm.service"
            startfpm_old = "service ea-" + rpm + "-php-fpm restart"
            subprocess.call(copypool, shell=True)
            if os.path.exists('/lib/systemd/system'):
                subprocess.call(enable_service, shell=True)
                print shellcolor.pink + "Starting php fpm  service version .. " + shellcolor.end + shellcolor.yellow + pversion + shellcolor.end
                subprocess.call(startfpm, shell=True)
            else:
                subprocess.call(enable_service_old, shell=True)
                print shellcolor.pink + "Starting php fpm  service version .. " + shellcolor.end + shellcolor.yellow + pversion + shellcolor.end
                subprocess.call(startfpm_old, shell=True)

    print "Installing  php-fpm(s)  .. " + shellcolor.green + "completed" + shellcolor.end
    return fpmfinal
Beispiel #3
0
def main():
    print "Running cpnginx  Apache Domlog  Fix Hook "
    cmd = "sed -i s/%h/%a/g /var/cpanel/templates/apache2_4/ea4_main.default"
    subprocess.call(cmd, shell=True)
    cmdap = "/usr/local/cpanel/scripts/rebuildhttpdconf"
    result = backport.check_output(cmdap, shell=True)
    print "Cpnginx post hook completed"
Beispiel #4
0
def main():
    lines = read_in()
    data=lines[0]
    cpdata = json.loads(data,object_hook=_decode_dict)
    domain=cpdata['data']['args']['domain']
    cmd="/usr/local/cpanel/scripts/nginxctl rmvhost "+domain
    out=backport.check_output(cmd,shell=True)
    print 1
Beispiel #5
0
def main():
    lines = read_in()
    data=lines[0]
    cpdata = json.loads(data,object_hook=_decode_dict)
    cpuser=cpdata['data']['user']
    cmd="/usr/local/cpanel/scripts/nginxctl rmuservhost "+cpuser
    #subprocess.call(cmd,shell=True)
    out=backport.check_output(cmd,shell=True)
    print 1
Beispiel #6
0
def main():
    lines = read_in()
    data = lines[0]
    cpdata = json.loads(data, object_hook=_decode_dict)
    sub = cpdata['data']['args']['domain']
    domain = sub.replace("_", ".", 1)
    cmd = "/usr/local/cpanel/scripts/nginxctl rmvhost " + domain
    #subprocess.call(cmd,shell=True)
    out = backport.check_output(cmd, shell=True)
    print 1
Beispiel #7
0
def buildremoteip():
    command = ['httpd -M | grep remoteip_module']
    DEVNULL = open(os.devnull, 'wb')
    proc = subprocess.Popen(command,
                            stdout=DEVNULL,
                            stderr=DEVNULL,
                            shell=True)
    (output, err) = proc.communicate()
    p_status = proc.wait()
    if p_status == 1:
        command1 = ['yum -y install ea-apache24-mod_remoteip']
        subprocess.call(command1, shell=True)
        print "Installing  mod-remoteip for Apache .. " + shellcolor.green + "starting" + shellcolor.end
        command2 = ['/usr/local/cpanel/scripts/ipusage| awk \'{print $1}\'']
        y = backport.check_output(command2, shell=True).split()
        remoteip = "RemoteIPHeader X-Real-IP\nRemoteIPInternalProxy 127.0.0.1\n"
        for i in y:
            remoteip += "RemoteIPInternalProxy " + i + "\n"
        conf = open("/etc/apache2/conf.modules.d/361_mod_cpgninx.conf", "w")
        conf.write(remoteip)
        conf.close()
        print "Installing  mod-remoteip for Apache .. " + shellcolor.green + "done" + shellcolor.end
        result = "ok"
    else:
        print "Installing  mod-remoteip configurations for  Apache .. " + shellcolor.green + "starting" + shellcolor.end
        command2 = ['/usr/local/cpanel/scripts/ipusage| awk \'{print $1}\'']
        y = backport.check_output(command2, shell=True).split()
        remoteip = "RemoteIPHeader X-Real-IP\nRemoteIPInternalProxy 127.0.0.1\n"
        for i in y:
            remoteip += "RemoteIPInternalProxy " + i + "\n"
        conf = open("/etc/apache2/conf.modules.d/361_mod_cpgninx.conf", "w")
        conf.write(remoteip)
        conf.close()
        print "Installing  mod-remoteip configurations for  Apache .. " + shellcolor.green + "done" + shellcolor.end
        result = "ok"
    sys.stdout.write("Running Apache Domlog  Fix .. ")
    cmd = "sed -i s/%h/%a/g /var/cpanel/templates/apache2_4/ea4_main.default"
    subprocess.call(cmd, shell=True)
    cmdap = "/usr/local/cpanel/scripts/rebuildhttpdconf"
    result = backport.check_output(cmdap, shell=True)
    print shellcolor.green + "done" + shellcolor.end

    return result
def main():
    lines = read_in()
    data=lines[0]
    cpdata = json.loads(data,object_hook=_decode_dict)
    #with open('/var/log/hook.txt' , 'w+') as a :
    #    a.write(cpdata)
    domain=cpdata['data']['args']['domain']
    cmd="/usr/local/cpanel/scripts/nginxctl rmvhost "+domain
    #subprocess.call(cmd,shell=True)
    out=backport.check_output(cmd,shell=True)
    print 1