From f320fb47998f5ac79b11fcfe9b400d2f9b020220 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 2 Jun 2017 14:42:16 -0700 Subject: [PATCH] don't exit if CNS is disabled --- triton-docker | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/triton-docker b/triton-docker index 5123e75..d5df59e 100755 --- a/triton-docker +++ b/triton-docker @@ -68,7 +68,24 @@ function currentProfile () { local profile_source='default; use `triton profile set ` to change' fi - echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source})" + # Get and the user's account information and CloudAPI URL for parsing later + local triton_account="$(triton account get)" + + echo "Executing in '$(echo "${triton_account}" | awk 'NR == 1 {print $2}')' (${profile_source})" + + # Check if CNS is enabled, require it + if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')" ] + then + echo + tput rev # reverse + tput bold # bold + echo 'Error! Triton CNS is not enabled.' + tput sgr0 # clear + echo + echo 'Please run the following to activate:' + echo ' triton account update triton_cns_enabled=true' + echo + fi } # Set env vars to make using CNS easier @@ -90,22 +107,6 @@ function cnsEnvVars () { return fi - # Check if CNS is enabled, require it - local triton_cns_enabled="$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')" - if [ ! "true" == "$triton_cns_enabled" ] - then - echo - tput rev # reverse - tput bold # bold - echo 'Error! Triton CNS is required and not enabled.' - tput sgr0 # clear - echo - echo 'Please run:' - echo ' triton account update triton_cns_enabled=true' - echo - exit 1 - fi - # Get the user's UUID local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/id:/{print $2}')" @@ -115,6 +116,7 @@ function cnsEnvVars () { local triton_dc="$(echo "${triton_url}" | awk -F'.' '{print $1}')" # Set the CNS base for public and private names + # 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 TRITON_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com" }