From 7b5608ef9e5a215348d8763034c36204a8d5d90f Mon Sep 17 00:00:00 2001 From: quackerd Date: Sun, 19 Jun 2022 22:06:30 -0400 Subject: [PATCH] docker update script --- docker_update.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docker_update.py diff --git a/docker_update.py b/docker_update.py new file mode 100644 index 0000000..7bb0fd9 --- /dev/null +++ b/docker_update.py @@ -0,0 +1,33 @@ +import os +import sys + +if len(sys.argv) != 3: + print("Invalid number of arguments\n") + exit(1) + +path = sys.argv[1] +spec_file = sys.argv[2] + +with open(spec_file,"r") as f: + lines = f.readlines() + +folders = [] + +for line in lines: + s = line.strip() + folders.add(s) + print("Registered folder " + s) + +for f in os.listdir(path): + fullpath = os.path.join(path,f) + if os.path.isdir(fullpath) and f in folders: + print("========= Processing " + fullpath + " =========") + os.system("docker-compose -f " + fullpath + " pull") + os.system("docker-compose -f " + fullpath + " up -d") + +print("========== CLEANING UP ==========") +os.system("docker system prune -af") + +os.system("echo $(date)") +os.system("echo \"Docker update finished!\"") +os.system("echo \"\"")