Add version check, separate the install action
This commit is contained in:
parent
4baea085f1
commit
3d866f9adc
@ -23,17 +23,33 @@ function currentProfile () {
|
|||||||
echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source}) at $(date +'%r')"
|
echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source}) at $(date +'%r')"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the Docker binary (named triton-docker-helper) is installed and executable
|
# Check if the Docker binary (named triton-docker-helper)
|
||||||
# ...install it if not
|
# and Docker Compose (named triton-compose-helper) are installed and executable
|
||||||
function checkDockerInstalled () {
|
function checkDockerInstalled () {
|
||||||
if [ ! -f /usr/local/bin/triton-docker-helper ] || [ ! -x /usr/local/bin/triton-docker-helper ]
|
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}') ]
|
||||||
then
|
then
|
||||||
echo "Triton-docker needs to install an application to continue."
|
echo 'Additional or updated components are required.'
|
||||||
|
echo 'Please run `sudo triton-docker-install` to continue.'
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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."
|
echo "This installation will only happen once."
|
||||||
|
|
||||||
# Check if triton is installed and executable
|
# Check if curl is installed and executable
|
||||||
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required to complete this installation. Please install before continuing."; exit 1; }
|
checkCurlInstalled
|
||||||
|
|
||||||
|
# Install the specific version of Docker for Triton
|
||||||
rm -Rf /tmp/triton-docker /usr/local/bin/triton-docker-helper
|
rm -Rf /tmp/triton-docker /usr/local/bin/triton-docker-helper
|
||||||
mkdir -p /tmp/triton-docker
|
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
|
curl https://get.docker.com/builds/$(uname -a | awk '{ print $1 }')/x86_64/docker-1.12.6.tgz | tar zxvf - -C /tmp/triton-docker
|
||||||
@ -43,42 +59,35 @@ function checkDockerInstalled () {
|
|||||||
|
|
||||||
echo "The triton-docker-helper is now installed."
|
echo "The triton-docker-helper is now installed."
|
||||||
echo
|
echo
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if Docker Compose (named triton-compose-helper) is installed and executable
|
|
||||||
# ...install it if not
|
|
||||||
function checkComposeInstalled () {
|
|
||||||
if [ ! -f /usr/local/bin/triton-compose-helper ] || [ ! -x /usr/local/bin/triton-compose-helper ]
|
|
||||||
then
|
|
||||||
echo "Triton-compose needs to install an application to continue."
|
|
||||||
echo "This installation will only happen once."
|
|
||||||
|
|
||||||
# Check if curl is installed and executable
|
|
||||||
checkCurlInstalled
|
|
||||||
|
|
||||||
|
# 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
|
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
|
chmod +x /usr/local/bin/triton-compose-helper
|
||||||
|
|
||||||
echo "The triton-compose-helper is now installed."
|
echo "The triton-compose-helper is now installed."
|
||||||
echo
|
echo
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
# Install architecture-specific Docker and Docker Compose binaries
|
||||||
|
function checkAll () {
|
||||||
|
checkTritonInstalled &&
|
||||||
|
checkDockerInstalled &&
|
||||||
|
currentProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
case "`basename $0`" in
|
case "`basename $0`" in
|
||||||
triton-docker)
|
triton-docker)
|
||||||
checkTritonInstalled &&
|
checkAll &&
|
||||||
checkDockerInstalled &&
|
|
||||||
currentProfile &&
|
|
||||||
eval "$(triton env)" &&
|
eval "$(triton env)" &&
|
||||||
exec /usr/local/bin/triton-docker-helper $@
|
exec /usr/local/bin/triton-docker-helper $@
|
||||||
;;
|
;;
|
||||||
triton-compose)
|
triton-compose)
|
||||||
checkTritonInstalled &&
|
checkAll &&
|
||||||
checkComposeInstalled &&
|
|
||||||
currentProfile &&
|
|
||||||
eval "$(triton env)" &&
|
eval "$(triton env)" &&
|
||||||
export COMPOSE_HTTP_TIMEOUT=750 &&
|
export COMPOSE_HTTP_TIMEOUT=750 &&
|
||||||
exec /usr/local/bin/triton-compose-helper $@
|
exec /usr/local/bin/triton-compose-helper $@
|
||||||
;;
|
;;
|
||||||
|
triton-docker-install)
|
||||||
|
install
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user