def disable(self, instance_name=""): elements = self.systemd_name.split("@") if instance_name != "" and len(elements) > 1: # Remove instance, we need to do following: # Remove link from /etc/systemd/system/<service>.target.wants/ # <service>@<instance_name>.service # to /lib/systemd/system/<service>@.service srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, self.SYSTEMD_SRV_TARGET % (elements[0])) srv_lnk = os.path.join(srv_tgt, self.service_instance(instance_name)) try: if ipautil.dir_exists(srv_tgt): if os.path.islink(srv_lnk): os.unlink(srv_lnk) ipautil.run([paths.SYSTEMCTL, "--system", "daemon-reload"]) except Exception: pass else: try: ipautil.run([paths.SYSTEMCTL, "disable", self.service_instance(instance_name)]) except ipautil.CalledProcessError: pass
def disable(self, instance_name=""): elements = self.systemd_name.split("@") if instance_name != "" and len(elements) > 1: # Remove instance, we need to do following: # Remove link from /etc/systemd/system/<service>.target.wants/ # <service>@<instance_name>.service # to /lib/systemd/system/<service>@.service srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, self.SYSTEMD_SRV_TARGET % (elements[0])) srv_lnk = os.path.join(srv_tgt, self.service_instance(instance_name)) try: if ipautil.dir_exists(srv_tgt): if os.path.islink(srv_lnk): os.unlink(srv_lnk) ipautil.run([paths.SYSTEMCTL, "--system", "daemon-reload"]) except Exception: pass else: try: ipautil.run([ paths.SYSTEMCTL, "disable", self.service_instance(instance_name) ]) except ipautil.CalledProcessError: pass
def validate_options(self): options = self.options super(ReplicaPrepare, self).validate_options(needs_root=True) installutils.check_server_configuration() if not options.ip_addresses: if options.reverse_zones: self.option_parser.error( "You cannot specify a --reverse-zone " "option without the --ip-address option") if options.no_reverse: self.option_parser.error( "You cannot specify a --no-reverse " "option without the --ip-address option") elif options.reverse_zones and options.no_reverse: self.option_parser.error("You cannot specify a --reverse-zone " "option together with --no-reverse") #Automatically disable pkinit w/ dogtag until that is supported options.setup_pkinit = False # If any of the PKCS#12 options are selected, all are required. cert_file_req = (options.dirsrv_cert_files, options.http_cert_files) cert_file_opt = (options.pkinit_cert_files, ) if any(cert_file_req + cert_file_opt) and not all(cert_file_req): self.option_parser.error( "--dirsrv-cert-file and --http-cert-file are required if any " "PKCS#12 options are used.") if len(self.args) < 1: self.option_parser.error( "must provide the fully-qualified name of the replica") elif len(self.args) > 1: self.option_parser.error( "must provide exactly one name for the replica") else: [self.replica_fqdn] = self.args api.bootstrap(in_server=True) api.finalize() # Connect to LDAP, connection is closed at the end of run() api.Backend.ldap2.connect() self.check_for_supported_domain_level() if api.env.host == self.replica_fqdn: raise admintool.ScriptError("You can't create a replica on itself") config_dir = dsinstance.config_dirname( installutils.realm_to_serverid(api.env.realm)) if not ipautil.dir_exists(config_dir): raise admintool.ScriptError( "could not find directory instance: %s" % config_dir)
def validate_options(self): options = self.options super(ReplicaPrepare, self).validate_options(needs_root=True) installutils.check_server_configuration() if not options.ip_address: if options.reverse_zone: self.option_parser.error("You cannot specify a --reverse-zone " "option without the --ip-address option") if options.no_reverse: self.option_parser.error("You cannot specify a --no-reverse " "option without the --ip-address option") elif options.reverse_zone and options.no_reverse: self.option_parser.error("You cannot specify a --reverse-zone " "option together with --no-reverse") #Automatically disable pkinit w/ dogtag until that is supported options.setup_pkinit = False # If any of the PKCS#12 options are selected, all are required. pkcs12_req = (options.dirsrv_pkcs12, options.http_pkcs12) pkcs12_opt = (options.pkinit_pkcs12,) if any(pkcs12_req + pkcs12_opt) and not all(pkcs12_req): self.option_parser.error( "--dirsrv_pkcs12 and --http_pkcs12 are required if any " "PKCS#12 options are used.") if len(self.args) < 1: self.option_parser.error( "must provide the fully-qualified name of the replica") elif len(self.args) > 1: self.option_parser.error( "must provide exactly one name for the replica") else: [self.replica_fqdn] = self.args api.bootstrap(in_server=True) api.finalize() if api.env.host == self.replica_fqdn: raise admintool.ScriptError("You can't create a replica on itself") if not api.env.enable_ra and not options.http_pkcs12: raise admintool.ScriptError( "Cannot issue certificates: a CA is not installed. Use the " "--http_pkcs12, --dirsrv_pkcs12 options to provide custom " "certificates.") config_dir = dsinstance.config_dirname( dsinstance.realm_to_serverid(api.env.realm)) if not ipautil.dir_exists(config_dir): raise admintool.ScriptError( "could not find directory instance: %s" % config_dir)
def enable(self, instance_name=""): if self.lib_path_exists is None: self.lib_path_exists = os.path.exists(self.lib_path) elements = self.systemd_name.split("@") l = len(elements) if self.lib_path_exists and (l > 1 and elements[1][0] != '.'): # There is explicit service unit supporting this instance, # follow normal systemd enabler self.__enable(instance_name) return if self.lib_path_exists and (l == 1): # There is explicit service unit which does not support # the instances, ignore instance self.__enable() return if len(instance_name) > 0 and l > 1: # New instance, we need to do following: # 1. Make /etc/systemd/system/<service>.target.wants/ # if it is not there # 2. Link /etc/systemd/system/<service>.target.wants/ # <service>@<instance_name>.service to # /lib/systemd/system/<service>@.service srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, self.SYSTEMD_SRV_TARGET % (elements[0])) srv_lnk = os.path.join(srv_tgt, self.service_instance(instance_name)) try: if not ipautil.dir_exists(srv_tgt): os.mkdir(srv_tgt) os.chmod(srv_tgt, 0o755) if os.path.exists(srv_lnk): # Remove old link os.unlink(srv_lnk) if not os.path.exists(srv_lnk): # object does not exist _or_ is a broken link if not os.path.islink(srv_lnk): # if it truly does not exist, make a link os.symlink(self.lib_path, srv_lnk) else: # Link exists and it is broken, make new one os.unlink(srv_lnk) os.symlink(self.lib_path, srv_lnk) ipautil.run([paths.SYSTEMCTL, "--system", "daemon-reload"]) except Exception: pass else: self.__enable(instance_name)
def validate_options(self): options = self.options super(ReplicaPrepare, self).validate_options(needs_root=True) installutils.check_server_configuration() if not options.ip_addresses: if options.reverse_zones: self.option_parser.error("You cannot specify a --reverse-zone " "option without the --ip-address option") if options.no_reverse: self.option_parser.error("You cannot specify a --no-reverse " "option without the --ip-address option") elif options.reverse_zones and options.no_reverse: self.option_parser.error("You cannot specify a --reverse-zone " "option together with --no-reverse") #Automatically disable pkinit w/ dogtag until that is supported options.setup_pkinit = False # If any of the PKCS#12 options are selected, all are required. cert_file_req = (options.dirsrv_cert_files, options.http_cert_files) cert_file_opt = (options.pkinit_cert_files,) if any(cert_file_req + cert_file_opt) and not all(cert_file_req): self.option_parser.error( "--dirsrv-cert-file and --http-cert-file are required if any " "PKCS#12 options are used.") if len(self.args) < 1: self.option_parser.error( "must provide the fully-qualified name of the replica") elif len(self.args) > 1: self.option_parser.error( "must provide exactly one name for the replica") else: [self.replica_fqdn] = self.args api.bootstrap(in_server=True) api.finalize() # Connect to LDAP, connection is closed at the end of run() api.Backend.ldap2.connect() self.check_for_supported_domain_level() if api.env.host == self.replica_fqdn: raise admintool.ScriptError("You can't create a replica on itself") config_dir = dsinstance.config_dirname( installutils.realm_to_serverid(api.env.realm)) if not ipautil.dir_exists(config_dir): raise admintool.ScriptError( "could not find directory instance: %s" % config_dir)
def disable(self, instance_name=""): elements = self.systemd_name.split("@") if instance_name != "" and len(elements) > 1: # Remove instance, we need to do following: # Remove link from /etc/systemd/system/<service>.target.wants/<service>@<instance_name>.service # to /lib/systemd/system/<service>@.service srv_tgt = os.path.join(self.SYSTEMD_ETC_PATH, self.SYSTEMD_SRV_TARGET % (elements[0])) srv_lnk = os.path.join(srv_tgt, self.service_instance(instance_name)) try: if ipautil.dir_exists(srv_tgt): if os.path.islink(srv_lnk): os.unlink(srv_lnk) ipautil.run(["/bin/systemctl", "--system", "daemon-reload"]) except: pass else: self.__disable(instance_name)
def disable(self, instance_name=""): elements = self.service_name.split("@") if instance_name != "" and len(elements) > 1: # Remove instance, we need to do following: # Remove link from /etc/systemd/system/<service>.target.wants/<service>@<instance_name>.service # to /lib/systemd/system/<service>@.service srv_tgt = os.path.join(self.SYSTEMD_ETC_PATH, self.SYSTEMD_SRV_TARGET % (elements[0])) srv_lnk = os.path.join(srv_tgt, self.service_instance(instance_name)) try: if ipautil.dir_exists(srv_tgt): if os.path.islink(srv_lnk): os.unlink(srv_lnk) ipautil.run(["/bin/systemctl", "--system", "daemon-reload"]) except: pass else: self.__disable(instance_name)
def find_server_root(): if ipautil.dir_exists(SERVER_ROOT_64): return SERVER_ROOT_64 else: return SERVER_ROOT_32
def find_server_root(): if ipautil.dir_exists(paths.USR_LIB_DIRSRV_64): return paths.USR_LIB_DIRSRV_64 else: return paths.USR_LIB_DIRSRV