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