#!/usr/bin/env bash
set -euo pipefail

CONTAINER="hotel-mysql"

RUNTIME="docker"
if [[ "${1:-}" == "--podman" ]]; then
    RUNTIME="podman"
fi

if ! ${RUNTIME} ps -a --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
    echo "Container '${CONTAINER}' does not exist."
    exit 0
fi

${RUNTIME} stop "${CONTAINER}"
echo "Container '${CONTAINER}' stopped. Data volume preserved."
