示例#1
0
    def unInstallPHPExtension(extension, extensions):
        try:

            mailUtilities.checkHome()

            if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
                command = 'sudo rpm --nodeps -e  ' + extension + ' -v'
            else:
                command = 'sudo apt-get remove -y  ' + extension

            cmd = shlex.split(command)

            try:

                with open(phpUtilities.installLogPath, 'w') as f:
                    subprocess.call(cmd, stdout=f)

                writeToFile = open(phpUtilities.installLogPath, 'a')
                writeToFile.writelines("PHP Extension Removed.\n")
                writeToFile.close()
                installUtilities.installUtilities.reStartLiteSpeed()
                return 1
            except:
                writeToFile = open(phpUtilities.installLogPath, 'a')
                writeToFile.writelines("Can not un-install Extension.\n")
                writeToFile.close()
                logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
                installUtilities.installUtilities.reStartLiteSpeed()
                return 0

        except BaseException, msg:
            logging.CyberCPLogFileWriter.writeToFile(
                str(msg) + "[unInstallPHPExtension]")
示例#2
0
    def installModSec():
        try:

            mailUtilities.checkHome()

            if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
                command = 'sudo yum install ols-modsecurity -y'
            else:
                command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install ols-modsecurity -y'

            cmd = shlex.split(command)

            with open(modSec.installLogPath, 'w') as f:
                res = subprocess.call(cmd, stdout=f)

            if res == 1:
                writeToFile = open(modSec.installLogPath, 'a')
                writeToFile.writelines("Can not be installed.[404]\n")
                writeToFile.close()
                logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
                return 0
            else:
                writeToFile = open(modSec.installLogPath, 'a')
                writeToFile.writelines("ModSecurity Installed.[200]\n")
                writeToFile.close()

            return 1
        except BaseException, msg:
            logging.CyberCPLogFileWriter.writeToFile(
                str(msg) + "[installModSec]")
示例#3
0
    def unInstallPHPExtension(extension,extensions):
        try:

            mailUtilities.checkHome()

            command = 'sudo rpm --nodeps -e  ' + extension + ' -v'

            cmd = shlex.split(command)

            with open(phpUtilities.installLogPath, 'w') as f:
                res = subprocess.call(cmd, stdout=f)

            if res == 1:
                writeToFile = open(phpUtilities.installLogPath, 'a')
                writeToFile.writelines("Can not un-install Extension.\n")
                writeToFile.close()
                logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
                return 0
            else:
                writeToFile = open(phpUtilities.installLogPath, 'a')
                writeToFile.writelines("PHP Extension Removed.\n")
                writeToFile.close()

            return 1
        except BaseException, msg:
            logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[unInstallPHPExtension]")
示例#4
0
    def installModSec(install, modSecInstall):
        try:

            mailUtilities.checkHome()

            command = 'sudo yum install ols-modsecurity -y'

            cmd = shlex.split(command)

            with open(modSec.installLogPath, 'w') as f:
                res = subprocess.call(cmd, stdout=f)

            if res == 1:
                writeToFile = open(modSec.installLogPath, 'a')
                writeToFile.writelines("Can not be installed.[404]\n")
                writeToFile.close()
                logging.CyberCPLogFileWriter.writeToFile("[Could not Install]")
                return 0
            else:
                writeToFile = open(modSec.installLogPath, 'a')
                writeToFile.writelines("ModSecurity Installed.[200]\n")
                writeToFile.close()

            return 1
        except BaseException, msg:
            logging.CyberCPLogFileWriter.writeToFile(
                str(msg) + "[installModSec]")