Ejemplo n.º 1
0
    def mysql_user(self):
        if fs.sh_file_exists(self.my_debian_conf):
            content = fs.sh_cat(self.my_debian_conf, sudo=True)
            return text.safefind('(?m)^user\s+=\s+(.*)$', content)

        elif fs.sh_dir_exists(self.zar_live_config):
            fp = join(self.zar_live_config, 'server.cfg')
            content = fs.sh_cat(fp, sudo=True)
            return text.safefind('(?m)^mysql_user\s+=\s+(.*)$', content)
Ejemplo n.º 2
0
    def mysql_user(self):
        if fs.sh_file_exists(self.my_debian_conf):
            content = fs.sh_cat(self.my_debian_conf, sudo=True)
            return text.safefind('(?m)^user\s+=\s+(.*)$', content)

        elif fs.sh_dir_exists(self.zar_live_config):
            fp = join(self.zar_live_config, 'server.cfg')
            content = fs.sh_cat(fp, sudo=True)
            return text.safefind('(?m)^mysql_user\s+=\s+(.*)$', content)
Ejemplo n.º 3
0
def create_database():
    ldap_env = LdapEnv.get()

    if not fs.sh_dir_exists(ldap_env.database_path, sudo=True):
        puth('Creating database directory {0}'.format(ldap_env.database_path))
        fs.sh_makedirs(ldap_env.database_path,
                       user=ldap_env.ldap_user,
                       group=ldap_env.ldap_group,
                       sudo=True)

    with fs.mkstemp() as fp:
        content = ldif.get_database()
        open(fp, 'wt').write(content)

        puth('Creating database config for {0}'.format(env.ldap_database_name))
        env.sudo('ldapadd -Y EXTERNAL -H ldapi:/// -f {0}'.format(fp))
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 def conf_templates(self):
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'installer', 'linux')
     return '/etc/zarafa'
Ejemplo n.º 6
0
 def zarafa_server_bin(self):
     binary = 'zarafa-server'
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'provider', 'server', binary)
     return fs.sh_which(binary, sudo=True)
Ejemplo n.º 7
0
 def zarafa_licensed_bin(self):
     binary = 'zarafa-licensed'
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'licensed', binary)
     return fs.sh_which(binary, sudo=True)
Ejemplo n.º 8
0
 def plugin_path(self):
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'provider', 'plugins', '.libs')
Ejemplo n.º 9
0
 def conf_templates(self):
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'installer', 'linux')
     return '/etc/zarafa'
Ejemplo n.º 10
0
 def zarafa_server_bin(self):
     binary = 'zarafa-server'
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'provider', 'server', binary)
     return fs.sh_which(binary, sudo=True)
Ejemplo n.º 11
0
 def zarafa_licensed_bin(self):
     binary = 'zarafa-licensed'
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'licensed', binary)
     return fs.sh_which(binary, sudo=True)
Ejemplo n.º 12
0
 def plugin_path(self):
     if fs.sh_dir_exists(self.repo_basedir):
         return join(self.repo_basedir, 'provider', 'plugins', '.libs')
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
def delete_database_storage():
    ldap_env = LdapEnv.get()

    if fs.sh_dir_exists(ldap_env.database_path, sudo=True):
        puth('Deleting database directory {0}'.format(ldap_env.database_path))
        fs.sh_rmtree(ldap_env.database_path, sudo=True)