From 69441f51cdf21f6aa04bfde407ac19d1a914b23d Mon Sep 17 00:00:00 2001 From: Alexandru Pentilescu Date: Sun, 16 Jul 2023 12:14:36 +0000 Subject: [PATCH] Added script for updating all the docker images on my instance --- update-docker-images.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 update-docker-images.py diff --git a/update-docker-images.py b/update-docker-images.py new file mode 100755 index 0000000..93d6f30 --- /dev/null +++ b/update-docker-images.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import os, subprocess + +TARGET_PATH = "/home/alex/Scripts/" + +def iterate_in_directory(path): + + for fname in os.listdir(path): + + parent_path = os.path.join(path, fname) + if os.path.isdir(parent_path) and ("docker-compose.yml" in os.listdir(parent_path) or ("docker-compose.yaml" in os.listdir(parent_path))): + print("Updating " + parent_path) + os.chdir(parent_path) + subprocess.run(["docker-compose", "down"], check=True, stderr = subprocess.STDOUT) + subprocess.run(["docker-compose", "pull"], check=True, stderr = subprocess.STDOUT) + subprocess.run(["docker-compose", "up", "-d"], check=True, stderr = subprocess.STDOUT) + + elif (fname == "bitwarden"): + print("Updating bitwarden instance") + os.chdir(parent_path) + subprocess.run(["./bitwarden.sh", "updateself"], check=True, stderr = subprocess.STDOUT) + subprocess.run(["./bitwarden.sh", "update"], check=True, stderr = subprocess.STDOUT) + + +iterate_in_directory(TARGET_PATH) \ No newline at end of file