2017-05-19 20:17:38 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Check if triton is installed and executable
|
2017-05-19 21:45:36 +03:00
|
|
|
function checkTritonInstalled () {
|
|
|
|
command -v triton >/dev/null 2>&1 || { echo >&2 "Triton CLI tools do not appear to be installed. Please install before continuing."; exit 1; }
|
|
|
|
}
|
2017-05-19 20:17:38 +03:00
|
|
|
|
2017-05-19 21:45:36 +03:00
|
|
|
# Check if curl is installed and executable
|
|
|
|
function checkCurlInstalled () {
|
|
|
|
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required to complete this installation. Please install before continuing."; exit 1; }
|
|
|
|
}
|
|
|
|
|
2017-05-19 21:59:14 +03:00
|
|
|
# Emit the current Triton profile and time
|
|
|
|
function currentProfile () {
|
2017-05-19 22:12:53 +03:00
|
|
|
if [ -n "$TRITON_PROFILE" ]
|
|
|
|
then
|
|
|
|
local profile_source='via env var; use `eval "$(triton env <profile name>)"` to change'
|
|
|
|
else
|
|
|
|
local profile_source='default; use `triton profile set <profile name>` to change'
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source}) at $(date +'%r')"
|
2017-05-19 21:59:14 +03:00
|
|
|
}
|
|
|
|
|
2017-05-19 22:58:30 +03:00
|
|
|
# Check if the Docker binary (named triton-docker-helper)
|
|
|
|
# and Docker Compose (named triton-compose-helper) are installed and executable
|
2017-05-19 21:45:36 +03:00
|
|
|
function checkDockerInstalled () {
|
2017-05-19 22:58:30 +03:00
|
|
|
if
|
|
|
|
[ ! -f /usr/local/bin/triton-docker-helper ] ||
|
|
|
|
[ ! -x /usr/local/bin/triton-docker-helper ] ||
|
|
|
|
[ '1.12.6,' != $(/usr/local/bin/triton-docker-helper -v | awk '{print $3}') ] ||
|
|
|
|
[ ! -f /usr/local/bin/triton-compose-helper ] ||
|
|
|
|
[ ! -x /usr/local/bin/triton-compose-helper ] ||
|
|
|
|
[ '1.9.0,' != $(/usr/local/bin/triton-compose-helper -v | awk '{print $3}') ]
|
2017-05-19 21:45:36 +03:00
|
|
|
then
|
2017-05-19 22:58:30 +03:00
|
|
|
echo 'Additional or updated components are required.'
|
|
|
|
echo 'Please run `sudo triton-docker-install` to continue.'
|
2017-05-19 21:45:36 +03:00
|
|
|
echo
|
2017-05-19 22:58:30 +03:00
|
|
|
exit 1
|
2017-05-19 21:45:36 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-05-19 22:58:30 +03:00
|
|
|
# Install architecture-specific Docker and Docker Compose binaries
|
|
|
|
function install () {
|
|
|
|
echo "Triton needs to install additional components for Docker and Docker Compose interactions."
|
|
|
|
echo "This installation will only happen once."
|
2017-05-19 20:39:31 +03:00
|
|
|
|
2017-05-19 22:58:30 +03:00
|
|
|
# Check if curl is installed and executable
|
|
|
|
checkCurlInstalled
|
2017-05-19 20:17:38 +03:00
|
|
|
|
2017-05-19 22:58:30 +03:00
|
|
|
# Install the specific version of Docker for Triton
|
|
|
|
rm -Rf /tmp/triton-docker /usr/local/bin/triton-docker-helper
|
|
|
|
mkdir -p /tmp/triton-docker
|
|
|
|
curl https://get.docker.com/builds/$(uname -a | awk '{ print $1 }')/x86_64/docker-1.12.6.tgz | tar zxvf - -C /tmp/triton-docker
|
|
|
|
mv /tmp/triton-docker/docker/docker /usr/local/bin/triton-docker-helper
|
|
|
|
rm -Rf /tmp/triton-docker
|
|
|
|
chmod +x /usr/local/bin/triton-docker-helper
|
2017-05-19 20:17:38 +03:00
|
|
|
|
2017-05-19 22:58:30 +03:00
|
|
|
echo "The triton-docker-helper is now installed."
|
|
|
|
echo
|
|
|
|
|
|
|
|
# Install the specific version of Docker Compose for Triton
|
|
|
|
curl -Lo /usr/local/bin/triton-compose-helper https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -a | awk '{ print $1 }')-x86_64
|
|
|
|
chmod +x /usr/local/bin/triton-compose-helper
|
|
|
|
|
|
|
|
echo "The triton-compose-helper is now installed."
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install architecture-specific Docker and Docker Compose binaries
|
|
|
|
function checkAll () {
|
|
|
|
checkTritonInstalled &&
|
|
|
|
checkDockerInstalled &&
|
|
|
|
currentProfile
|
2017-05-19 21:45:36 +03:00
|
|
|
}
|
2017-05-19 20:17:38 +03:00
|
|
|
|
2017-05-19 21:45:36 +03:00
|
|
|
case "`basename $0`" in
|
|
|
|
triton-docker)
|
2017-05-19 22:58:30 +03:00
|
|
|
checkAll &&
|
2017-05-19 21:45:36 +03:00
|
|
|
eval "$(triton env)" &&
|
|
|
|
exec /usr/local/bin/triton-docker-helper $@
|
|
|
|
;;
|
|
|
|
triton-compose)
|
2017-05-19 22:58:30 +03:00
|
|
|
checkAll &&
|
2017-05-19 21:45:36 +03:00
|
|
|
eval "$(triton env)" &&
|
|
|
|
export COMPOSE_HTTP_TIMEOUT=750 &&
|
|
|
|
exec /usr/local/bin/triton-compose-helper $@
|
|
|
|
;;
|
2017-05-19 22:58:30 +03:00
|
|
|
triton-docker-install)
|
|
|
|
install
|
|
|
|
;;
|
2017-05-19 21:45:36 +03:00
|
|
|
esac
|