Skip to content

Instantly share code, notes, and snippets.

@nickman
Created May 20, 2011 13:16
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save nickman/982866 to your computer and use it in GitHub Desktop.
Save nickman/982866 to your computer and use it in GitHub Desktop.
Graphite Server Install Script for Ubuntu
#!/bin/bash
#######################################
# Graphite Install
# Run with sudo for best results
#
#######################################
if [[ "$(/usr/bin/whoami)" != "root" ]]; then
echo "This script must be run as root or using sudo.Script aborted."
exit 1
fi
export GVERSION=0.9.8
export X_DIR=`dirname $0`
export INSTALL_DIR=`pwd "$X_DIR"`
echo "===================================================="
echo "Install Directory:$INSTALL_DIR"
echo "===================================================="
echo ""
echo ""
echo "===================================================="
echo "Downloading Graphite Server Binaries"
echo "===================================================="
echo ""
echo ""
echo "Retrieving Graphite Web...."
wget http://launchpad.net/graphite/1.0/$GVERSION/+download/graphite-web-$GVERSION.tar.gz
echo "Retrieving Carbon...."
wget http://launchpad.net/graphite/1.0/$GVERSION/+download/carbon-$GVERSION.tar.gz
echo "Retrieving Whisper...."
wget http://launchpad.net/graphite/1.0/$GVERSION/+download/whisper-$GVERSION.tar.gz
PACKAGES="apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 python3.1 libpython3.1 python3.1-minimal libapache2-mod-wsgi libaprutil1-ldap memcached python-cairo-dev python-django python-ldap python-memcache python-pysqlite2 sqlite3 erlang-os-mon erlang-snmp rabbitmq-server bzr expect ssh"
echo ""
echo ""
echo "===================================================="
echo "Installing Required Packages"
echo "Packages:$PACKAGES"
echo "===================================================="
echo ""
echo ""
apt-get install --assume-yes --quiet $PACKAGES
- Show quoted text -
echo ""
echo ""
echo "===================================================="
echo "Completed Required Package Installs"
echo "===================================================="
echo ""
echo ""
echo ""
echo ""
echo "===================================================="
echo "Installing Graphite Server Binaries"
echo "===================================================="
echo ""
echo ""
echo "===================================================="
echo "Expanding Graphite Archives"
echo "===================================================="
#==========================================
tar xzvf whisper-$GVERSION.tar.gz
tar xzvf carbon-$GVERSION.tar.gz
tar xzvf graphite-web-$GVERSION.tar.gz
#==========================================
# Install Whisper
#==========================================
echo "===================================================="
echo "Installing Whisper"
echo "===================================================="
pushd whisper-$GVERSION
python setup.py install
popd
#==========================================
# Install Carbon
#==========================================
echo "===================================================="
echo "Installing Carbon"
echo "===================================================="
pushd carbon-$GVERSION
python setup.py install
popd
#==========================================
# Configure Carbon
#==========================================
echo "===================================================="
echo "Configuring Carbon"
echo "===================================================="
pushd /opt/graphite/conf
#cp carbon.conf.example carbon.conf
#cp storage-schemas.conf.example storage-schemas.conf
#==========================================
# Install TXAmqp
#==========================================
echo "===================================================="
echo "Installing Python TXAMQP"
echo "===================================================="
wget http://launchpad.net/txamqp/trunk/0.3/+download/python-txamqp_0.3.orig.tar.gz
tar xzvf python-txamqp_0.3.orig.tar.gz
pushd python-txamqp-0.3
python setup.py install
#==========================================
popd
popd
pushd graphite-web-$GVERSION
echo "===================================================="
echo "Checking Dependencies"
echo "===================================================="
python check-dependencies.py
#==========================================
# Install Graphite WebApp
#==========================================
echo "===================================================="
echo "Installing Graphite WebApp"
echo "===================================================="
python setup.py install
echo "===================================================="
echo "Deploying Preconfigs From $INSTALL_DIR to /opt/graphite/conf"
echo "===================================================="
cp $INSTALL_DIR/wsgi.conf /opt/graphite/conf
cp $INSTALL_DIR/graphite.wsgi /opt/graphite/conf
cp $INSTALL_DIR/dashboard.conf /opt/graphite/conf
cp $INSTALL_DIR/carbon.conf /opt/graphite/conf
cp $INSTALL_DIR/storage-schemas.conf /opt/graphite/conf
cp $INSTALL_DIR/st*_carbon.sh /opt/graphite/
chmod 770 /opt/graphite/st*_carbon.sh
echo "===================================================="
echo "Configuring Apache2"
echo "===================================================="
rm /etc/apache2/sites-enabled/000-default
rm /etc/apache2/mods-enabled/wsgi.conf
ln -s -v $INSTALL_DIR/vhost.conf /etc/apache2/sites-enabled/000-default
ln -s -v $INSTALL_DIR/wsgi.conf /etc/apache2/mods-enabled/wsgi.conf
ln -s /etc/apache2/mods-enabled/info.load /etc/apache2/mods-available/info.load
ln -s /etc/apache2/mods-enabled/info.conf /etc/apache2/mods-available/info.conf
echo "===================================================="
echo "Creating Django Admin User"
echo "===================================================="
pushd $INSTALL_DIR
cd /opt/graphite/webapp/graphite
expect $INSTALL_DIR/dbresponse.txt
popd
sqlite3 -init $INSTALL_DIR/user.sql /opt/graphite/storage/graphite.db
echo ""
echo ""
echo "===================================================="
echo "Completed Graphite Server Binaries"
echo "===================================================="
echo ""
echo ""
echo ""
echo ""
echo "===================================================="
echo "Cleaning Up"
echo "===================================================="
echo ""
echo ""
apt-get --assume-yes autoremove
rm /opt/graphite/conf/python-txamqp_0.3.orig.tar.gz
echo "===================================================="
echo "Creating and Setting Ownership on Graphite Dirs"
echo "===================================================="
mkdir -p /opt/graphite/storage/log/carbon-cache/
chown -R www-data /opt/graphite
mkdir -p /etc/httpd/wsgi/
chown -R www-data /etc/httpd/wsgi/
echo "===================================================="
echo "Setting Up Carbon init.d scripts"
echo "===================================================="
cp $INSTALL_DIR/carbon /etc/init.d/
chmod 770 /etc/init.d/carbon
ln -s /etc/init.d/carbon /etc/rc2.d/S89carbon
ln -s /etc/init.d/carbon /etc/rc3.d/S89carbon
ln -s /etc/init.d/carbon /etc/rc4.d/S89carbon
ln -s /etc/init.d/carbon /etc/rc5.d/S89carbon
ln -s /etc/init.d/carbon /etc/rc0.d/K10carbon
ln -s /etc/init.d/carbon /etc/rc1.d/K10carbon
ln -s /etc/init.d/carbon /etc/rc6.d/K10carbon
echo "===================================================="
echo "Starting Carbon and Restarting Apache2"
echo "===================================================="
/etc/init.d/carbon start
/etc/init.d/apache2 restart
#echo ""
#echo ""
#echo "===================================================="
#echo "Retrieving Graphite Source Code"
#echo "===================================================="
#echo ""
#echo ""
#bzr branch lp:graphite
@lmilbaum
Copy link

I am trying to update the script. Would appreciate your assistance.
Can you point out how the wsgi.conf file get into the $INSTALL_DIR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment