Remove double backslash bs

This commit is contained in:
Daniel_I_Am 2020-08-17 18:54:31 +02:00
parent 98c328c9e2
commit 5a68c4fab3
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -141,22 +141,23 @@ deploy:
script:
- 'apk add curl jq'
# Sign in with credentials
- 'AUTH_TOKEN="`curl -X POST $API_URI/api/auth -H "Content-Type: application/json" -d "{\\"Username\\": \\"$API_USER\\", \\"Password\\": \\"$API_PASS\\"}" | jq -r ".jwt" | tr -d "\n"`"'
- 'AUTH_TOKEN="`curl -X POST $API_URI/api/auth -H "Content-Type: application/json" -d "{\"Username\": \"$API_USER\", \"Password\": \"$API_PASS\"}" | jq -r ".jwt" | tr -d "\n"`"'
# Update chaosbot:latest image
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/images/create?fromImage=registry.chaoticlogic.us%2Fchaosbot:latest" -H "X-Registry-Auth: eyJzZXJ2ZXJhZGRyZXNzIjoicmVnaXN0cnkuY2hhb3RpY2xvZ2ljLnVzIn0=" --data-raw "{\\"fromImage\\":\\"registry.chaoticlogic.us/chaosbot:latest\\"}"'
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/images/create?fromImage=registry.chaoticlogic.us%2Fchaosbot:latest" -H "X-Registry-Auth: eyJzZXJ2ZXJhZGRyZXNzIjoicmVnaXN0cnkuY2hhb3RpY2xvZ2ljLnVzIn0=" --data-raw "{\"fromImage\":\"registry.chaoticlogic.us/chaosbot:latest\"}"'
# Stop old container
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/$CONTAINER_ID/stop" --data-raw "{}"'
# Rename old container
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/$CONTAINER_ID/rename?name=%2F$CONTAINER_ID-old" --data-raw "{}"'
# Create new container
- 'CONTAINER_CREATION_RESPONSE=`curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/create?name=$CONTAINER_ID" --data-raw "{\\"Cmd\\":[],\\"Entrypoint\\":[\\"./ChaosBot\\"],\\"Hostname\\":\\"b47984029a4a\\",\\"Image\\":\\"registry.chaoticlogic.us/chaosbot:latest\\",\\"Labels\\":{},\\"OnBuild\\":null,\\"OpenStdin\\":false,\\"StdinOnce\\":false,\\"Tty\\":false,\\"User\\":\\"\\",\\"Volumes\\":{\\"/App/appsettings.json\\":{}},\\"WorkingDir\\":\\"/App\\",\\"HostConfig\\":{\\"AutoRemove\\":false,\\"Binds\\":[\\"/etc/ChaosBot/appsettings.json:/App/appsettings.json:ro\\"],\\"RestartPolicy\\":{\\"MaximumRetryCount\\":0,\\"Name\\":\\"unless-stopped\\"}},\\"name\\":\\"ChaoticLogicBot\\"}"`'
- 'CONTAINER_CREATION_RESPONSE=`curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/create?name=$CONTAINER_ID" --data-raw "{\"Cmd\":[],\"Entrypoint\":[\"./ChaosBot\"],\"Hostname\":\"b47984029a4a\",\"Image\":\"registry.chaoticlogic.us/chaosbot:latest\",\"Labels\":{},\"OnBuild\":null,\"OpenStdin\":false,\"StdinOnce\":false,\"Tty\":false,\"User\":\"\",\"Volumes\":{\"/App/appsettings.json\":{}},\"WorkingDir\":\"/App\",\"HostConfig\":{\"AutoRemove\":false,\"Binds\":[\"/etc/ChaosBot/appsettings.json:/App/appsettings.json:ro\"],\"RestartPolicy\":{\"MaximumRetryCount\":0,\"Name\":\"unless-stopped\"}},\"name\":\"ChaoticLogicBot\"}"`'
- 'echo $CONTAINER_CREATION_RESPONSE'
- 'NEW_CONTAINER_ID=`echo $CONTAINER_CREATION_RESPONSE | jq -r ".Id"`'
- 'NEW_RESOURCE_CONTROL_ID=`echo $CONTAINER_CREATION_RESPONSE | jq -r ".Portainer.ResourceControl.Id"`'
# Connect new container to docker bridge
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/networks/bridge/connect" --data-raw "{\\"Container\\":\\"$NEW_CONTAINER_ID\\"}"'
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/networks/bridge/connect" --data-raw "{\"Container\":\"$NEW_CONTAINER_ID\"}"'
# Start new container
- 'curl -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/$NEW_CONTAINER_ID/start" --data-raw "{}"'
# Lock down new container
- 'curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/resource_controls/$NEW_RESOURCE_CONTROL_ID" --data-raw "{\\"AdministratorsOnly\\":true,\\"Public\\":false,\\"Users\\":[],\\"Teams\\":[]}"'
- 'curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $AUTH_TOKEN" "$API_URI/api/resource_controls/$NEW_RESOURCE_CONTROL_ID" --data-raw "{\"AdministratorsOnly\":true,\"Public\":false,\"Users\":[],\"Teams\":[]}"'
# Delete old container
- 'curl -X DELETE "$API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/$CONTAINER_ID-old?force=true&v=1" -H "Authorization: Bearer $AUTH_TOKEN"'