Skip to content

Instantly share code, notes, and snippets.

@cloudnull
Created May 21, 2014 16:14
Show Gist options
  • Save cloudnull/e8870f133dcbf4a9a279 to your computer and use it in GitHub Desktop.
Save cloudnull/e8870f133dcbf4a9a279 to your computer and use it in GitHub Desktop.
Build a text file of all objects in a swift container using the full CDN URL for the object
#!/usr/bin/env bash
# Export the following variables and or modify this script with the following data
# Variables:
# CLOUD_USERNAME="The username of the cloud user"
# CLOUD_APIKEY="The API Key of the cloud user"
# CLOUD_REGION="The Region of the cloud user"
# CLOUD_CDNURL_TYPE="The cdn url type to build with"
# Available Values: x-cdn-ssl-uri, x-cdn-ios-uri, x-cdn-uri, x-cdn-streaming-uri
# CDNURLS_LOG="Name of this log file"
USERNAME="${CLOUD_USERNAME}"
APIKEY="${CLOUD_APIKEY}"
REGION="${CLOUD_REGION}"
CDN_URL_TYPE=${CLOUD_CDNURL_TYPE:-"x-cdn-ssl-uri"}
CDNURLS_LOG=${CDNURLS_LOG:-"$HOME/cdnfiles.log"}
if [ -f "$CDNURLS_LOG" ];then
mv $CDNURLS_LOG $CDNURLS_LOG.bak
fi
# Grab the CDN URL from the container
CDN_VAR=$(turbolift -u $USERNAME -a $APIKEY --os-rax-auth $REGION show -c cdn --cdn-info | grep $CDN_URL_TYPE | awk '{print $4}')
# Build all of the URLS that are found
for i in $(turbolift -u $USERNAME -a $APIKEY --os-rax-auth $REGION list -c cdn | awk '/\|/ {print $4}'); do
echo "$CDN_VAR/$i" | tee -a $CDNURLS_LOG
done
echo "Data can be found here: $CDNURLS_LOG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment