2019-02-20 22:10:38 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C
|
|
|
|
|
2019-06-01 12:06:51 +00:00
|
|
|
IMAGE_NAMESPACE=hectormolinero
|
|
|
|
IMAGE_PROJECT=qemu-reactos
|
|
|
|
IMAGE_TAG=latest
|
|
|
|
IMAGE_NAME=${IMAGE_NAMESPACE}/${IMAGE_PROJECT}:${IMAGE_TAG}
|
|
|
|
CONTAINER_NAME=${IMAGE_PROJECT}
|
2019-02-20 22:10:38 +00:00
|
|
|
|
|
|
|
imageExists() { [ -n "$(docker images -q "$1")" ]; }
|
|
|
|
containerExists() { docker ps -aqf name="$1" --format '{{.Names}}' | grep -Fxq "$1"; }
|
|
|
|
containerIsRunning() { docker ps -qf name="$1" --format '{{.Names}}' | grep -Fxq "$1"; }
|
|
|
|
|
2019-06-01 12:06:51 +00:00
|
|
|
if ! imageExists "${IMAGE_NAME}"; then
|
|
|
|
>&2 printf -- '%s\n' "${IMAGE_NAME} image doesn't exist!"
|
2019-02-20 22:10:38 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-06-01 12:06:51 +00:00
|
|
|
if containerIsRunning "${CONTAINER_NAME}"; then
|
|
|
|
printf -- '%s\n' "Stopping \"${CONTAINER_NAME}\" container..."
|
|
|
|
docker stop "${CONTAINER_NAME}" >/dev/null
|
2019-02-20 22:10:38 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-01 12:06:51 +00:00
|
|
|
if containerExists "${CONTAINER_NAME}"; then
|
|
|
|
printf -- '%s\n' "Removing \"${CONTAINER_NAME}\" container..."
|
|
|
|
docker rm "${CONTAINER_NAME}" >/dev/null
|
2019-02-20 22:10:38 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-01 12:06:51 +00:00
|
|
|
printf -- '%s\n' "Creating \"${CONTAINER_NAME}\" container..."
|
2019-02-20 22:10:38 +00:00
|
|
|
docker run --detach \
|
2019-06-01 12:06:51 +00:00
|
|
|
--name "${CONTAINER_NAME}" \
|
|
|
|
--hostname "${CONTAINER_NAME}" \
|
2019-02-20 22:10:38 +00:00
|
|
|
--restart on-failure:3 \
|
|
|
|
--log-opt max-size=32m \
|
|
|
|
--publish '127.0.0.1:5900:5900/tcp' \
|
|
|
|
--publish '127.0.0.1:6080:6080/tcp' \
|
2019-02-21 23:09:49 +00:00
|
|
|
--publish '127.0.0.1:15900:15900/tcp' \
|
2019-02-20 22:10:38 +00:00
|
|
|
--privileged --env QEMU_KVM=true \
|
2019-06-01 12:06:51 +00:00
|
|
|
"${IMAGE_NAME}" "$@" >/dev/null
|
2019-02-20 22:10:38 +00:00
|
|
|
|
|
|
|
printf -- '%s\n\n' 'Done!'
|
2019-06-01 12:06:51 +00:00
|
|
|
exec docker logs -f "${CONTAINER_NAME}"
|