From eeb207d77354876319b07cf803339f29be941e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Mej=C3=ADas=20Rodr=C3=ADguez?= Date: Wed, 21 Nov 2018 12:46:31 -0500 Subject: [PATCH] Made SSL verification optional --- deploy.sh | 13 +++++++------ undeploy.sh | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/deploy.sh b/deploy.sh index 930d612..b422b34 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,6 +5,7 @@ PORTAINER_PASSWORD=${PORTAINER_PASSWORD:-"password"} PORTAINER_URL=${PORTAINER_URL:-"https://portainer.example.com"} PORTAINER_PRUNE=${PORTAINER_PRUNE:-"false"} PORTAINER_ENDPOINT=${PORTAINER_ENDPOINT:-"1"} +HTTPIE_VERIFY_SSL=${HTTPIE_VERIFY_SSL:-"yes"} if [ -z ${1+x} ]; then echo "Error: Parameter #1 missing (stack name)" @@ -32,7 +33,7 @@ STACK_YAML_CONTENT="${STACK_YAML_CONTENT//$'\n'/'\n'}" echo "Getting auth token..." AUTH_TOKEN=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ $PORTAINER_URL/api/auth \ username=$PORTAINER_USER \ password=$PORTAINER_PASSWORD \ @@ -47,7 +48,7 @@ echo "Done" echo "Getting stack $STACK_NAME..." STACKS=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ "$PORTAINER_URL/api/stacks" \ "Authorization: Bearer $AUTH_TOKEN") @@ -60,7 +61,7 @@ if [ -z "$STACK" ]; then echo "Getting swarm cluster (if any)..." SWARM_ID=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ "$PORTAINER_URL/api/endpoints/$PORTAINER_ENDPOINT/docker/info" \ "Authorization: Bearer $AUTH_TOKEN" \ | jq -r ".Swarm.Cluster.ID // empty") @@ -73,7 +74,7 @@ if [ -z "$STACK" ]; then CREATE=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ --timeout=300 \ "$PORTAINER_URL/api/stacks" \ "Authorization: Bearer $AUTH_TOKEN" \ @@ -88,7 +89,7 @@ if [ -z "$STACK" ]; then CREATE=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ --timeout=300 \ "$PORTAINER_URL/api/stacks" \ "Authorization: Bearer $AUTH_TOKEN" \ @@ -116,7 +117,7 @@ else echo "Updating stack $STACK_NAME..." UPDATE=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ --timeout=300 \ PUT "$PORTAINER_URL/api/stacks/$STACK_ID" \ "Authorization: Bearer $AUTH_TOKEN" \ diff --git a/undeploy.sh b/undeploy.sh index 918427f..0f8bb1d 100755 --- a/undeploy.sh +++ b/undeploy.sh @@ -5,6 +5,7 @@ PORTAINER_PASSWORD=${PORTAINER_PASSWORD:-"password"} PORTAINER_URL=${PORTAINER_URL:-"https://portainer.example.com"} PORTAINER_PRUNE=${PORTAINER_PRUNE:-"false"} PORTAINER_ENDPOINT=${PORTAINER_ENDPOINT:-"1"} +HTTPIE_VERIFY_SSL=${HTTPIE_VERIFY_SSL:-"yes"} if [ -z ${1+x} ]; then echo "Error: Parameter #1 missing (stack name)" @@ -15,7 +16,7 @@ STACK_NAME="$1" echo "Getting auth token..." AUTH_TOKEN=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ $PORTAINER_URL/api/auth \ username=$PORTAINER_USER \ password=$PORTAINER_PASSWORD \ @@ -30,7 +31,7 @@ echo "Done" echo "Getting stack $STACK_NAME..." STACKS=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ "$PORTAINER_URL/api/stacks" \ "Authorization: Bearer $AUTH_TOKEN") @@ -48,7 +49,7 @@ STACK_ID="$(echo "$STACK" | jq -j ".Id")" echo "Deleting stack $STACK_NAME..." DELETE=$(http \ --ignore-stdin \ - --verify=no \ + --verify=$HTTPIE_VERIFY_SSL \ DELETE "$PORTAINER_URL/api/stacks/$STACK_ID" \ "Authorization: Bearer $AUTH_TOKEN")