github.com/cvmfs/docker-graphdriver@v0.0.0-20181206110523-155ec6df0521/provision/setup_minio_webhook.sh (about) 1 #!/bin/bash 2 CONFIG_PATH="$1" 3 4 ACCESS_KEY="$(jq -r .credential.accessKey $CONFIG_PATH)" 5 SECRET_KEY="$(jq -r .credential.secretKey $CONFIG_PATH)" 6 ARN="arn:minio:sqs:us-east-1:1:webhook" 7 8 URL="http://localhost:9000" 9 ALIAS="local-minio" 10 BUCKET="layers" 11 12 function check_configuration() { 13 local s=$(mc config host list | grep $ALIAS | wc -l) 14 test $s -eq 1 15 } 16 17 function configure() { 18 mc config host add $ALIAS $URL $ACCESS_KEY $SECRET_KEY 19 } 20 21 22 function check_bucket() { 23 mc ls $ALIAS/$BUCKET 24 } 25 26 function create_bucket() { 27 mc mb $ALIAS/$BUCKET 28 } 29 30 31 32 function event_handler_ok() { 33 local s=$(mc events list $ALIAS/$BUCKET $ARN | wc -l) 34 test $s -eq 1 35 } 36 37 function add_event_handler() { 38 mc events add $ALIAS/$BUCKET "$ARN" --events put 39 } 40 41 42 check_configuration || configure 43 check_bucket || create_bucket 44 event_handler_ok || add_event_handler