From 782893838f392eed1fa197a6b14eaebc440e7457 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 18 Apr 2018 22:48:05 +0100 Subject: [PATCH] rancher env update script --- scripts/README.md | 20 +++++++++++++ scripts/rancher-update.sh | 61 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100755 scripts/rancher-update.sh diff --git a/scripts/README.md b/scripts/README.md index 3c80f21afb..beb7179b9f 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -393,4 +393,24 @@ This script test the distribution of ADF against the demo shell ```sh ./test-dist +``` + +# rancher-update.sh + +***rancher-update.sh*** + +Internal script for update the rancher env + +| Option | Description | +| --- | --- | +|--access_key |rancher access key| +|--secret_key |rancher secret key| +|--url |rancher_url| +|--environment_name s|ervice name to replace in rancher| +|--image |image to gater and load in the service, example: docker:alfresco/demo-shell:latest| + +## Examples + +```sh +/rancher-update.sh --access_key ACCESS_KEY --secret_key SECRET_KEY --url RANCHER_URL--environment_name adf-master --image docker:alfresco/demo-shell:master ``` \ No newline at end of file diff --git a/scripts/rancher-update.sh b/scripts/rancher-update.sh new file mode 100755 index 0000000000..a2adaff887 --- /dev/null +++ b/scripts/rancher-update.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +show_help() { + echo "Usage: docker_publish.sh" + echo "" + echo "--access_key rancher access key" + echo "--secret_key rancher secret key" + echo "--url rancher_url" + echo "--environment_name service name to replace in rancher" + echo "--image image to gater and load in the service, example: docker:alfresco/demo-shell:latest" +} + +access_key(){ + ACCESSKEY=$1 +} + +secret_key(){ + SECRETKEY=$1 +} + +url(){ + RANCHERURL=$1 +} + +environment_name(){ + ENVIRONMENTNAME=$1 +} + +image_name(){ + IMAGE=$1 +} + +while [[ $1 == -* ]]; do + case "$1" in + -h|--help|-\?) show_help; exit 0;; + --access_key) access_key $2; shift 2;; + --secret_key) secret_key $2; shift 2;; + --url) url $2; shift 2;; + --environment_name) environment_name $2; shift 2;; + --image) image_name $2; shift 2;; + -*) echo "invalid option: $1" 1>&2; show_help; exit 1;; + esac +done + +docker pull etlweather/gaucho:alpine + +docker=$(which docker) + +echo "getting the id" + +ENVIRONMENTID=$($docker run --rm -e CATTLE_ACCESS_KEY=$ACCESSKEY \ + -e CATTLE_SECRET_KEY=$SECRETKEY \ + -e CATTLE_URL=$RANCHERURL \ + etlweather/gaucho:alpine id_of $ENVIRONMENTNAME) + +echo "id retrieved! is ${environment_id}" + +$docker run --rm -e CATTLE_ACCESS_KEY=$ACCESSKEY \ + -e CATTLE_SECRET_KEY=$SECRETKEY \ + -e CATTLE_URL=$RANCHERURL \ + etlweather/gaucho:alpine upgrade $ENVIRONMENTID --imageUuid $IMAGE --auto_complete true --timeout 600