From 4c504b03aa5b92dbb737bd6e430a92c837d716e1 Mon Sep 17 00:00:00 2001 From: LinuxSquare Date: Sat, 23 Dec 2023 13:35:18 +0100 Subject: [PATCH] Add check if container is running --- utils/configparser | 4 ++++ utils/podman | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/utils/configparser b/utils/configparser index b4da6cc..9dba429 100644 --- a/utils/configparser +++ b/utils/configparser @@ -3,3 +3,7 @@ function getValueByKey() { jq -r ".$1" "${CONFIG}" } + +function getLocalConfValue() { + jq -r ".$2" "$1/config.json" +} diff --git a/utils/podman b/utils/podman index 5f47b31..0b7c7b8 100644 --- a/utils/podman +++ b/utils/podman @@ -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 }