Initial commit commit
This commit is contained in:
31
main.py
Normal file
31
main.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
import config
|
||||
|
||||
|
||||
DOCKER_COMPOSE_PATH = '/srv/docker/portainer/portainer-data/compose/{}/docker-compose.yml'
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
BASH_COMPANION_SCRIPT = CURRENT_DIR + '/docker_updater.sh'
|
||||
|
||||
|
||||
def update_stack(stack):
|
||||
project_name = stack['Name']
|
||||
compose_file = DOCKER_COMPOSE_PATH.format(stack['Id'])
|
||||
os.system(f"{BASH_COMPANION_SCRIPT} {project_name} {compose_file}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"X-API-Key": config.access_token
|
||||
}
|
||||
|
||||
api_url = "https://portainer.dorfsvald.net/api/stacks"
|
||||
response = requests.get(api_url, headers=headers)
|
||||
stack_list = response.json()
|
||||
|
||||
for s in stack_list:
|
||||
if s['Status'] == 1:
|
||||
update_stack(s)
|
||||
Reference in New Issue
Block a user