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)
def stop_services(): zcpenv = ZcpEnv.get() server_pidfile = join(zcpenv.fakeroot, 'var', 'run', 'zarafa-server.pid') licensed_pidfile = join(zcpenv.fakeroot, 'var', 'run', 'zarafa-licensed.pid') server_pid = fs.sh_cat(server_pidfile, sudo=True) licensed_pid = fs.sh_cat(licensed_pidfile) if licensed_pid: proc.sh_kill(licensed_pid) proc.sh_kill_wait(server_pid, 'zarafa-server', 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 get_pid(self): content = fs.sh_cat(self.pidfile, sudo=True) content = content.strip() if content: return int(content)