Skip to content

Instantly share code, notes, and snippets.

@dmfenton
Created August 29, 2017 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmfenton/6771949ae214ff24e20ad792deded93a to your computer and use it in GitHub Desktop.
Save dmfenton/6771949ae214ff24e20ad792deded93a to your computer and use it in GitHub Desktop.
Bash S3 Deploy Script
#!/bin/sh
DIR=$(dirname"$0")
STAMP=$(date +%s)
TEMPDIR="/srv/hub/$STAMP"
APPLICATIONDIR="/arcgis/portal/apps/hub"
OLDDIR=$(cat ./.old-directory)
echo "downloading files to $DIR"
/usr/local/bin/aws s3 cp s3://REDACTED/build.tar.gz "$DIR"
echo "writing application files to $TEMPDIR"
mkdir -p "$TEMPDIR"
tar -xzvf build.tar.gz -C "$TEMPDIR" --strip-components=1 > build-files.log
echo "linking to $APPLICATIONDIR"
ln -sfvn "$TEMPDIR" "$APPLICATIONDIR"
echo "removing previous deploy from $OLDDIR"
rm -rf $OLDDIR
echo "$TEMPDIR" > ".old-directory"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment