Skip to content

Instantly share code, notes, and snippets.

@mignev
Forked from sanjmen/build
Created November 25, 2013 15:10
Show Gist options
  • Save mignev/7642673 to your computer and use it in GitHub Desktop.
Save mignev/7642673 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This is a simple build script and will be executed on your CI system if
# available. Otherwise it will execute while your application is stopped
# before the deploy step. This script gets executed directly, so it
# could be python, php, ruby, etc.
#
# MEMCACHED SERVER
#
# All credits to: https://github.com/zfdang/memcached-in-openshift
MEMCACHED_VERSION=1.4.15
MEMCACHED_BINARY=${OPENSHIFT_DATA_DIR}memcached/bin/memcached
if [ ! -d ${OPENSHIFT_DATA_DIR}memcached ]; then
echo "create ${OPENSHIFT_DATA_DIR}memcached..."
mkdir ${OPENSHIFT_DATA_DIR}memcached
echo "download memcached to temp folder..."
cd ${OPENSHIFT_TMP_DIR}
if [ ! -d memcached-${MEMCACHED_VERSION} ]; then
curl -L -o memcached-${MEMCACHED_VERSION}.tar.gz http://memcached.googlecode.com/files/memcached-${MEMCACHED_VERSION}.tar.gz
tar -xvzf memcached-${MEMCACHED_VERSION}.tar.gz
fi
echo "Start compiling memcached ${MEMCACHED_VERSION} on Openshift (i'll take a while)"
cd memcached-${MEMCACHED_VERSION}
sh configure --prefix=${OPENSHIFT_DATA_DIR}memcached
make
make install
if [ -e "${MEMCACHED_BINARY}" ]; then
echo "memcached was installed successfully: ${MEMCACHED_BINARY}"
else
echo "-------------------------------------------"
echo "Failed to install memcached!"
echo "Please install memcached into ${MEMCACHED_BINARY} manually!"
echo "-------------------------------------------"
fi
else
echo "${OPENSHIFT_DATA_DIR}memcached exists already."
fi
#NGINX
if [ ! -d $OPENSHIFT_DATA_DIR/nginx/sbin ]; then
# download, build and install nginx into our data directory.
# pcre is needed to build nginx, so we also download that.
cd $OPENSHIFT_TMP_DIR
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
wget http://nginx.org/download/nginx-1.2.0.tar.gz
tar -xvf pcre-8.30.tar.gz
tar -xvf nginx-1.2.0.tar.gz
cd nginx-1.2.0
mkdir $OPENSHIFT_DATA_DIR/nginx
./configure --prefix=$OPENSHIFT_DATA_DIR/nginx --with-pcre=$OPENSHIFT_TMP_DIR/pcre-8.30
make && make install && make clean
# cleanup
rm -rf $OPENSHIFT_TMP_DIR/*
echo "NGINX SUCCESSFULLY INSTALLED!"
else
echo "NGINX ALREADY INSTALLED"
fi
source $OPENSHIFT_DATA_DIR/virtenv/bin/activate
 
pip install Django==1.4.3
django-admin.py startproject --template=https://github.com/pinax/pinax-project-account/zipball/master $OPENSHIFT_REPO_DIR/orcheeder
pip install --use-mirrors -r $OPENSHIFT_REPO_DIR/orcheeder/requirements.txt
#!/bin/bash
# This is a simple post deploy hook executed after your application
# is deployed and started. This script gets executed directly, so
# it could be python, php, ruby, etc.
MEMCACHED_BINARY=${OPENSHIFT_DATA_DIR}memcached/bin/memcached
if [ ! -e MEMCACHED_BINARY ]; then
killall memcached
$MEMCACHED_BINARY -l $OPENSHIFT_INTERNAL_IP -p 22322 -m 64 -d
echo "${MEMCACHED_BINARY} started!"
else
echo "============================================"
echo "${MEMCACHED_BINARY} does not exist!."
echo "You should manually install it ..."
echo "============================================"
fi
#!/bin/bash
# This is a simple script and will be executed on your CI system if
# available. Otherwise it will execute while your application is stopped
# before the build step. This script gets executed directly, so it
# could be python, php, ruby, etc.
if [ ! -d $OPENSHIFT_DATA_DIR/python-2.7/bin ]; then
if [ "$OPENSHIFT_DATA_DIR/python-2.7/bin/python -V" != 'Python 2.7.3' ]; then
# install python 2.7.3
cd $OPENSHIFT_TMP_DIR
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar jxf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure --prefix=$OPENSHIFT_DATA_DIR/python-2.7
make install
fi
# set path
export PATH=$OPENSHIFT_DATA_DIR/python-2.7/bin:$PATH
#install virtualenv
cd $OPENSHIFT_TMP_DIR
wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.8.4.tar.gz
tar xzvf virtualenv-1.8.4.tar.gz
# Create the first "bootstrap" environment.
python virtualenv-1.8.4/virtualenv.py $OPENSHIFT_DATA_DIR/ENV
rm -rf virtualenv-1.8.4
# Install virtualenv into the environment.
$OPENSHIFT_DATA_DIR/ENV/bin/pip install virtualenv
# Install the environment for this project
$OPENSHIFT_DATA_DIR/ENV/bin/virtualenv $OPENSHIFT_DATA_DIR/virtenv
# cleanup
rm -rf $OPENSHIFT_TMP_DIR/*
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment