github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/scripts/s3/get-bucket-inventory.sh (about) 1 #!/bin/bash 2 3 while getopts n:p:b:f: flag 4 do 5 case "$flag" in 6 b) BUCKET=${OPTARG};; 7 n) ID=${OPTARG};; 8 esac 9 done 10 11 print_usage() { 12 echo "Usage:" 13 echo "./get-bucket-inventory -b BUCKET_NAME [-n INVENTORY_NAME]" 14 echo 15 echo "The script displays detailed information about the selected inventory" 16 echo 17 echo " BUCKET_NAME - AWS bucket name for which inventory will be enabled" 18 echo " INVENTORY_NAME - is the inventory ID" 19 } 20 21 RED='\033[0;31m' 22 NC='\033[0m' 23 24 if [[ -z "${BUCKET}" ]]; then 25 printf "${RED}Error${NC}: bucket name is not defined.\n" 26 print_usage 27 exit 1 28 fi 29 30 if [[ -z "${ID}" ]]; then 31 ID="${BUCKET}" 32 fi 33 34 CFG=`aws s3api get-bucket-inventory-configuration --bucket ${BUCKET} --id ${ID}` 35 36 OUT=`echo $CFG | jq '"ID\t\(.InventoryConfiguration .Id)\nPrefix\t\(.InventoryConfiguration .Destination .S3BucketDestination .Prefix)\nFrequency\t\(.InventoryConfiguration .Schedule .Frequency)\nEnabled\t\(.InventoryConfiguration .IsEnabled)\nFormat\t\(.InventoryConfiguration .Destination .S3BucketDestination .Format)\nFields\t\(.InventoryConfiguration .OptionalFields)"'` 37 OUT="${OUT:1:${#OUT}-2}" 38 printf "$OUT\n"