-
-
Save ccakes/cb9576b377b205709ad1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VER=0.9.10 | |
HERE=`pwd` | |
apt-get install python-setuptools python-django-tagging python-pysqlite2 python-memcache python-ldap python-django python-cairo-dev | |
wget https://launchpad.net/graphite/0.9/${VER}/+download/graphite-web-${VER}.tar.gz | |
wget https://launchpad.net/graphite/0.9/${VER}/+download/carbon-${VER}.tar.gz | |
wget https://launchpad.net/graphite/0.9/${VER}/+download/whisper-${VER}.tar.gz | |
tar zxvf graphite-web-${VER}.tar.gz | |
tar zxvf carbon-${VER}.tar.gz | |
tar zxvf whisper-${VER}.tar.gz | |
# fpm package up whisper: | |
fpm -v ${VER} -s python -t deb whisper-$VER/setup.py | |
# install whisper... optional? | |
dpkg -i python-whisper_${VER}_all.deb | |
(cd carbon-${VER} ; python setup.py install) | |
(cd graphite-web-${VER} ; python setup.py install) | |
cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf | |
cat >/opt/graphite/conf/storage-schemas.conf <<EOF | |
# Schema definitions for Whisper files. Entries are scanned in order, | |
# and first match wins. This file is scanned for changes every 60 seconds. | |
# | |
# [name] | |
# pattern = regex | |
# retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ... | |
# Carbon's internal metrics. This entry should match what is specified in | |
# CARBON_METRIC_PREFIX and CARBON_METRIC_INTERVAL settings | |
[carbon] | |
pattern = ^carbon\. | |
retentions = 60:90d | |
[everything_1min_13months] | |
priority = 100 | |
pattern = .* | |
retentions = 1m:395d | |
EOF | |
sed -i -e 's/@DJANGO_ROOT@/\/usr\/lib\/python2.7\/dist-packages\/django/' /opt/graphite/examples/example-graphite-vhost.conf | |
cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py | |
echo "MEMCACHE_HOSTS = ['127.0.0.1:11211']" >> /opt/graphite/webapp/graphite/local_settings.py | |
tee -a /opt/graphite/webapp/graphite/local_settings.py <<EOF | |
DATABASES = { | |
'default': { | |
'NAME': '/opt/graphite/storage/graphite.db', | |
'ENGINE': 'django.db.backends.sqlite3', | |
'USER': '', | |
'PASSWORD': '', | |
'HOST': '', | |
'PORT': '' | |
} | |
} | |
EOF | |
cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi | |
cd /opt/graphite/webapp/graphite | |
echo no | python manage.py syncdb | |
python manage.py createsuperuser --email admin@admin.com --username spire | |
chown -R www-data:www-data /opt/graphite/storage | |
cat > /etc/init.d/carbon-cache <<EOF | |
#! /bin/bash | |
### BEGIN INIT INFO | |
# Provides: carbon-cache | |
# Required-Start: \$remote_fs \$syslog | |
# Required-Stop: \$remote_fs \$syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Carbon-Cache | |
### END INIT INFO | |
set -e | |
. /lib/lsb/init-functions | |
case "\$1" in | |
start) | |
if [ $(stat -c %U /opt/graphite/storage) != "www-data" ]; then | |
echo "/opt/graphite/storage not owned by www-data!" | |
exit 255 | |
fi | |
cd /opt/graphite/ | |
log_daemon_msg "Starting carbon-cache" || true | |
sudo -E -u www-data nohup /opt/graphite/bin/carbon-cache.py start > /opt/graphite/storage/carbon-cache.log 2>&1 < /dev/null & | |
[[ $? -eq 0 ]] && log_end_msg 0 || log_end_msg 1 | |
;; | |
stop) | |
log_daemon_msg "Stopping carbon-cache" || true | |
sudo -E -u www-data pkill carbon-cache.py | |
[[ $? -eq 0 ]] && log_end_msg 0 || log_end_msg 1 | |
;; | |
*) | |
log_action_msg "Usage: /etc/init.d/carbon-cache {start|stop}" || true | |
exit 1 | |
esac | |
exit 0 | |
EOF | |
chmod +x /etc/init.d/carbon-cache | |
cat > /etc/init.d/graphite-web <<EOF | |
#! /bin/bash | |
### BEGIN INIT INFO | |
# Provides: graphite-web | |
# Required-Start: \$network \$syslog | |
# Required-Stop: \$network \$syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Graphite Web | |
### END INIT INFO | |
set -e | |
. /lib/lsb/init-functions | |
export PYTHONPATH=/opt/graphite/storage/whisper | |
GRAPHITEPATH=/opt/graphite | |
case "$1" in | |
start) | |
if [ www-data != "www-data" ]; then | |
echo "/opt/graphite/storage not owned by www-data!" | |
exit 255 | |
fi | |
log_daemon_msg "Starting graphite-web" || true | |
sudo -E -u www-data nohup /opt/graphite/bin/run-graphite-devel-server.py --libs=$GRAPHITEPATH/webapp/ $GRAPHITEPATH > /opt/graphite/storage/graphite-web.log 2>&1 < /dev/null & | |
[[ 0 -eq 0 ]] && log_end_msg 0 || log_end_msg 1 | |
;; | |
stop) | |
log_daemon_msg "Stopping graphite-web" || true | |
sudo -E -u www-data ps aux | grep django-admin | grep -v grep | awk '{print $2}' | xargs kill | |
[[ 0 -eq 0 ]] && log_end_msg 0 || log_end_msg 1 | |
;; | |
*) | |
log_action_msg "Usage: /etc/init.d/graphite-web {start|stop}" || true | |
exit 1 | |
esac | |
exit 0 | |
EOF | |
chmod +x /etc/init.d/graphite-web | |
# now fpm the whole mess | |
cd $HERE | |
fpm -s dir -t deb -n graphite -d python-twisted -v ${VER} /etc/init.d/carbon-cache /opt/graphite |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment