Made SSL verification optional

This commit is contained in:
Juan Carlos Mejías Rodríguez 2018-11-21 12:46:31 -05:00
parent 3a885e5e47
commit eeb207d773
2 changed files with 11 additions and 9 deletions

View File

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

View File

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