This commit is contained in:
zino
2023-11-23 14:09:28 +01:00
parent 62e7b86882
commit 6816f5ba10

View File

@@ -5,7 +5,15 @@ CONTAINER_NAME="lgsm-cs"
# Function to check if the container is running # Function to check if the container is running
is_container_running() { is_container_running() {
[[ "$(docker inspect -f '{{.State.Running}}' "${CONTAINER_NAME}" 2>/dev/null)" == "true" ]] docker inspect -f '{{.State.Running}}' "${CONTAINER_NAME}" 2>/dev/null
}
# Function to wait for the container to be fully up and running
wait_for_container() {
echo "Waiting for container ${CONTAINER_NAME} to be fully up and running..."
while ! docker exec "${CONTAINER_NAME}" echo "Container is up" &>/dev/null; do
sleep 1
done
} }
# Function to execute commands in the container # Function to execute commands in the container
@@ -13,17 +21,11 @@ execute_in_container() {
docker exec -d "${CONTAINER_NAME}" sh -c "$1" docker exec -d "${CONTAINER_NAME}" sh -c "$1"
} }
# Ensure the container is running # Check if container is running
if ! is_container_running; then if [ "$(is_container_running)" != "true" ]; then
echo "Container ${CONTAINER_NAME} is not running. Starting it..." echo "Container ${CONTAINER_NAME} is not running. Starting it..."
docker start "${CONTAINER_NAME}" docker start "${CONTAINER_NAME}"
wait_for_container
# Wait for the container to be up
echo "Waiting for the container to be fully up..."
until is_container_running; do
sleep 1
done
echo "Container ${CONTAINER_NAME} is now running."
fi fi
# Moving and copying libstdc++.so.6 # Moving and copying libstdc++.so.6