Created
February 5, 2016 07:37
-
-
Save noda-sin/722da6463cfd3da98aa9 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# ------------------------------------------------------------------ | |
# Deploy chef-repo.tar.gz of kirishima to S3 bucket | |
# ------------------------------------------------------------------ | |
VERSION=1.0 | |
SUBJECT=kiri-deploy-to-s3 | |
USAGE="Usage: deploy env" | |
# --- Options processing ------------------------------------------- | |
if [ $# == 0 ] ; then | |
echo $USAGE | |
exit 1; | |
fi | |
while getopts ":vh" optname | |
do | |
case "$optname" in | |
"v") | |
echo "Version $VERSION" | |
exit 0; | |
;; | |
"h") | |
echo $USAGE | |
exit 0; | |
;; | |
"?") | |
echo "Unknown option $OPTARG" | |
exit 0; | |
;; | |
":") | |
echo "No argument value for option $OPTARG" | |
exit 0; | |
;; | |
*) | |
echo "Unknown error while processing options" | |
exit 0; | |
;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
# --- Locks ------------------------------------------------------- | |
LOCK_FILE=/tmp/$SUBJECT.lock | |
if [ -f "$LOCK_FILE" ]; then | |
echo "Script is already running" | |
exit | |
fi | |
trap "rm -f $LOCK_FILE" EXIT | |
touch $LOCK_FILE | |
# --- Body -------------------------------------------------------- | |
# SCRIPT LOGIC GOES HERE | |
CHEF_TAR="chef-repo.tar.gz" | |
env=$1 | |
berks update | |
berks vendor | |
tar cvzf "$CHEF_TAR" --exclude "$CHEF_TAR" --exclude ".DS_Store" * | |
aws s3 cp "$CHEF_TAR" "s3://kiri-$env-chef-bucket" --profile "aws-$env" | |
# ----------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment