rancher env update script

This commit is contained in:
Eugenio Romano
2018-04-18 22:48:05 +01:00
parent 3713284ada
commit 782893838f
2 changed files with 81 additions and 0 deletions

View File

@@ -394,3 +394,23 @@ This script test the distribution of ADF against the demo shell
```sh ```sh
./test-dist ./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
```

61
scripts/rancher-update.sh Executable file
View File

@@ -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