netbox-docker/hooks/common
2019-12-21 17:11:29 +01:00

97 lines
2 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
ensure_jq() {
if [ ! -x "$(command -v jq)" ]; then
if [ -x "$(command -v apt-get)" ]; then
echo "🛠🛠🛠 Installing 'jq' via 'apt-get'"
apt-get update && apt-get install -y jq
else
echo "⚠️⚠️⚠️ apt-get not found, unable to automatically install 'jq'."
fi
fi
}
# Passes args to the scripts
run_build() {
echo "🐳🐳🐳 Building '${BUILD}' images"
case ${BUILD} in
release)
# build the latest release
# shellcheck disable=SC2068
./build-latest.sh $@
;;
prerelease)
# build the latest pre-release
# shellcheck disable=SC2068
PRERELEASE=true ./build-latest.sh $@
;;
branches)
# build all branches
# shellcheck disable=SC2068
./build-branches.sh $@
;;
this) # Pull Requests
# only build the 'master' branch of netbox
# (resulting in the 'latest' docker tag)
# and the 'main' target.
DOCKER_TARGET=main ./build.sh master
;;
*)
echo "🚨 Unrecognized build '$BUILD'."
if [ -z "$DEBUG" ]; then
exit 1
else
echo "⚠️ Would exit here with code '1', but DEBUG is enabled."
fi
;;
esac
}
env_info() {
echo " docker version"
docker version
echo " docker-compose version"
docker-compose version
echo " git version"
git --version
echo " curl version"
curl --version
echo " jq version"
jq --version
echo " bash version"
bash --version
echo " apt-get version"
apt-get --version
echo " date version"
date --version
echo " Netbox Docker VERSION"
cat VERSION
echo " Netbox Docker git ref"
git rev-parse HEAD
git rev-parse --abbrev-ref HEAD
}
echo "🤖🤖🤖 Preparing build"
export DOCKER_ORG=netboxcommunity
export DOCKER_REPO=netbox
export DOCKER_REGISTRY=docker.io
# shellcheck disable=SC2153
export BUILD="${DOCKER_TAG}"
unset DOCKER_TAG
ensure_jq
echo "🤖🤖🤖 Build Environment Information"
env_info