def load_module_refint(): with fs.mkstemp() as fp: content = ldif.get_mod_refint() open(fp, 'wt').write(content) env.sudo('ldapadd -Y EXTERNAL -H ldapi:/// -f {0}'.format(fp)) with fs.mkstemp() as fp: content = ldif.get_overlay_refint() open(fp, 'wt').write(content) env.sudo('ldapadd -Y EXTERNAL -H ldapi:/// -f {0}'.format(fp))
def setup_vhost(): '''Set up apache vhost''' with fs.mkstemp() as fp: dest = join('/etc/apache2/conf.d', 'zarafa-zsm.conf') content = get_vhost() open(fp, 'wt').write(content) fs.sh_copyfile(fp, dest, sudo=True) fs.sh_chmod(dest, 644, sudo=True)
def populate_database(): puth('Populating database') with fs.mkstemp() as fp: content = ldif.get_base_structure() open(fp, 'wt').write(content) env.sudo('ldapadd -x -D {0} -w {1} -f {2}'.format( env.ldap_admin_dn, env.ldap_admin_pw, fp))
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))
def ipython(userid='SYSTEM', password='******'): '''Launch an ipython shell.''' snip = ''' import os from MAPI.Util import OpenECSession from MAPI.Util import GetDefaultStore def get_session(userid, password): global socket if userid == 'SYSTEM': #session = OpenECSession('demo1', 'zarafa', 'http://192.168.50.195:236') #session = OpenECSession('SYSTEM', '', 'http://192.168.50.195:236') socket = 'file:///var/run/zarafa' else: port = 236 if os.getuid() == 0 else 2236 socket = 'http://localhost:%s' % port return OpenECSession(userid, password, socket) userid = '{userid}' password = '******' session = get_session(userid, password) store = GetDefaultStore(session) print fmt = "%-12s %s" print fmt % ("userid:", userid) print fmt % ("password:"******"socket:", socket) print fmt % ("session:", session) print fmt % ("store:", store) ''' with fs.mkstemp() as fp: snip = snip.format( userid=userid, password=password, ) open(fp, 'wt').write(snip) print(snip) interpreter = 'ipython' if fs.sh_which('ipython') else 'python' env.run('{0} -i {1}'.format(interpreter, fp))
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)
def load_schema(): puth('Loading schema') with fs.mkstemp() as fp: content = ldif.get_zarafa_schema() open(fp, 'wt').write(content) env.sudo('ldapadd -Y EXTERNAL -H ldapi:/// -f {0}'.format(fp))