dockerutils/docker_update.py
2022-06-19 22:27:50 -04:00

35 lines
981 B
Python

import os
import sys
if len(sys.argv) != 3:
print("Invalid number of arguments\n")
exit(1)
path = os.path.abspath(sys.argv[1])
spec_file = os.path.abspath(sys.argv[2])
with open(spec_file,"r") as f:
lines = f.readlines()
for line in lines:
s = line.strip()
if s.startswith("#"):
continue
fullpath = os.path.join(path, s)
if os.path.isdir(fullpath) and ("docker-compose.yml" in os.listdir(fullpath)):
fullpath = os.path.join(fullpath, "docker-compose.yml")
print("========= Processing " + fullpath + " =========")
os.system("docker-compose -f " + fullpath + " pull")
os.system("docker-compose -f " + fullpath + " up -d")
else:
print("========= Skipping " + fullpath + ": invalid dir or docker-compos.yml =========")
print("========== CLEANING UP ==========")
os.system("docker system prune -af")
os.system("echo $(date)")
os.system("echo \"Docker update finished!\"")
os.system("echo \"\"")