Added script for updating all the docker images on my instance
This commit is contained in:
26
update-docker-images.py
Executable file
26
update-docker-images.py
Executable file
@ -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)
|
Reference in New Issue
Block a user