diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-09-18 15:56:31 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-09-18 15:57:46 +0200 |
commit | b18e29b389792267269c77db711b54d38e6b9d59 (patch) | |
tree | 973ad914da9105cc526df1690cc99dc038fea5e4 /.local/bin/update |
initial commit
Diffstat (limited to '.local/bin/update')
-rw-r--r-- | .local/bin/update | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/.local/bin/update b/.local/bin/update new file mode 100644 index 0000000..ee6f67d --- /dev/null +++ b/.local/bin/update @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import sys, os +import subprocess + + +# pacman +subprocess.run(["sudo", "pacman", "-Syu", "--noconfirm"]) + + +# docker +process_docker_ps = subprocess.run(["docker", "ps", "-q"], stdout=subprocess.PIPE) + +container_ids = process_docker_ps.stdout.decode("utf-8").split("\n") + +docker_compose_project_paths = [] +for id in container_ids: + if id: + process_docker_inspect = subprocess.run(["docker", "inspect", "--format", "{{ index .Config.Labels \"com.docker.compose.project.working_dir\" }}", id], stdout=subprocess.PIPE) + docker_compose_project_paths.append(process_docker_inspect.stdout.decode("utf-8").strip()) + +docker_compose_project_paths = set(docker_compose_project_paths) + +for path in docker_compose_project_paths: + subprocess.run(["docker", "compose", "down"], cwd=path) + subprocess.run(["docker", "compose", "pull"], cwd=path) + subprocess.run(["docker", "compose", "up", "-d"], cwd=path) |