diff --git a/README.md b/README.md index 8919107..45ead32 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - [微信消息转发 1.5](docs%2FWeChatForward.md) - 订阅下载统计 1.5 - [自定义命令 1.5](docs%2FCustomCommand.md) -- docker管理 1.1 +- docker管理 1.2 diff --git a/package.json b/package.json index caa4519..794b9b7 100644 --- a/package.json +++ b/package.json @@ -279,11 +279,12 @@ "DockerManager": { "name": "docker管理", "description": "管理宿主机docker,自定义容器定时任务。", - "version": "1.1", + "version": "1.2", "icon": "Docker_F.png", "author": "thsrite", "level": 1, "history": { + "v1.2": "多个容器名,拼接", "v1.1": "修复多个任务立即运行一次", "v1.0": "init" } diff --git a/plugins/dockermanager/__init__.py b/plugins/dockermanager/__init__.py index c8c9f91..2d05a6e 100644 --- a/plugins/dockermanager/__init__.py +++ b/plugins/dockermanager/__init__.py @@ -21,7 +21,7 @@ class DockerManager(_PluginBase): # 插件图标 plugin_icon = "Docker_F.png" # 插件版本 - plugin_version = "1.1" + plugin_version = "1.2" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -111,14 +111,15 @@ class DockerManager(_PluginBase): # 获取所有容器列表 containers = self._docker_client.containers.list(all=True) + container_names = str(name).split(",") # 遍历容器列表,找到对应名称的容器ID for container in containers: for env in container.attrs['Config']['Env']: if str(env.split("=")[0]) == "HOST_CONTAINERNAME": - if str(env.split("=")[1]) == str(name): + if str(env.split('=')[1]) in container_names: container_id = container.id # 执行命令 - log_text = f"容器:{name} {command}" + log_text = f"容器:{env.split('=')[1]} {command}" try: state = True @@ -152,7 +153,7 @@ class DockerManager(_PluginBase): history = self.get_data('history') or [] history.append({ - "name": name, + "name": env.split('=')[1], "command": command, "result": 'success' if state else 'fail', "time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) @@ -172,7 +173,6 @@ class DockerManager(_PluginBase): text=log_text, image=container_icon if container_icon and str(container_icon).startswith( "http") else None) - break def __update_config(self): self.update_config({ @@ -333,7 +333,7 @@ class DockerManager(_PluginBase): 'props': { 'type': 'info', 'variant': 'tonal', - 'text': '容器名#cron表达式#restart/start/stop/pause/unpause/update' + 'text': '容器名(多个容器名,拼接)#cron表达式#restart/start/stop/pause/unpause/update' } } ]