summaryrefslogtreecommitdiff
path: root/.local/bin/update
blob: c0c337c3a63ac2570ac7bf4d9a8534b4f2db6ae4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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", "build"], cwd=path)
    subprocess.run(["docker", "compose", "pull"], cwd=path)
    subprocess.run(["docker", "compose", "up", "-d"], cwd=path)