Allow creation of DO images for a specific revision

This commit is contained in:
Girish Ramakrishnan
2014-08-29 11:21:14 -07:00
parent c192020a4b
commit d6ecb4aa55
3 changed files with 14 additions and 9 deletions
+1
View File
@@ -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
+6 -2
View File
@@ -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
+7 -7
View File
@@ -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 <<EOS
git fetch
git reset --hard origin/master
git reset --hard $BOX_REVISION
EOS
echo "[II] Done"
echo "[II] Run bootstrap script..."
/bin/bash $SRCDIR/scripts/bootstrap.sh https://appstore-dev.herokuapp.com
# /bin/bash $SRCDIR/scripts/bootstrap.sh https://nebulon.fwd.wf
/bin/bash $SRCDIR/scripts/bootstrap.sh https://appstore-dev.herokuapp.com $BOX_REVISION
echo "[II] Done"
echo "[II] Disable bootstrap init script"