コード例 #1
0
ファイル: pulp-dev.py プロジェクト: credativ/pulp
def create_link(opts, src, dst):
    if not os.path.lexists(dst):
        return _create_link(opts, src, dst)

    if not os.path.islink(dst):
        return "[%s] is not a symbolic link as we expected, " \
               "please adjust if this is not what you intended." % dst

    if not os.path.exists(os.readlink(dst)):
        environment.warning('BROKEN LINK: [%s] attempting to delete and fix it to point to %s.' % (dst, src))
        try:
            os.unlink(dst)
            return _create_link(opts, src, dst)
        except:
            msg = "[%s] was a broken symlink, failed to delete " \
                  "and relink to [%s], please fix this manually" % (dst, src)
            return msg

    environment.debug(opts, 'verifying link: %s points to %s' % (dst, src))
    dst_stat = os.stat(dst)
    src_stat = os.stat(src)
    if dst_stat.st_ino != src_stat.st_ino:
        msg = "[%s] is pointing to [%s] which is different than " \
              "the intended target [%s]" % (dst, os.readlink(dst), src)
        return msg
コード例 #2
0
ファイル: pulp-dev.py プロジェクト: grizax/pulp
def install(opts):
    # Install the Python packages
    environment.manage_setup_pys('install')

    warnings = []
    create_dirs(opts)
    gen_rsa_keys()
    for src, dst in getlinks():
        warning_msg = create_link(opts, os.path.join(ROOT_DIR, src), dst)
        if warning_msg:
            warnings.append(warning_msg)

    environment.copy_files(get_paths_to_copy(), opts)

    if LSB_VERSION >= 6.0:
        # Grant apache write access to the pulp tools log file and pulp
        # packages dir
        os.system('chown -R apache:apache /var/log/pulp')
        os.system('chown -R apache:apache /var/lib/pulp')
        os.system('chown -R apache:apache /var/cache/pulp')
        os.system('chown -R apache:apache /var/run/pulp')
        os.system('chown -R apache:apache /var/www/streamer')

        # The Celery init script will get angry if /etc/default things aren't root owned
        os.system('chown root:root /etc/default/pulp_celerybeat')
        os.system('chown root:root /etc/default/pulp_workers')
        os.system('chown root:root /etc/default/pulp_resource_manager')

        # Guarantee apache always has write permissions
        os.system('chmod 3775 /var/log/pulp')
        os.system('chmod 3775 /var/lib/pulp')
        os.system('chmod 3775 /var/cache/pulp')

        # Generate certificates
        print 'generating certificates'
        if not os.path.exists('/etc/pki/pulp/ca.crt'):
            os.system(os.path.join(ROOT_DIR, 'server/bin/pulp-gen-ca-certificate'))
        if not os.path.exists('/etc/pki/pulp/nodes/node.crt'):
            os.system(os.path.join(ROOT_DIR, 'nodes/common/bin/pulp-gen-nodes-certificate'))

        # Unfortunately, our unit tests fail to mock the CA certificate and key, so we need to make
        # those world readable. Until we fix this, we cannot close #1048297
        os.system('chmod 644 /etc/pki/pulp/ca.*')
        os.system('chown apache:apache /etc/pki/pulp/content')

        # Link between pulp and apache
        create_link(opts, '/var/lib/pulp/published', '/var/www/pub')

        # Grant apache write access permissions
        os.system('chmod 3775 /var/www/pub')
        os.system('chown -R apache:apache /var/lib/pulp/published')

        # Reload systemd unit files
        os.system('systemctl daemon-reload')

    if warnings:
        print "\n***\nPossible problems:  Please read below\n***"
        for w in warnings:
            environment.warning(w)
    return os.EX_OK
コード例 #3
0
ファイル: pulp-dev.py プロジェクト: arnisoph/pulp
def create_link(opts, src, dst):
    if not os.path.lexists(dst):
        return _create_link(opts, src, dst)

    if not os.path.islink(dst):
        return "[%s] is not a symbolic link as we expected, " \
               "please adjust if this is not what you intended." % dst

    if not os.path.exists(os.readlink(dst)):
        environment.warning(
            'BROKEN LINK: [%s] attempting to delete and fix it to point to %s.'
            % (dst, src))
        try:
            os.unlink(dst)
            return _create_link(opts, src, dst)
        except:
            msg = "[%s] was a broken symlink, failed to delete " \
                  "and relink to [%s], please fix this manually" % (dst, src)
            return msg

    environment.debug(opts, 'verifying link: %s points to %s' % (dst, src))
    dst_stat = os.stat(dst)
    src_stat = os.stat(src)
    if dst_stat.st_ino != src_stat.st_ino:
        msg = "[%s] is pointing to [%s] which is different than " \
              "the intended target [%s]" % (dst, os.readlink(dst), src)
        return msg
コード例 #4
0
def install(opts):
    # Install the Python packages
    environment.manage_setup_pys('install')

    warnings = []
    create_dirs(opts)
    gen_rsa_keys()
    for src, dst in getlinks():
        warning_msg = create_link(opts, os.path.join(ROOT_DIR, src), dst)
        if warning_msg:
            warnings.append(warning_msg)

    environment.copy_files(get_paths_to_copy(), opts)

    if LSB_VERSION >= 6.0:
        # Grant apache write access to the pulp tools log file and pulp
        # packages dir
        os.system('chown -R apache:apache /var/log/pulp')
        os.system('chown -R apache:apache /var/lib/pulp')
        os.system('chown -R apache:apache /var/cache/pulp')
        os.system('chown -R apache:apache /var/run/pulp')

        # The Celery init script will get angry if /etc/default things aren't root owned
        os.system('chown root:root /etc/default/pulp_celerybeat')
        os.system('chown root:root /etc/default/pulp_workers')
        os.system('chown root:root /etc/default/pulp_resource_manager')

        # Guarantee apache always has write permissions
        os.system('chmod 3775 /var/log/pulp')
        os.system('chmod 3775 /var/lib/pulp')
        os.system('chmod 3775 /var/cache/pulp')

        # Generate certificates
        print 'generating certificates'
        if not os.path.exists('/etc/pki/pulp/ca.crt'):
            os.system(
                os.path.join(ROOT_DIR, 'server/bin/pulp-gen-ca-certificate'))
        if not os.path.exists('/etc/pki/pulp/nodes/node.crt'):
            os.system(
                os.path.join(ROOT_DIR,
                             'nodes/common/bin/pulp-gen-nodes-certificate'))

        # Unfortunately, our unit tests fail to mock the CA certificate and key, so we need to make
        # those world readable. Until we fix this, we cannot close #1048297
        os.system('chmod 644 /etc/pki/pulp/ca.*')
        os.system('chown apache:apache /etc/pki/pulp/content')

        # Link between pulp and apache
        create_link(opts, '/var/lib/pulp/published', '/var/www/pub')

        # Grant apache write access permissions
        os.system('chmod 3775 /var/www/pub')
        os.system('chown -R apache:apache /var/lib/pulp/published')

    if warnings:
        print "\n***\nPossible problems:  Please read below\n***"
        for w in warnings:
            environment.warning(w)
    return os.EX_OK