#!/usr/bin/env bash

mc alias set storage \
  "${DRYCC_STORAGE_ENDPOINT}" \
  "${DRYCC_STORAGE_ACCESSKEY}" \
  "${DRYCC_STORAGE_SECRETKEY}" \
  --path "${DRYCC_STORAGE_PATH_STYLE}"

GET_PATH=/tmp/app.tgz

mc ping storage -x
if ! mc admin info storage > /dev/null 2>&1; then
  sleep 9s
else
  mc ready storage
fi
mc cp storage/"${DRYCC_STORAGE_BUCKET}/${TAR_PATH}" "${GET_PATH}"
