2016-08-22 23:15:37 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-02-21 13:25:57 +01:00
|
|
|
set -e # error out when one of the commands in the script errors.
|
|
|
|
|
2017-03-10 09:55:04 +01:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Usage: $0 {host-to-deploy-to}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
DEPLOYHOST="$1"
|
|
|
|
|
2017-07-14 12:44:32 +02:00
|
|
|
# macOS does not support readlink -f, so we use greadlink instead
|
|
|
|
if [[ `uname` == 'Darwin' ]]; then
|
|
|
|
command -v greadlink 2>/dev/null 2>&1 || { echo >&2 "Install greadlink using brew."; exit 1; }
|
|
|
|
readlink='greadlink'
|
|
|
|
else
|
|
|
|
readlink='readlink'
|
|
|
|
fi
|
|
|
|
|
|
|
|
BLENDER_CLOUD_DIR="$(dirname "$($readlink -f "$0")")"
|
|
|
|
if [ ! -d "$BLENDER_CLOUD_DIR" ]; then
|
|
|
|
echo "Unable to find Blender Cloud dir '$BLENDER_CLOUD_DIR'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
BLENDER_CLOUD_ASSETS="$BLENDER_CLOUD_DIR/cloud/static/assets/"
|
|
|
|
BLENDER_CLOUD_TEMPLATES="$BLENDER_CLOUD_DIR/cloud/templates/"
|
|
|
|
|
|
|
|
if [ ! -d "$BLENDER_CLOUD_ASSETS" ]; then
|
|
|
|
echo "Unable to find assets dir $BLENDER_CLOUD_ASSETS"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $BLENDER_CLOUD_DIR
|
|
|
|
if [ $(git rev-parse --abbrev-ref HEAD) != "production" ]; then
|
|
|
|
echo "You are NOT on the production branch, refusing to rsync_ui." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-08-23 12:50:39 +02:00
|
|
|
PILLAR_DIR=$(python <<EOT
|
|
|
|
from __future__ import print_function
|
|
|
|
import os.path
|
|
|
|
import pillar
|
|
|
|
|
|
|
|
print(os.path.dirname(os.path.dirname(pillar.__file__)))
|
|
|
|
EOT
|
|
|
|
)
|
2016-08-22 23:15:37 +02:00
|
|
|
|
2017-07-14 12:44:32 +02:00
|
|
|
PILLAR_ASSETS="$PILLAR_DIR/pillar/web/static/assets/"
|
|
|
|
PILLAR_TEMPLATES="$PILLAR_DIR/pillar/web/templates/"
|
2016-08-22 23:15:37 +02:00
|
|
|
|
2017-07-14 12:44:32 +02:00
|
|
|
if [ ! -d "$PILLAR_ASSETS" ]; then
|
|
|
|
echo "Unable to find assets dir $PILLAR_ASSETS"
|
2016-08-23 12:50:39 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-08-22 23:15:37 +02:00
|
|
|
cd $PILLAR_DIR
|
|
|
|
if [ $(git rev-parse --abbrev-ref HEAD) != "production" ]; then
|
|
|
|
echo "You are NOT on the production branch, refusing to rsync_ui." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2017-07-14 12:44:32 +02:00
|
|
|
echo "*** GULPA GULPA PILLAR ***"
|
2016-08-22 23:15:37 +02:00
|
|
|
if [ -x ./node_modules/.bin/gulp ]; then
|
|
|
|
./node_modules/.bin/gulp --production
|
|
|
|
else
|
|
|
|
gulp --production
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2017-07-14 12:44:32 +02:00
|
|
|
echo "*** SYNCING PILLAR_ASSETS ***"
|
|
|
|
rsync -avh $PILLAR_ASSETS root@${DEPLOYHOST}:/data/git/pillar/pillar/web/static/assets/
|
2016-08-22 23:15:37 +02:00
|
|
|
|
|
|
|
echo
|
2017-07-14 12:44:32 +02:00
|
|
|
echo "*** SYNCING PILLAR_TEMPLATES ***"
|
|
|
|
rsync -avh $PILLAR_TEMPLATES root@${DEPLOYHOST}:/data/git/pillar/pillar/web/templates/
|
2017-07-13 18:35:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
cd $BLENDER_CLOUD_DIR
|
|
|
|
|
|
|
|
echo
|
2017-07-14 12:44:32 +02:00
|
|
|
echo "*** GULPA GULPA BLENDER_CLOUD ***"
|
2017-07-13 18:35:18 +02:00
|
|
|
./gulp --production
|
|
|
|
|
|
|
|
echo
|
2017-07-14 12:44:32 +02:00
|
|
|
echo "*** SYNCING BLENDER_CLOUD_ASSETS ***"
|
2017-07-13 18:35:18 +02:00
|
|
|
# Exclude files managed by Git.
|
2017-07-14 12:44:32 +02:00
|
|
|
rsync -avh $BLENDER_CLOUD_ASSETS --exclude js/vendor/ root@${DEPLOYHOST}:/data/git/blender-cloud/cloud/static/assets/
|
2017-07-13 18:35:18 +02:00
|
|
|
|
|
|
|
echo
|
2017-07-14 12:44:32 +02:00
|
|
|
echo "*** SYNCING BLENDER_CLOUD_TEMPLATES ***"
|
|
|
|
rsync -avh $BLENDER_CLOUD_TEMPLATES root@${DEPLOYHOST}:/data/git/blender-cloud/cloud/templates/
|