updated for sc
This commit is contained in:
parent
dab09df51d
commit
2741fe5d94
@ -6,7 +6,7 @@ triton_compose_version=1.9.0
|
|||||||
|
|
||||||
# Check if triton is installed and executable
|
# Check if triton is installed and executable
|
||||||
function checkTritonInstalled () {
|
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; }
|
command -v spearhead >/dev/null 2>&1 || { echo >&2 "Spearhead CLI tools do not appear to be installed. Please install before continuing."; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if curl is installed and executable
|
# Check if curl is installed and executable
|
||||||
@ -14,19 +14,19 @@ function checkCurlInstalled () {
|
|||||||
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required to complete this installation. Please install before continuing."; exit 1; }
|
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required to complete this installation. Please install before continuing."; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the Docker binary (named triton-docker-helper)
|
# Check if the Docker binary (named spearhead-docker-helper)
|
||||||
# and Docker Compose (named triton-compose-helper) are installed and executable
|
# and Docker Compose (named spearhead-compose-helper) are installed and executable
|
||||||
function checkDockerInstalled () {
|
function checkDockerInstalled () {
|
||||||
if
|
if
|
||||||
[ ! -f /usr/local/bin/triton-docker-helper ] ||
|
[ ! -f /usr/local/bin/spearhead-docker-helper ] ||
|
||||||
[ ! -x /usr/local/bin/triton-docker-helper ] ||
|
[ ! -x /usr/local/bin/spearhead-docker-helper ] ||
|
||||||
[ "${triton_docker_version}," != "$(/usr/local/bin/triton-docker-helper -v | awk '{print $3}')" ] ||
|
[ "${triton_docker_version}," != "$(/usr/local/bin/spearhead-docker-helper -v | awk '{print $3}')" ] ||
|
||||||
[ ! -f /usr/local/bin/triton-compose-helper ] ||
|
[ ! -f /usr/local/bin/spearhead-compose-helper ] ||
|
||||||
[ ! -x /usr/local/bin/triton-compose-helper ] ||
|
[ ! -x /usr/local/bin/spearhead-compose-helper ] ||
|
||||||
[ "${triton_compose_version}," != "$(/usr/local/bin/triton-compose-helper -v | awk '{print $3}')" ]
|
[ "${triton_compose_version}," != "$(/usr/local/bin/spearhead-compose-helper -v | awk '{print $3}')" ]
|
||||||
then
|
then
|
||||||
echo 'Additional or updated components are required.'
|
echo 'Additional or updated components are required.'
|
||||||
echo 'Please run `sudo triton-docker-install` to continue.'
|
echo 'Please run `sudo spearhead-docker-install` to continue.'
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -34,44 +34,44 @@ function checkDockerInstalled () {
|
|||||||
|
|
||||||
# Install architecture-specific Docker and Docker Compose binaries
|
# Install architecture-specific Docker and Docker Compose binaries
|
||||||
function install () {
|
function install () {
|
||||||
echo "Triton needs to install additional components for Docker and Docker Compose interactions."
|
echo "Spearhead Cloud 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 curl is installed and executable
|
# Check if curl is installed and executable
|
||||||
checkCurlInstalled
|
checkCurlInstalled
|
||||||
|
|
||||||
# Install the specific version of Docker for Triton
|
# Install the specific version of Docker for Triton
|
||||||
rm -Rf /tmp/triton-docker /usr/local/bin/triton-docker-helper
|
rm -Rf /tmp/spearhead-docker /usr/local/bin/spearhead-docker-helper
|
||||||
mkdir -p /tmp/triton-docker
|
mkdir -p /tmp/spearhead-docker
|
||||||
curl https://get.docker.com/builds/"$(uname -a | awk '{ print $1 }')"/x86_64/docker-${triton_docker_version}.tgz | tar zxvf - -C /tmp/triton-docker
|
curl https://get.docker.com/builds/"$(uname -a | awk '{ print $1 }')"/x86_64/docker-${triton_docker_version}.tgz | tar zxvf - -C /tmp/spearhead-docker
|
||||||
mv /tmp/triton-docker/docker/docker /usr/local/bin/triton-docker-helper
|
mv /tmp/spearhead-docker/docker/docker /usr/local/bin/spearhead-docker-helper
|
||||||
rm -Rf /tmp/triton-docker
|
rm -Rf /tmp/spearhead-docker
|
||||||
chmod +x /usr/local/bin/triton-docker-helper
|
chmod +x /usr/local/bin/spearhead-docker-helper
|
||||||
|
|
||||||
echo "The triton-docker-helper is now installed."
|
echo "The spearhead-docker-helper is now installed."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Install the specific version of Docker Compose for Triton
|
# Install the specific version of Docker Compose for Triton
|
||||||
curl -Lo /usr/local/bin/triton-compose-helper https://github.com/docker/compose/releases/download/${triton_compose_version}/docker-compose-"$(uname -a | awk '{ print $1 }')"-x86_64
|
curl -Lo /usr/local/bin/spearhead-compose-helper https://github.com/docker/compose/releases/download/${triton_compose_version}/docker-compose-"$(uname -a | awk '{ print $1 }')"-x86_64
|
||||||
chmod +x /usr/local/bin/triton-compose-helper
|
chmod +x /usr/local/bin/spearhead-compose-helper
|
||||||
|
|
||||||
echo "The triton-compose-helper is now installed."
|
echo "The spearhead-compose-helper is now installed."
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# Emit the current Triton profile and time
|
# Emit the current Triton profile and time
|
||||||
function currentProfile () {
|
function currentProfile () {
|
||||||
if [ -n "$TRITON_PROFILE" ]
|
if [ -n "$SC_PROFILE" ]
|
||||||
then
|
then
|
||||||
local profile_source='via env var; use `eval "$(triton env <profile name>)"` to change'
|
local profile_source='via env var; use `eval "$(spearhead env <profile name>)"` to change'
|
||||||
else
|
else
|
||||||
local profile_source='default; use `triton profile set <profile name>` to change'
|
local profile_source='default; use `spearhead profile set <profile name>` to change'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get and the user's account information and CloudAPI URL for parsing later
|
# Get and the user's account information and CloudAPI URL for parsing later
|
||||||
local triton_account="$(triton account get)"
|
local triton_account="$(spearhead account get)"
|
||||||
|
|
||||||
echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source})"
|
echo "Executing in '$(spearhead profile get | awk 'NR == 1 {print $2}')' (${profile_source})"
|
||||||
|
|
||||||
# Check if CNS is enabled, require it
|
# Check if CNS is enabled, require it
|
||||||
if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/^triton_cns_enabled:/{print $2}')" ]
|
if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/^triton_cns_enabled:/{print $2}')" ]
|
||||||
@ -83,7 +83,7 @@ function currentProfile () {
|
|||||||
tput sgr0 # clear
|
tput sgr0 # clear
|
||||||
echo
|
echo
|
||||||
echo 'Please run the following to activate:'
|
echo 'Please run the following to activate:'
|
||||||
echo ' triton account update triton_cns_enabled=true'
|
echo ' spearhead account update triton_cns_enabled=true'
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -92,17 +92,17 @@ function currentProfile () {
|
|||||||
function cnsEnvVars () {
|
function cnsEnvVars () {
|
||||||
|
|
||||||
# If the CNS env vars are already set, don't bother continuing
|
# If the CNS env vars are already set, don't bother continuing
|
||||||
if [ -n "$TRITON_CNS_SEARCH_DOMAIN_PUBLIC" ] && [ -n "$TRITON_CNS_SEARCH_DOMAIN_PRIVATE" ]
|
if [ -n "$SC_CNS_SEARCH_DOMAIN_PUBLIC" ] && [ -n "$SC_CNS_SEARCH_DOMAIN_PRIVATE" ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get and the user's account information and CloudAPI URL for parsing later
|
# Get and the user's account information and CloudAPI URL for parsing later
|
||||||
local triton_account="$(triton account get)"
|
local triton_account="$(spearhead account get)"
|
||||||
local triton_url="$(triton profile get | awk -F"/" '/url:/{print $3}')"
|
local triton_url="$(spearhead profile get | awk -F"/" '/url:/{print $3}')"
|
||||||
|
|
||||||
# Do not continue if the target is not a Triton Public Cloud data center
|
Do not continue if the target is not a Spearhead Cloud data center
|
||||||
if [ ! ".api.joyent.com" == "${triton_url: -15}" ]
|
if [ ! ".api.joyent.com" == "${triton_url: -15}" ] || [ ! ".api.spearhead.cloud" == "${triton_url: -15}" ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -117,39 +117,36 @@ function cnsEnvVars () {
|
|||||||
|
|
||||||
# Set the CNS base for public and private names
|
# Set the CNS base for public and private names
|
||||||
# Note, this also makes assumptions that only work in our public cloud
|
# Note, this also makes assumptions that only work in our public cloud
|
||||||
export TRITON_CNS_SEARCH_DOMAIN_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone"
|
export SC_CNS_SEARCH_DOMAIN_PUBLIC="${triton_account_uuid}.${triton_dc}.spearhead.cloud"
|
||||||
export TRITON_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com"
|
export SC_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.spearhead.cloud"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run all checks
|
|
||||||
function checkAll () {
|
function checkAll () {
|
||||||
checkTritonInstalled &&
|
checkTritonInstalled &&
|
||||||
checkDockerInstalled
|
checkDockerInstalled
|
||||||
}
|
}
|
||||||
|
|
||||||
# Special case handling if the sub-command is `profile`
|
|
||||||
if [ "profile" == "$1" ]
|
if [ "profile" == "$1" ]
|
||||||
then
|
then
|
||||||
currentProfile
|
currentProfile
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change behavior based on the calling name of this executable
|
|
||||||
case "$(basename $0)" in
|
case "$(basename $0)" in
|
||||||
triton-docker)
|
spearhead-docker)
|
||||||
checkAll &&
|
checkAll &&
|
||||||
eval "$(triton env)" &&
|
eval "$(spearhead env)" &&
|
||||||
cnsEnvVars &&
|
cnsEnvVars &&
|
||||||
exec /usr/local/bin/triton-docker-helper $@
|
exec /usr/local/bin/spearhead-docker-helper $@
|
||||||
;;
|
;;
|
||||||
triton-compose)
|
spearhead-compose)
|
||||||
checkAll &&
|
checkAll &&
|
||||||
eval "$(triton env)" &&
|
eval "$(triton env)" &&
|
||||||
export COMPOSE_HTTP_TIMEOUT=750 &&
|
export COMPOSE_HTTP_TIMEOUT=750 &&
|
||||||
cnsEnvVars &&
|
cnsEnvVars &&
|
||||||
exec /usr/local/bin/triton-compose-helper $@
|
exec /usr/local/bin/spearhead-compose-helper $@
|
||||||
;;
|
;;
|
||||||
triton-docker-install)
|
spearhead-docker-install)
|
||||||
install
|
install
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user