#!/usr/bin/env bash # Copyright (C) 2023 Umorpha Systems # SPDX-License-Identifier: AGPL-3.0-or-later set -euE -o pipefail # Clusters: # # | ID | hostname | location | # |----+-----------------------+----------------| # | 2 | ewr1.vultrobjects.com | New Jersey | # | 4 | sgp1.vultrobjects.com | Singapore | # | 5 | sjc1.vultrobjects.com | Silicon Valley | # | 6 | ams1.vultrobjects.com | Amsterdam | # | 7 | blr1.vultrobjects.com | Bangalore | # | 8 | del1.vultrobjects.com | Delhi NCR | main() { store_id=$(bin/vultr-api object-storage | jq -r '.object_storages[]|select(.label=="Umorpha disk images").id') if [[ -z "$store_id" ]]; then store_id=$(bin/vultr-api object-storage -XPOST --data '{"label":"Umorpha disk images","cluster_id":5}' | jq -r .object_storage.id) fi info_resp=$(bin/vultr-api object-storage/$store_id) s3_hostname=$(jq -r .object_storage.s3_hostname <<<"$info_resp") export AWS_ACCESS_KEY_ID="$(jq -r .object_storage.s3_access_key <<<"$info_resp")" export AWS_SECRET_ACCESS_KEY="$(jq -r .object_storage.s3_secret_key <<<"$info_resp")" if [[ "$1" == hostname ]]; then printf '%s\n' "$s3_hostname" else s3cmd --host="$s3_hostname" --host-bucket="%(bucket)s.${s3_hostname}" "$@" fi } main "$@"