Last active
November 4, 2015 19:46
-
-
Save tanzeeb/6ec3b6bebfa4b5a1e274 to your computer and use it in GitHub Desktop.
Script to deploy Pivotal CF MS Data Sync to Pivotal Web Services
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
#!/usr/bin/env bash -ex | |
id=$RANDOM | |
start_dir=`pwd` | |
work_dir=tmp | |
REDIS_SERVICE=rediscloud | |
CONFIG_PLAN=30mb | |
DATA_PLAN=30mb | |
APP_NAME=cfms-ds-$id | |
CONFIG_REDIS=cfms-ds-cr-$id | |
DATA_REDIS=cfms-ds-dr-$id | |
DOMAIN=cfapps.io | |
AUTH_URL=https://uaa.run.pivotal.io/userinfo | |
trap "cd $start_dir; rm -rf $work_dir" EXIT | |
unzip $1 releases/*.tgz -d $work_dir | |
cd $work_dir/releases | |
tar xzf *data*sync-*.tgz | |
cd packages | |
tar xzf datasync-datastore.tgz | |
cd datasync-datastore | |
cf push $APP_NAME \ | |
-d $DOMAIN \ | |
-i 1 \ | |
-m 128M \ | |
-n $APP_NAME \ | |
-p ./datasync-datastore-latest.zip \ | |
-b binary_buildpack \ | |
--no-manifest \ | |
--no-start \ | |
cf set-env $APP_NAME ADMIN_AUTH_URL $AUTH_URL | |
cf set-env $APP_NAME USER_AUTH_URL $AUTH_URL | |
cf set-env $APP_NAME CONFIG_REDIS $CONFIG_REDIS | |
cf set-env $APP_NAME DATA_REDIS $DATA_REDIS | |
cf create-service $REDIS_SERVICE $CONFIG_PLAN ${CONFIG_REDIS}_sp | |
sleep 20 | |
cf bind-service $APP_NAME ${CONFIG_REDIS}_sp | |
cf create-service $REDIS_SERVICE $DATA_PLAN ${DATA_REDIS}_sp | |
sleep 20 | |
cf bind-service $APP_NAME ${DATA_REDIS}_sp | |
cr_creds=`cf env $APP_NAME | \ | |
grep -A 4 credentials | head -n 5 | \ | |
sed 's/hostname/host/g' | \ | |
head -n 4 | tail -n 3 | tr -d ' ' | tr "\\n" " "` | |
dr_creds=`cf env $APP_NAME | \ | |
grep -A 4 credentials | tail -n 5 | \ | |
sed 's/hostname/host/g' | \ | |
head -n 4 | tail -n 3 | tr -d ' ' | tr "\\n" " "` | |
cf cups $CONFIG_REDIS -p "{ $cr_creds }" | |
cf bind-service $APP_NAME $CONFIG_REDIS | |
cf cups $DATA_REDIS -p "{ $dr_creds }" | |
cf bind-service $APP_NAME $DATA_REDIS | |
cf start $APP_NAME | |
echo "Data Sync deployed to $APP_NAME.$DOMAIN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment