From 85e62706700634dc603b9207bd67f768249b9cb4 Mon Sep 17 00:00:00 2001 From: Jon Antoine Date: Wed, 18 Apr 2018 18:25:28 -0700 Subject: [PATCH 1/2] Cleaned up the setup.sh script updating links and replacing the check for the Docker client pointing to the same place as the Triton client with a Triton Docker CLI check. --- examples/triton/setup.sh | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/examples/triton/setup.sh b/examples/triton/setup.sh index b7e7687..b0932e5 100755 --- a/examples/triton/setup.sh +++ b/examples/triton/setup.sh @@ -35,30 +35,18 @@ check() { tput bold # bold echo 'Error! Joyent Triton CLI is required, but does not appear to be installed.' tput sgr0 # clear - echo 'See https://www.joyent.com/blog/introducing-the-triton-command-line-tool' + echo 'See https://docs.joyent.com/public-cloud/api-access/triton-cli' exit 1 } - - # make sure Docker client is pointed to the same place as the Triton client - local docker_user=$(docker info 2>&1 | awk -F": " '/SDCAccount:/{print $2}') - local docker_dc=$(echo $DOCKER_HOST | awk -F"/" '{print $3}' | awk -F'.' '{print $1}') - - TRITON_USER=$(triton profile get | awk -F": " '/account:/{print $2}') - TRITON_DC=$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}') - TRITON_ACCOUNT=$(triton account get | awk -F": " '/id:/{print $2}') - if [ ! "$docker_user" = "$TRITON_USER" ] || [ ! "$docker_dc" = "$TRITON_DC" ]; then + command -v triton-docker >/dev/null 2>&1 || { echo tput rev # reverse tput bold # bold - echo 'Error! The Triton CLI configuration does not match the Docker CLI configuration.' + echo 'Error! Joyent Triton CLI is required, but does not appear to be installed.' tput sgr0 # clear - echo - echo "Docker user: ${docker_user}" - echo "Triton user: ${TRITON_USER}" - echo "Docker data center: ${docker_dc}" - echo "Triton data center: ${TRITON_DC}" + echo 'See https://docs.joyent.com/public-cloud/api-access/docker' exit 1 - fi + } local triton_cns_enabled=$(triton account get | awk -F": " '/cns/{print $2}') if [ ! "true" == "$triton_cns_enabled" ]; then From 7be16fee27a8ae4ff9175edecc8cd7c18977efc0 Mon Sep 17 00:00:00 2001 From: Jon Antoine Date: Thu, 19 Apr 2018 08:19:22 -0700 Subject: [PATCH 2/2] Restored the required TRITON_* environment variables and added checks that a Triton profile has been configured and that triton-docker has been configured for the current profile. --- examples/triton/setup.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/examples/triton/setup.sh b/examples/triton/setup.sh index b0932e5..31087b9 100755 --- a/examples/triton/setup.sh +++ b/examples/triton/setup.sh @@ -38,6 +38,22 @@ check() { echo 'See https://docs.joyent.com/public-cloud/api-access/triton-cli' exit 1 } + + TRITON_USER=$(triton profile get 2>/dev/null | awk -F": " '/account:/{print $2}') + TRITON_DC=$(triton profile get 2>/dev/null | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}') + TRITON_ACCOUNT=$(triton account get 2>/dev/null | awk -F": " '/id:/{print $2}') + if [ -z "$TRITON_USER" ] || [ -z "$TRITON_DC" ] || [ -z "$TRITON_ACCOUNT" ]; then + echo + tput rev # reverse + tput bold # bold + echo 'Error! A Triton profile does not appear to be configured.' + tput sgr0 # clear + echo + echo 'See https://docs.joyent.com/public-cloud/api-access/triton-cli' + echo + exit 1 + fi + command -v triton-docker >/dev/null 2>&1 || { echo tput rev # reverse @@ -48,6 +64,20 @@ check() { exit 1 } + local triton_docker_configured=$(triton-docker info 2>/dev/null | awk -F": " '/Operating System:/{print $2}') + if [ ! "SmartDataCenter" == "$triton_docker_configured" ]; then + echo + tput rev # reverse + tput bold # bold + echo 'Error! The current Triton profile does not appear to be configured for use with triton-docker.' + tput sgr0 # clear + echo + echo 'Consider running:' + echo ' triton profile docker-setup' + echo + exit 1 + fi + local triton_cns_enabled=$(triton account get | awk -F": " '/cns/{print $2}') if [ ! "true" == "$triton_cns_enabled" ]; then echo