diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 47cab605b..adb946769 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -14,6 +14,7 @@ BACKUP_DIR=/home/$USER/.yellowtent # we get the appstore origin from the caller which is baked into the image APP_SERVER_URL=$1 +BOX_REVISION=$2 echo "==== Setup /etc/yellowtent ====" mkdir -p /etc/yellowtent diff --git a/scripts/createDigitalOceanImage.sh b/scripts/createDigitalOceanImage.sh index 7d2ef2319..df3e88145 100755 --- a/scripts/createDigitalOceanImage.sh +++ b/scripts/createDigitalOceanImage.sh @@ -8,8 +8,12 @@ JSON="$SCRIPT_DIR/../node_modules/.bin/json" CURL="curl -s" UBUNTU_IMAGE_SLUG="ubuntu-14-04-x64" # ID=5141286 DATE=`date +%Y-%m-%d-%H%M%S` -BOX_NAME="box-$DATE" SNAPSHOT_NAME="box-base-image-$DATE" +BOX_REVISION=origin/master +if [ ! -z "$1" ]; then + BOX_REVISION=$1 +fi +BOX_NAME="box-`echo $BOX_REVISION | sed -e 's/\//_/g'`-$DATE" # remove slashes function get_ssh_key_id() { $CURL "https://api.digitalocean.com/v1/ssh_keys/?client_id=$CLIENT_ID&api_key=$API_KEY" \ @@ -132,7 +136,7 @@ while true; do done echo "Executing init script" -ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $SCRIPT_DIR/ssh/id_rsa_yellowtent root@$DROPLET_IP "/bin/bash /root/initializeBaseUbuntuImage.sh" +ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $SCRIPT_DIR/ssh/id_rsa_yellowtent root@$DROPLET_IP "/bin/bash /root/initializeBaseUbuntuImage.sh $BOX_REVISION" if [ $? -ne 0 ]; then echo "Init script failed" exit 1 diff --git a/scripts/initializeBaseUbuntuImage.sh b/scripts/initializeBaseUbuntuImage.sh index f8f1a58a9..efe4d6d30 100755 --- a/scripts/initializeBaseUbuntuImage.sh +++ b/scripts/initializeBaseUbuntuImage.sh @@ -5,6 +5,7 @@ set -v USER_HOME=/home/yellowtent SRCDIR=$USER_HOME/box USER=yellowtent +BOX_REVISION=$1 echo "==== Create User $USER ====" id $USER @@ -16,7 +17,7 @@ fi # now exit on failure set -e -echo "== Yellowtent base image preparation ==" +echo "== Yellowtent base image preparation ($BOX_REVISION) ==" export DEBIAN_FRONTEND=noninteractive @@ -76,16 +77,16 @@ if [ -d "$SRCDIR/.git" ]; then echo "Updating the box repo" cd $SRCDIR git fetch - git reset --hard origin/master else echo "Cloning the box repo" rm -rf $SRCDIR mkdir -p $USER_HOME cd $USER_HOME git clone http://bootstrap:not4long@yellowtent.girish.in/yellowtent/box.git - echo "git HEAD is `git rev-parse HEAD`" - cd box + cd $SRCDIR fi +git reset --hard $BOX_REVISION +echo "git HEAD is `git rev-parse HEAD`" NPM_INSTALL="npm install --production" rm -rf ./node_modules @@ -117,13 +118,12 @@ echo "[II] Update to latest git revision..." cd $SRCDIR sudo -u $USER bash <