def _update_config( current: config.InstanceConfig, previous: typing.Optional[config.InstanceConfig], ensure_paths: bool = True, notify_server: bool = True, ) -> typing.Tuple[config.InstanceConfig, bool]: """Compare the current and previous instance configurations. If they differ, ensure any new paths, update the samba config, and inform any running smbds of the new configuration. Return the current config and a boolean indicating if the instance configs differed. """ # has the config changed? changed = current != previous # ensure share paths exist if changed and ensure_paths: for share in current.shares(): path = share.path() if not path: continue _logger.info(f"Ensuring share path: {path}") paths.ensure_share_dirs(path) _logger.info(f"Updating permissions if needed: {path}") perms_handler(share.permissions_config(), path).update() # update smb config if changed: _logger.info("Updating samba configuration") loader = nc.NetCmdLoader() loader.import_config(current) # notify smbd of changes if changed and notify_server: subprocess.check_call( list(samba_cmds.smbcontrol["smbd", "reload-config"])) return current, changed
def import_config(cli, config): # there are some expectations about what dirs exist and perms paths.ensure_samba_dirs() cfgs = cli.config or [] iconfig = config.read_config_files(cfgs).get(cli.identity) loader = nc.NetCmdLoader() loader.import_config(iconfig)
def import_config(ctx: Context) -> None: """Import configuration parameters from the sambacc config to samba's registry config. """ # there are some expectations about what dirs exist and perms paths.ensure_samba_dirs() loader = nc.NetCmdLoader() loader.import_config(ctx.instance_config)
def import_config(cli, config) -> None: """Import configuration parameters from the sambacc config to samba's registry config. """ # there are some expectations about what dirs exist and perms paths.ensure_samba_dirs() cfgs = cli.config or [] iconfig = config.read_config_files(cfgs).get(cli.identity) loader = nc.NetCmdLoader() loader.import_config(iconfig)