def unload_schema(): ldap_env = LdapEnv.get() schema_dir = join(ldap_env.cn_config_path, 'cn=schema') files = fs.sh_listdir(schema_dir, sudo=True) files = fnmatch.filter(files, 'cn={*}%s.ldif' % env.ldap_custom_schema_cn) if not files: putw('Failed to detect schema: {0}'.format(env.ldap_custom_schema_cn)) else: filepath = join(schema_dir, files[0]) puth('Removing schema {0}'.format(filepath)) fs.sh_rm(filepath, sudo=True)
def unload_modules(): ldap_env = LdapEnv.get() for name in env.ldap_modules: filepath = None files = fs.sh_listdir(ldap_env.cn_config_path, sudo=True) files = fnmatch.filter(files, 'cn=module{*}.ldif') for f in files: fp = join(ldap_env.cn_config_path, f) if fs.sh_file_exists(fp, sudo=True): content = fs.sh_cat(fp, sudo=True) if text.safefind('(?m)^olcModuleLoad: {[0-9]+}' + name, content): filepath = fp if not filepath: putw('Failed to detect loaded module: {0}'.format(name)) else: puth('Removing module {0}'.format(name)) fs.sh_rm(filepath, sudo=True)
def drop_database(): ldap_env = LdapEnv.get() files = fs.sh_listdir(ldap_env.cn_config_path, sudo=True) files = fnmatch.filter(files, 'olcDatabase={*}hdb.ldif') filepath = None for f in files: fp = join(ldap_env.cn_config_path, f) content = fs.sh_cat(fp, sudo=True) if text.safefind('(?m)^olcSuffix: ' + env.ldap_dit_dn, content): filepath = fp if not filepath: putw('Failed to detect database: {0}'.format(env.ldap_dit_dn)) else: puth('Removing database config {0}'.format(filepath)) fs.sh_rm(filepath, sudo=True) root, _ = os.path.splitext(filepath) if fs.sh_dir_exists(root, sudo=True): puth('Removing database config subdir {0}'.format(root)) fs.sh_rmtree(root, sudo=True)
def reload(): '''Reload apache''' setup_vhost() fs.sh_rm('/etc/apache2/sites-enabled/000-default', sudo=True) env.sudo('service apache2 restart')
def setup_local_zcp(): zcpenv = ZcpEnv.get() puts('Setting up MAPI_CONFIG_PATH') sys_mapi_config_path = '/etc/mapi' if fs.sh_dir_exists(sys_mapi_config_path): warn('{0} directory exists, cannot set up symlink'.format( sys_mapi_config_path)) else: local_mapi_config_path = join(zcpenv.repo_basedir, 'provider', 'client') fs.sh_ln(local_mapi_config_path, sys_mapi_config_path, sudo=True) puts('Setting up LD_LIBRARY_PATH') ld_conf = '/etc/ld.so.conf.d' with fs.mkstemp() as fp: dest = join(ld_conf, 'zarafa.conf') paths = [ join(zcpenv.repo_basedir, 'provider', 'client', '.libs'), ] paths = '\n'.join(paths) + '\n' open(fp, 'wt').write(paths) fs.sh_copyfile(fp, dest, sudo=True) fs.sh_chmod(dest, 644, sudo=True) env.sudo('ldconfig') puts('Setting up PYTHONPATH') pyhome = dirname(os.__file__) pkg_dir_dir = join(pyhome, 'dist-packages') with fs.mkstemp() as fp: dest = join(pkg_dir_dir, 'MAPI.pth') paths = [ join(zcpenv.repo_basedir, 'swig', 'python'), join(zcpenv.repo_basedir, 'swig', 'python', '.libs'), ] paths = '\n'.join(paths) + '\n' open(fp, 'wt').write(paths) fs.sh_copyfile(fp, dest, sudo=True) fs.sh_chmod(dest, 644, sudo=True) puts('Setting up ZARAFA_SOCKET') src = join(zcpenv.fakeroot, 'var', 'run', 'zarafa') if not os.path.exists(src): warn('Path does not exist: {0}'.format(src)) else: dest = '/var/run/zarafa' if fs.sh_exists(dest): fs.sh_rm(dest, sudo=True) fs.sh_ln(src, dest, sudo=True) puts('Setting up ssl client cert') src = join('etc', 'zarafa', 'ssl', 'client.pem') destdir = '/etc/zarafa/sslkeys' dest = join(destdir, 'client.pem') if not fs.sh_exists(dest): fs.sh_makedirs(destdir, sudo=True) fs.sh_copyfile(src, dest, sudo=True)