Add check if container is running

This commit is contained in:
LinuxSquare 2023-12-23 13:35:18 +01:00
parent 6256422ac5
commit 4c504b03aa
2 changed files with 9 additions and 0 deletions

View file

@ -3,3 +3,7 @@
function getValueByKey() {
jq -r ".$1" "${CONFIG}"
}
function getLocalConfValue() {
jq -r ".$2" "$1/config.json"
}

View file

@ -43,6 +43,11 @@ function startpod() {
podman network create "$network"
fi
if [[ -n $(podman container ls | grep $(getLocalConfValue $(getValueByKey 'PODMAN_DIRECTORY')/${1} container.name)) ]]; then
log e "Container $(getLocalConfValue $(getValueByKey 'PODMAN_DIRECTORY')/${1} container.name) is already running"
exit 1
fi
podman-compose up -d
}