-
-
Save abdi-d/9187182 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BUCKET=$1 | |
| TMP_DIR=`mktemp -d -t gzsync` | |
| # check that we have a trailing slash | |
| [[ $BUCKET != */ ]] && BUCKET="$BUCKET"/ | |
| printf "Copying files to temporary directory... " | |
| cp -R . $TMP_DIR && cd $TMP_DIR | |
| printf "Done\n" | |
| PWD=`pwd` | |
| if [ "$PWD" = "$TMP_DIR" ] | |
| then | |
| for filename in $(find . -type f | sed "s/\.\///g" | grep -v git | grep -v .DS_Store) | |
| do | |
| printf "${filename}... " | |
| gzip -t ${filename} > /dev/null 2>&1 || { gzip -9 ${filename}; mv ${filename}.gz ${filename}; } | |
| s3cmd put ${filename} ${BUCKET}${filename} --add-header "Content-Encoding: gzip" --acl-public > /dev/null 2>&1 | |
| printf "Done\n" | |
| done | |
| printf "Cleaning up... " | |
| cd && rm -rf ${TMP_DIR} | |
| printf "Done\n" | |
| else | |
| echo "ERROR: Failed to change to current directory, exiting" 1>&2 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment