Ejemplo n.º 1
0
def check_db_ver():
    db_ver = utils.get_db_ver()
    db_min_ver = utils.get_min_db_ver()
    db_min_ver_int = utils.get_int_ver(db_min_ver)

    if settings.local.version_int < db_min_ver_int:
        logger.error('Pritunl version not compatible with database version',
            'setup',
            db_version=db_ver,
            db_min_version=db_min_ver,
            server_version=settings.local.version,
        )
        exit(75)

    return utils.get_int_ver(MIN_DATABASE_VER) > db_min_ver_int
Ejemplo n.º 2
0
def setup_local():
    settings.local.iptables_wait = utils.check_iptables_wait()

    if settings.conf.host_id:
        settings.local.host_id = settings.conf.host_id
    elif os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, 'r') as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, 'w') as uuid_file:
            uuid_file.write(settings.local.host_id)

    if os.path.isfile(settings.conf.setup_key_path):
        with open(settings.conf.setup_key_path, 'r') as setup_key_file:
            settings.local.setup_key = setup_key_file.read().strip()
    else:
        settings.local.setup_key = uuid.uuid4().hex

        with open(settings.conf.setup_key_path, 'w') as setup_key_file:
            os.chmod(settings.conf.setup_key_path, 0600)
            setup_key_file.write(settings.local.setup_key)

    settings.local.version = __version__
    settings.local.version_int = utils.get_int_ver(__version__)
Ejemplo n.º 3
0
def setup_local():
    settings.local.openssl_heartbleed = not utils.check_openssl()
    settings.local.iptables_wait = utils.check_iptables_wait()

    if settings.conf.host_id:
        settings.local.host_id = settings.conf.host_id
    elif os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, 'r') as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, 'w') as uuid_file:
            uuid_file.write(settings.local.host_id)

    if os.path.isfile(settings.conf.setup_key_path):
        with open(settings.conf.setup_key_path, 'r') as setup_key_file:
            settings.local.setup_key = setup_key_file.read().strip()
    else:
        settings.local.setup_key = uuid.uuid4().hex

        with open(settings.conf.setup_key_path, 'w') as setup_key_file:
            os.chmod(settings.conf.setup_key_path, 0600)
            setup_key_file.write(settings.local.setup_key)

    settings.local.version = __version__
    settings.local.version_int = utils.get_int_ver(__version__)
Ejemplo n.º 4
0
def check_db_ver():
    db_ver = utils.get_db_ver()
    db_min_ver = utils.get_min_db_ver()
    db_min_ver_int = utils.get_int_ver(db_min_ver)

    if settings.local.version_int < db_min_ver_int:
        logger.error(
            'Pritunl version not compatible with database version',
            'setup',
            db_version=db_ver,
            db_min_version=db_min_ver,
            server_version=settings.local.version,
        )
        exit(75)

    return utils.get_int_ver(MIN_DATABASE_VER) > db_min_ver_int
Ejemplo n.º 5
0
def upgrade_server():
    if utils.get_db_ver_int() < utils.get_int_ver('1.4.0.0'):
        logger.info('Running 1.4 database upgrade', 'upgrade')
        upgrade_1_4()
        utils.set_db_ver('1.4.0.0')
    else:
        logger.info('No upgrade needed', 'upgrade')
Ejemplo n.º 6
0
def upgrade_server():
    upgraded = False

    if utils.get_db_ver_int() < utils.get_int_ver('1.4.0.0'):
        upgraded = True
        logger.info('Running 1.4 database upgrade', 'upgrade')
        upgrade_1_4()
        utils.set_db_ver('1.4.0.0')

    if utils.get_db_ver_int() < utils.get_int_ver('1.5.0.0'):
        upgraded = True
        logger.info('Running 1.5 database upgrade', 'upgrade')
        upgrade_1_5()
        utils.set_db_ver('1.5.0.0')

    if not upgraded:
        logger.info('No upgrade needed', 'upgrade')
Ejemplo n.º 7
0
def setup_local():
    settings.local.openssl_heartbleed = not utils.check_openssl()

    if os.path.isfile(settings.conf.uuid_path):
        with open(settings.conf.uuid_path, 'r') as uuid_file:
            settings.local.host_id = uuid_file.read().strip()
    else:
        settings.local.host_id = uuid.uuid4().hex

        dir_path = os.path.dirname(settings.conf.uuid_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        with open(settings.conf.uuid_path, 'w') as uuid_file:
            uuid_file.write(settings.local.host_id)

    settings.local.version = __version__
    settings.local.version_int = utils.get_int_ver(__version__)