Exemple #1
0
def check_postgreConfig(postgrePath=''):
    result = True
    if (host_platform == 'windows'):
        base.set_env('PGPASSWORD', install_params['PostgreSQL']['dbPass'])

    rootUser = install_params['PostgreSQL']['root']
    dbUser = install_params['PostgreSQL']['dbUser']
    dbName = install_params['PostgreSQL']['dbName']
    dbPass = install_params['PostgreSQL']['dbPass']
    postgre_path_to_bin = get_postrgre_path_to_bin(postgrePath)
    postgreLoginRoot = get_postgreLoginSrting(rootUser)
    postgreLoginDbUser = get_postgreLoginSrting(dbUser)
    creatdb_path = base.get_script_dir(
    ) + "/../../server/schema/postgresql/createdb.sql"

    if (base.run_command_in_dir(postgre_path_to_bin,
                                postgreLoginRoot + ' -c "\du ' + dbUser +
                                '"')['stdout'].find(dbUser) != -1):
        print('User ' + dbUser + ' is exist')
        if (os.system(postgreLoginDbUser + '-c "\q"') != 0):
            print('Invalid user password!')
            base.print_info('Changing password...')
            result = change_userPass(dbUser, dbPass,
                                     postgre_path_to_bin) and result
    else:
        print('User ' + dbUser + ' not exist!')
        base.print_info('Creating ' + dbName + ' user...')
        result = create_postgreUser(dbUser, dbPass,
                                    postgre_path_to_bin) and result

    if (base.run_command_in_dir(
            postgre_path_to_bin,
            postgreLoginRoot + ' -c "SELECT datname FROM pg_database;"')
        ['stdout'].find('onlyoffice') == -1):
        print('Database ' + dbName + ' not found')
        base.print_info('Creating ' + dbName + ' database...')
        result = create_postgreDb(dbName, postgre_path_to_bin) and configureDb(
            dbUser, dbName, creatdb_path, postgre_path_to_bin)
    else:
        if (base.run_command_in_dir(
                postgre_path_to_bin, postgreLoginRoot +
                '-c "SELECT pg_size_pretty(pg_database_size(' + "'" + dbName +
                "'" + '));"')['stdout'].find('7559 kB') != -1):
            print('Database ' + dbName + ' not configured')
            base.print_info('Configuring ' + dbName + ' database...')
            result = configureDb(dbName, creatdb_path,
                                 postgre_path_to_bin) and result
        print('Database ' + dbName + ' is valid')

    if (base.run_command_in_dir(
            postgre_path_to_bin, postgreLoginRoot + '-c "\l+ ' + dbName +
            '"')['stdout'].find(dbUser + '=CTc/' + rootUser) == -1):
        print('User ' + dbUser + ' has no database privileges!')
        base.print_info('Setting database privileges for user ' + dbUser +
                        '...')
        result = set_dbPrivilegesForUser(dbUser, dbName,
                                         postgre_path_to_bin) and result
    print('User ' + dbUser + ' has database privileges')

    return result
Exemple #2
0
def check_MySQLConfig(mysqlPath = ''):
  result = True
  mysqlLoginSrt = get_mysqlLoginSrting()
  mysql_path_to_bin = get_mysql_path_to_bin(mysqlPath)

  if (base.run_command_in_dir(mysql_path_to_bin, mysqlLoginSrt + ' -e "SHOW DATABASES;"')['stdout'].find('onlyoffice') == -1):
    print('Database onlyoffice not found')
    creatdb_path = base.get_script_dir() + "/../../server/schema/mysql/createdb.sql"
    result = execMySQLScript(mysqlPath, creatdb_path)
  if (base.run_command_in_dir(mysql_path_to_bin, mysqlLoginSrt + ' -e "SELECT plugin from mysql.user where User='******'" + install_params['MySQLServer']['user'] + "';" + '"')['stdout'].find('mysql_native_password') == -1):
    print('Password encryption is not valid')
    result = set_MySQLEncrypt(mysqlPath, 'mysql_native_password') and result

  return result
Exemple #3
0
def check_erlang():
    dependence = CDependencies()
    base.print_info('Check installed Erlang')

    erlangBitness = ""
    erlang_path_home = get_erlang_path_to_bin()
    if base.is_exist(erlang_path_home) == False:
        dependence.append_uninstall('Erlang')
        dependence.append_uninstall('RabbitMQ')
        return dependence

    if ("" != erlang_path_home or host_platform != 'windows'):
        erlangBitness = base.run_command_in_dir(
            erlang_path_home,
            'erl -eval "erlang:display(erlang:system_info(wordsize)), halt()." -noshell'
        )['stdout']

    if (erlangBitness == '8'):
        print("Installed Erlang is valid")
        return dependence

    print('Need Erlang with bitness x64')

    if (host_platform == 'windows'):
        dependence.append_removepath(os.environ['AppData'] + '\\RabbitMQ\\db')
        dependence.append_uninstall('Erlang')
        dependence.append_uninstall('RabbitMQ')
    else:
        dependence.append_uninstall('erlang')
        dependence.append_uninstall('rabbitmq-server')
    dependence.append_install('Erlang')
    dependence.append_install('RabbitMQ')

    return dependence
Exemple #4
0
def check_mysqlServer():
    base.print_info('Check MySQL Server')
    dependence = CDependencies()
    mysqlLoginSrt = get_mysqlLoginSrting()
    connectionString = mysqlLoginSrt + ' -e "SHOW GLOBAL VARIABLES LIKE ' + r"'PORT';" + '"'

    if (host_platform != 'windows'):
        result = os.system(mysqlLoginSrt + ' -e "exit"')
        if (result == 0):
            connectionResult = base.run_command(connectionString)['stdout']
            if (connectionResult.find('port') != -1 and connectionResult.find(
                    install_params['MySQLServer']['port']) != -1):
                print('MySQL configuration is valid')
                dependence.sqlPath = 'mysql'
                return dependence
        print('Valid MySQL Server not found')
        dependence.append_install('MySQLServer')
        dependence.append_uninstall('mysql-server')
        return dependence

    arrInfo = get_mysqlServersInfo()
    for info in arrInfo:
        if (base.is_dir(info['Location']) == False):
            continue

        mysql_full_name = 'MySQL Server ' + info['Version'] + ' '

        connectionResult = base.run_command_in_dir(
            get_mysql_path_to_bin(info['Location']),
            connectionString)['stdout']
        if (connectionResult.find('port') != -1 and connectionResult.find(
                install_params['MySQLServer']['port']) != -1):
            print(mysql_full_name + 'configuration is valid')
            dependence.sqlPath = info['Location']
            return dependence
        print(mysql_full_name + 'configuration is not valid')

    print('Valid MySQL Server not found')
    dependence.append_uninstall('MySQL Server')
    dependence.append_uninstall('MySQL Installer')
    dependence.append_install('MySQLInstaller')
    dependence.append_install('MySQLServer')

    MySQLData = os.environ['ProgramData'] + '\\MySQL\\'
    if base.is_exist(MySQLData) == False:
        return dependence

    dir = os.listdir(MySQLData)
    for path in dir:
        if (path.find('MySQL Server') != -1) and (base.is_file(MySQLData +
                                                               path) == False):
            dependence.append_removepath(MySQLData + path)

    return dependence
Exemple #5
0
def check_postgreSQL():
    base.print_info('Check PostgreSQL')

    dependence = CDependencies()

    postgreLoginSrt = get_postgreLoginSrting(
        install_params['PostgreSQL']['root'])
    connectionString = postgreLoginSrt + ' -c "SELECT setting FROM pg_settings WHERE name = ' + "'port'" + ';"'

    if (host_platform == 'linux'):
        result = os.system(postgreLoginSrt + ' -c "\q"')
        connectionResult = base.run_command(connectionString)['stdout']

        if (result != 0 or connectionResult.find(
                install_params['PostgreSQL']['dbPort']) == -1):
            print('Valid PostgreSQL not found!')
            dependence.append_install('PostgreSQL')
            dependence.append_uninstall('PostgreSQL')
        else:
            print('PostreSQL is installed')
            dependence.sqlPath = 'psql'
        return dependence

    arrInfo = get_postgreSQLInfo()
    base.set_env('PGPASSWORD', install_params['PostgreSQL']['dbPass'])
    for info in arrInfo:
        if (base.is_dir(info['Location']) == False):
            continue

        postgre_full_name = 'PostgreSQL ' + info['Version'][:2] + ' '
        connectionResult = base.run_command_in_dir(
            get_postrgre_path_to_bin(info['Location']),
            connectionString)['stdout']

        if (connectionResult.find(install_params['PostgreSQL']['dbPort']) !=
                -1):
            print(postgre_full_name + 'configuration is valid')
            dependence.sqlPath = info['Location']
            return dependence
        print(postgre_full_name + 'configuration is not valid')

    print('Valid PostgreSQL not found')

    dependence.append_uninstall('PostgreSQL')
    dependence.append_install('PostgreSQL')

    for info in arrInfo:
        dependence.append_removepath(info['DataLocation'])

    return dependence