diff --git a/docker/start.sh b/docker/start.sh index 20a5b0e..070129f 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -7,15 +7,20 @@ ROOT_PASSWORD="ewc2025root" DATABASE="ewc2025" PORT="13306" +RUNTIME="docker" +if [[ "${1:-}" == "--podman" ]]; then + RUNTIME="podman" +fi + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SQL_DIR="$(cd "${SCRIPT_DIR}/../sql" && pwd)" -if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then +if ${RUNTIME} ps -a --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then echo "Container '${CONTAINER}' already exists — starting it." - docker start "${CONTAINER}" + ${RUNTIME} start "${CONTAINER}" else - echo "Creating and starting '${CONTAINER}'." - docker run -d \ + echo "Creating and starting '${CONTAINER}' using ${RUNTIME}." + ${RUNTIME} run -d \ --name "${CONTAINER}" \ -e MYSQL_ROOT_PASSWORD="${ROOT_PASSWORD}" \ -e MYSQL_DATABASE="${DATABASE}" \ @@ -26,7 +31,7 @@ else fi echo "Waiting for MySQL to be ready..." -until docker exec "${CONTAINER}" mysqladmin ping -uroot -p"${ROOT_PASSWORD}" --silent 2>/dev/null; do +until ${RUNTIME} exec "${CONTAINER}" mysqladmin ping -uroot -p"${ROOT_PASSWORD}" --silent 2>/dev/null; do sleep 1 done diff --git a/docker/stop.sh b/docker/stop.sh index 365ec45..cfda095 100755 --- a/docker/stop.sh +++ b/docker/stop.sh @@ -3,10 +3,15 @@ set -euo pipefail CONTAINER="ewc2025-mysql" -if ! docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then +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 -docker stop "${CONTAINER}" +${RUNTIME} stop "${CONTAINER}" echo "Container '${CONTAINER}' stopped. Data volume preserved."