Skip to content

Instantly share code, notes, and snippets.

@chriskief
Created October 24, 2013 02:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chriskief/7130536 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
#
# Test for a reboot, if this is a reboot just skip this script.
#
if test "$RS_REBOOT" = "true" ; then
echo "Skip software update on reboot."
logger -t RightScale "Software update, skipped on a reboot."
exit 0
fi
#
# install and upgrade a bunch of stuff
#
if [ $RS_DISTRO = ubuntu ]; then
# fix sftp issue
perl -p -i -e "s/\/usr\/libexec/\/usr\/lib/g" /etc/ssh/sshd_config
service ssh restart
# upgrade pip
yes | pip install --upgrade pip
# after updating pip, need to relink it so do_update_code works
ln -s /usr/local/bin/pip /usr/bin/pip
# install this for pip
apt-get install -y libyaml-dev
# install these for compressor
apt-get install -y default-jre
apt-get install -y npm
npm install -g less
npm install -g coffee-script
gem install sass
# link these so compress can find them
ln -s /usr/local/bin/lessc /usr/bin/lessc
ln -s /usr/local/bin/sass /usr/bin/sass
ln -s /usr/local/bin/coffee /usr/bin/coffee
# install Django beta
yes | pip uninstall Django
wget https://www.djangoproject.com/download/1.5b2/tarball/
mv index.html Django-1.5b2.tar.gz
tar xzvf Django-1.5b2.tar.gz
cd Django-1.5b2
python setup.py install
cd ../
rm -rf Django-1.5b2
rm Django-1.5b2.tar.gz
# install pip packages
yes | pip install --upgrade distribute
yes | pip install --upgrade MySQL-python
yes | pip install django-compressor
yes | pip install django-appconf
yes | pip install versiontools
yes | pip install --upgrade simplejson
yes | pip install "BeautifulSoup<4.0"
STATIC_DEPS=true
yes | sudo pip install lxml
yes | pip install odict
yes | pip install ply
yes | pip install html5lib
yes | pip install httplib2
yes | pip install slimit
yes | pip install boto
yes | pip install oauth2
yes | pip install python-openid
yes | pip install PyYAML
yes | pip install pytz
yes | pip install py-bcrypt
yes | pip install yolk
# cleanup simplejson (fixes yolk)
rm /usr/lib/python2.7/dist-packages/simplejson-2.3.2.egg-info
# remove generated wsgi.py in site root
rm /home/webapps/$APPLICATION/wsgi.py
# update apache config
perl -p -i -e "s/$APPLICATION\/wsgi.py/$APPLICATION\/conf\/wsgi.py/g" /etc/apache2/sites-available/http-80-localhost.vhost.conf
# copy and compress assets
python /home/webapps/$APPLICATION/manage.py collectstatic --noinput -i css -i js
python /home/webapps/$APPLICATION/manage.py compress
# restart apache
service apache2 restart
fi
logger -t RightScale "Software update completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment