release-notes/build.sh

35 lines
1.4 KiB
Bash
Raw Normal View History

2018-07-28 11:15:24 +02:00
#!/bin/sh
image="antora/antora"
2018-10-18 13:34:50 +02:00
cmd="--html-url-extension-style=indexify site.yml"
2018-07-28 11:15:24 +02:00
if [ "$(uname)" == "Darwin" ]; then
# Running on macOS.
# Let's assume that the user has the Docker CE installed
# which doesn't require a root password.
2018-10-18 13:34:50 +02:00
docker run --rm -it -v $(pwd):/antora $image $cmd
2018-07-28 11:15:24 +02:00
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# Running on Linux.
2018-10-18 13:34:50 +02:00
# Check whether podman is available, else faill back to docker
2018-07-28 11:15:24 +02:00
# which requires root.
2018-10-18 13:34:50 +02:00
if [ -f /usr/bin/podman ]; then
runtime="podman"
2018-10-18 13:34:50 +02:00
else
runtime="docker"
fi
if groups | grep -wq "docker"; then
# Check if the current user is in the "docker" group. If true, no sudo is needed.
2018-10-18 13:34:50 +02:00
echo ""
echo "This build script is using $runtime to run the build in an isolated environment."
echo ""
$runtime run --rm -it -v $(pwd):/antora:z $image $cmd
else
# User isn't in the docker group; run the command with sudo.
echo ""
echo "This build script is using $runtime to run the build in an isolated environment. You might be asked for your password."
echo "You can avoid this by adding your user to the 'docker' group, but be aware of the security implications. See https://docs.docker.com/install/linux/linux-postinstall/."
echo ""
sudo $runtime run --rm -it -v $(pwd):/antora:z $image $cmd
2018-10-18 13:34:50 +02:00
fi
2018-07-28 11:15:24 +02:00
fi