From 252dbb38adaa2d7e0cc78506e6e9d13a345229b3 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 10:17:38 -0700 Subject: [PATCH 01/12] initial commit --- triton-docker | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 triton-docker diff --git a/triton-docker b/triton-docker new file mode 100644 index 0000000..54376d8 --- /dev/null +++ b/triton-docker @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# Check if triton is installed and executable +command -v triton >/dev/null 2>&1 || { echo >&2 "Triton CLI tools do not appear to be installed. Please install before continuing."; exit 1; } + +# Check if the helper Go binary is installed and executable +# ...install it if not +if [ ! -f /usr/local/bin/triton-docker-helper ] || [ ! -x /usr/local/bin/triton-docker-helper ] +then + +echo "Triton-docker needs to install an application to continue." +echo "This installation will only happen once." + +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 }')/$(uname -a | awk '{ print $NF }')/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 + +echo "The triton-docker-helper is now installed." +echo +fi + +eval "$(triton env)" + +exec /usr/local/bin/triton-docker-helper $1 From 0b1e97425edc34bef747189a8810b710b787918f Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 10:24:25 -0700 Subject: [PATCH 02/12] get all args --- triton-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triton-docker b/triton-docker index 54376d8..99a6cff 100644 --- a/triton-docker +++ b/triton-docker @@ -25,4 +25,4 @@ fi eval "$(triton env)" -exec /usr/local/bin/triton-docker-helper $1 +exec /usr/local/bin/triton-docker-helper $@ From c7815759626b46711218423e30004ce37b775bbf Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 10:36:54 -0700 Subject: [PATCH 03/12] fix cpu arch detection nice hack by @cheaproc --- triton-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triton-docker b/triton-docker index 99a6cff..e1735d1 100644 --- a/triton-docker +++ b/triton-docker @@ -14,7 +14,7 @@ echo "This installation will only happen once." 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 }')/$(uname -a | awk '{ print $NF }')/docker-1.12.6.tgz | tar zxvf - -C /tmp/triton-docker +curl https://get.docker.com/builds/$(uname -a | awk '{ print $1 }')/$(file /bin/sh | awk '{ print $NF }')/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 From a5731337719a85e472794bcb03633fc72805ad16 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 10:39:31 -0700 Subject: [PATCH 04/12] curl is required, just go x86_64 everywhere --- triton-docker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/triton-docker b/triton-docker index e1735d1..4f26161 100644 --- a/triton-docker +++ b/triton-docker @@ -12,9 +12,12 @@ then echo "Triton-docker needs to install an application to continue." echo "This installation will only happen once." +# Check if triton 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; } + 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 }')/$(file /bin/sh | awk '{ print $NF }')/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 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 From 0261c5720bdd68994bb4fca1e2d9b64e242553ca Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 11:45:36 -0700 Subject: [PATCH 05/12] add compose support --- triton-docker | 77 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/triton-docker b/triton-docker index 4f26161..b5b87c2 100644 --- a/triton-docker +++ b/triton-docker @@ -2,30 +2,69 @@ set -e # Check if triton is installed and executable -command -v triton >/dev/null 2>&1 || { echo >&2 "Triton CLI tools do not appear to be installed. Please install before continuing."; exit 1; } +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; } +} -# Check if the helper Go binary is installed and executable +# 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; } +} + +# Check if the Docker binary (named triton-docker-helper) is installed and executable # ...install it if not -if [ ! -f /usr/local/bin/triton-docker-helper ] || [ ! -x /usr/local/bin/triton-docker-helper ] -then +function checkDockerInstalled () { + if [ ! -f /usr/local/bin/triton-docker-helper ] || [ ! -x /usr/local/bin/triton-docker-helper ] + then + echo "Triton-docker needs to install an application to continue." + echo "This installation will only happen once." -echo "Triton-docker needs to install an application to continue." -echo "This installation will only happen once." + # Check if triton 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; } -# Check if triton 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; } + 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 -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 + echo "The triton-docker-helper is now installed." + echo + fi +} -echo "The triton-docker-helper is now installed." -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." -eval "$(triton env)" + # Check if curl is installed and executable + checkCurlInstalled -exec /usr/local/bin/triton-docker-helper $@ + 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 + fi +} + +case "`basename $0`" in + triton-docker) + checkTritonInstalled && + checkDockerInstalled && + eval "$(triton env)" && + exec /usr/local/bin/triton-docker-helper $@ + ;; + triton-compose) + checkTritonInstalled && + checkComposeInstalled && + eval "$(triton env)" && + export COMPOSE_HTTP_TIMEOUT=750 && + exec /usr/local/bin/triton-compose-helper $@ + ;; +esac From b2482746d6072df3a13ea4da774c69de369a7b52 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 11:47:16 -0700 Subject: [PATCH 06/12] add install instructions --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 6470225..394ca42 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # triton-docker + Docker CLI helper for Triton + +### Installation + +```bash +curl -o /usr/local/bin/triton-docker https://raw.githubusercontent.com/misterbisson/triton-docker/working/triton-docker && chmod +x /usr/local/bin/triton-docker && ln -s /usr/local/bin/triton-docker /usr/local/bin/triton-compose +``` From 049000bc6dbfde815ca11834300854c0cd5e3bb2 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 11:48:47 -0700 Subject: [PATCH 07/12] use the force --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 394ca42..c42234a 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ Docker CLI helper for Triton ### Installation ```bash -curl -o /usr/local/bin/triton-docker https://raw.githubusercontent.com/misterbisson/triton-docker/working/triton-docker && chmod +x /usr/local/bin/triton-docker && ln -s /usr/local/bin/triton-docker /usr/local/bin/triton-compose +curl -o /usr/local/bin/triton-docker https://raw.githubusercontent.com/misterbisson/triton-docker/working/triton-docker && chmod +x /usr/local/bin/triton-docker && ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-compose ``` From 2a54927bb0cf928a1c7c10c1132e4a4ac943d80f Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 11:59:14 -0700 Subject: [PATCH 08/12] add profile info --- triton-docker | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/triton-docker b/triton-docker index b5b87c2..ac084d6 100644 --- a/triton-docker +++ b/triton-docker @@ -11,6 +11,11 @@ function checkCurlInstalled () { command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required to complete this installation. Please install before continuing."; exit 1; } } +# Emit the current Triton profile and time +function currentProfile () { + echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' at $(date +'%r')" +} + # Check if the Docker binary (named triton-docker-helper) is installed and executable # ...install it if not function checkDockerInstalled () { @@ -57,12 +62,14 @@ case "`basename $0`" in triton-docker) checkTritonInstalled && checkDockerInstalled && + currentProfile && eval "$(triton env)" && exec /usr/local/bin/triton-docker-helper $@ ;; triton-compose) checkTritonInstalled && checkComposeInstalled && + currentProfile && eval "$(triton env)" && export COMPOSE_HTTP_TIMEOUT=750 && exec /usr/local/bin/triton-compose-helper $@ From 4baea085f159b62581e6389d0314f23d73a7edec Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 12:12:53 -0700 Subject: [PATCH 09/12] explain the source of the profile --- triton-docker | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/triton-docker b/triton-docker index ac084d6..7832694 100644 --- a/triton-docker +++ b/triton-docker @@ -13,7 +13,14 @@ function checkCurlInstalled () { # Emit the current Triton profile and time function currentProfile () { - echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' at $(date +'%r')" + if [ -n "$TRITON_PROFILE" ] + then + local profile_source='via env var; use `eval "$(triton env )"` to change' + else + local profile_source='default; use `triton profile set ` to change' + fi + + 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 From 3d866f9adcff290d9afea10cc3446aae8cafa038 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 12:58:30 -0700 Subject: [PATCH 10/12] Add version check, separate the install action --- triton-docker | 83 ++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/triton-docker b/triton-docker index 7832694..2fe46cf 100644 --- a/triton-docker +++ b/triton-docker @@ -23,62 +23,71 @@ function currentProfile () { 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 -# ...install it if not +# Check if the Docker binary (named triton-docker-helper) +# and Docker Compose (named triton-compose-helper) are installed and executable 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 - echo "Triton-docker needs to install an application to continue." - echo "This installation will only happen once." - - # Check if triton 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; } - - 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 - - echo "The triton-docker-helper is now installed." + echo 'Additional or updated components are required.' + echo 'Please run `sudo triton-docker-install` to continue.' echo + exit 1 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." +# 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." - # Check if curl is installed and executable - checkCurlInstalled + # Check if curl is installed and executable + checkCurlInstalled - 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 + # 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 - echo "The triton-compose-helper is now installed." - echo - fi + 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 } case "`basename $0`" in triton-docker) - checkTritonInstalled && - checkDockerInstalled && - currentProfile && + checkAll && eval "$(triton env)" && exec /usr/local/bin/triton-docker-helper $@ ;; triton-compose) - checkTritonInstalled && - checkComposeInstalled && - currentProfile && + checkAll && eval "$(triton env)" && export COMPOSE_HTTP_TIMEOUT=750 && exec /usr/local/bin/triton-compose-helper $@ ;; + triton-docker-install) + install + ;; esac From 383dd3df7e8443cdb2c7319739185ca77f383799 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 12:59:40 -0700 Subject: [PATCH 11/12] update install one-liner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c42234a..caa1268 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ Docker CLI helper for Triton ### Installation ```bash -curl -o /usr/local/bin/triton-docker https://raw.githubusercontent.com/misterbisson/triton-docker/working/triton-docker && chmod +x /usr/local/bin/triton-docker && ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-compose +curl -o /usr/local/bin/triton-docker https://raw.githubusercontent.com/misterbisson/triton-docker/working/triton-docker && chmod +x /usr/local/bin/triton-docker && ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-compose && ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-docker-install ``` From a4386b19795a2f9f0aadfa52cfc0baf8a61e2bbf Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 19 May 2017 13:06:38 -0700 Subject: [PATCH 12/12] use vars for versions --- triton-docker | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/triton-docker b/triton-docker index 2fe46cf..f79c962 100644 --- a/triton-docker +++ b/triton-docker @@ -1,6 +1,9 @@ #!/bin/bash set -e +triton_docker_version=1.12.6 +triton_compose_version=1.9.0 + # Check if triton is installed and executable 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; } @@ -29,10 +32,10 @@ function checkDockerInstalled () { 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}') ] || + [ "${triton_docker_version}," != $(/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}') ] + [ "${triton_compose_version}," != $(/usr/local/bin/triton-compose-helper -v | awk '{print $3}') ] then echo 'Additional or updated components are required.' echo 'Please run `sudo triton-docker-install` to continue.' @@ -52,7 +55,7 @@ function install () { # 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 + curl https://get.docker.com/builds/$(uname -a | awk '{ print $1 }')/x86_64/docker-${triton_docker_version}.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 @@ -61,14 +64,14 @@ function install () { 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 + 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 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 +# Run all checks function checkAll () { checkTritonInstalled && checkDockerInstalled &&