forked from obfuscurity/synthesize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade
executable file
·71 lines (61 loc) · 2.78 KB
/
upgrade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Synthesize upgrade script for Graphite 1.0.0
# Jason Dixon <jason@dixongroup.net>
SYNTHESIZE_HOME=$( cd "$( dirname "$0" )" && pwd )
UBUNTU_RELEASE=`lsb_release -a 2>/dev/null | grep '^Descrip' | cut -s -f 2`
GRAPHITE_HOME='/opt/graphite'
GRAPHITE_CONF="${GRAPHITE_HOME}/conf"
GRAPHITE_STORAGE="${GRAPHITE_HOME}/storage"
if [[ ! $DANGER_ZONE =~ 'TRUE' ]]; then
echo "This upgrade script has not been thoroughly tested. There is a non-zero"
echo "chance that running this script will break your Synthesize-Graphite"
echo "installation. If you accept this warning and wish to continue anyways,"
echo "run this script again with the DANGER_ZONE environment variable set to TRUE."
echo
exit 1
fi
if [ -z $GRAPHITE_RELEASE ]; then
GRAPHITE_RELEASE='1.0.0'
fi
if [[ ! $UBUNTU_RELEASE =~ 'Ubuntu 14.04' ]]; then
echo "Sorry, this is only supported for Ubuntu Linux 14.04."
exit 1
fi
if [[ ! -d $GRAPHITE_HOME ]]; then
echo "Unable to find an existing Graphite installation in ${GRAPHITE_HOME}, aborting."
exit 1
fi
# Update, Build and install Graphite/Carbon/Whisper and Statsite
cd /usr/local/src
cd whisper; git fetch origin; \
git checkout ${GRAPHITE_RELEASE}; \
python setup.py install
cd ../carbon; git fetch origin; \
git checkout ${GRAPHITE_RELEASE}; \
pip install -r requirements.txt; \
python setup.py install
cd ../graphite-web; git fetch origin; \
git checkout ${GRAPHITE_RELEASE}; \
pip install -r requirements.txt; \
python check-dependencies.py; \
python setup.py install
# Install configuration files for Graphite/Carbon and Apache
cp -b ${GRAPHITE_CONF}/*.example ${GRAPHITE_CONF}/examples/
cp -b ${SYNTHESIZE_HOME}/templates/graphite/conf/* ${GRAPHITE_CONF}/
cp -b ${SYNTHESIZE_HOME}/templates/collectd/collectd.conf /etc/collectd/
cp -b ${SYNTHESIZE_HOME}/templates/apache/graphite.conf /etc/apache2/sites-available/
# Install configuration files for Django
cd ${GRAPHITE_HOME}/webapp/graphite
cp -b ${SYNTHESIZE_HOME}/templates/graphite/webapp/* .
sed -i -e "s/UNSAFE_DEFAULT/`date | md5sum | cut -d ' ' -f 1`/" local_settings.py
# Upgrade Django and migrate the webapp database
service apache2 stop
BACKUP=`date +%Y%m%d_%H%M%S`
mv ${GRAPHITE_STORAGE}/graphite.db ${GRAPHITE_STORAGE}/graphite.db.backup-${BACKUP}
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py dumpdata --indent 4 --settings=graphite.settings > dump_${BACKUP}_data.json
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py migrate --noinput --settings=graphite.settings --run-syncdb
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py loaddata --settings=graphite.settings dump_${BACKUP}_data.json
# Restart our processes
service carbon-cache restart
service memcached restart
service apache2 start