forked from obfuscurity/synthesize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·122 lines (99 loc) · 3.99 KB
/
install
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash -ex
# Graphite installation script for Ubuntu 14.04
# Jason Dixon <[email protected]>
SYNTHESIZE_HOME=$( cd "$( dirname "$0" )" && pwd )
UBUNTU_RELEASE=`lsb_release -a 2>/dev/null | grep '^Descrip' | cut -s -f 2`
GRAPHITE_HOME='/opt/graphite'
rm -rf $GRAPHITE_HOME
GRAPHITE_CONF="${GRAPHITE_HOME}/conf"
GRAPHITE_STORAGE="${GRAPHITE_HOME}/storage"
if [ -z $GRAPHITE_RELEASE ]; then
GRAPHITE_RELEASE='0.9.15'
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 "Looks like you already have a Graphite installation in ${GRAPHITE_HOME}, aborting."
exit 1
fi
# Update apt since the vagrant image might be old
apt-get update -y
# Install package dependencies from apt
RUNLEVEL=1 apt-get install -y libcairo2-dev libffi-dev pkg-config python-dev python-pip fontconfig apache2 libapache2-mod-wsgi git-core collectd memcached gcc g++ make libtool automake
# Download source repositories for Graphite/Carbon/Whisper and Statsite
cd /usr/local/src
if [ -d graphite-web ]; then
echo already git clone graphite-web
else
git clone https://github.com/graphite-project/graphite-web.git
fi
if [ -d carbon ]; then
echo already git clone carbon
else
git clone https://github.com/graphite-project/carbon.git
fi
if [ -d whisper ]; then
echo already git clone whisper
else
git clone https://github.com/graphite-project/whisper.git
fi
if [ -d statsite ]; then
echo already git clone statsite
else
git clone https://github.com/armon/statsite.git
fi
# Build and install Graphite/Carbon/Whisper and Statsite
cd whisper; git checkout ${GRAPHITE_RELEASE}; python setup.py install
cd ../carbon; git checkout ${GRAPHITE_RELEASE}; pip install -r requirements.txt; python setup.py install
cd ../graphite-web; git checkout ${GRAPHITE_RELEASE}; pip install -r requirements.txt; python check-dependencies.py; python setup.py install
cd ../statsite; ./bootstrap.sh; ./configure; make; cp src/statsite /usr/local/sbin/; cp sinks/graphite.py /usr/local/sbin/statsite-sink-graphite.py
# Install configuration files for Graphite/Carbon and Apache
cp ${SYNTHESIZE_HOME}/templates/statsite/statsite.conf /etc/statsite.conf
mkdir ${GRAPHITE_CONF}/examples
mv ${GRAPHITE_CONF}/*.example ${GRAPHITE_CONF}/examples/
cp ${SYNTHESIZE_HOME}/templates/graphite/conf/* ${GRAPHITE_CONF}/
cp ${SYNTHESIZE_HOME}/templates/collectd/collectd.conf /etc/collectd/
cp ${SYNTHESIZE_HOME}/templates/apache/graphite.conf /etc/apache2/sites-available/
cp ${SYNTHESIZE_HOME}/templates/apache/ports.conf /etc/apache2/
cp ${SYNTHESIZE_HOME}/templates/init/* /etc/init/
cp ${SYNTHESIZE_HOME}/templates/init.d/* /etc/init.d/
# Setup the correct Apache site and modules
a2dissite 000-default
a2ensite graphite
a2enmod ssl
a2enmod socache_shmcb
a2enmod rewrite
# Install configuration files for Django
cd ${GRAPHITE_HOME}/webapp/graphite
cp ${SYNTHESIZE_HOME}/templates/graphite/webapp/* .
sed -i -e "s/UNSAFE_DEFAULT/`date | md5sum | cut -d ' ' -f 1`/" local_settings.py
# Setup the Django database
python manage.py syncdb --noinput
chown www-data:www-data ${GRAPHITE_STORAGE}/graphite.db
# Add carbon system user and set permissions
userdel carbon
groupadd -g 998 carbon
useradd -c "carbon user" -g 998 -u 998 -s /bin/false carbon
chmod 775 ${GRAPHITE_STORAGE}
chown www-data:carbon ${GRAPHITE_STORAGE}
chown -R carbon ${GRAPHITE_STORAGE}/whisper
mkdir ${GRAPHITE_STORAGE}/log/apache2
chown www-data ${GRAPHITE_STORAGE}/log/webapp
chmod +x /etc/init.d/carbon-cache
# Setup hourly cron to rebuild Graphite index
cp ${SYNTHESIZE_HOME}/templates/graphite/cron/build-index /etc/cron.hourly/graphite-build-index
chmod 755 /etc/cron.hourly/graphite-build-index
sudo -u www-data /opt/graphite/bin/build-index.sh
service carbon-cache stop
service memcached stop
service collectd stop
service apache2 stop
# Start our processes
update-rc.d carbon-cache defaults
service carbon-cache start
service memcached start
service collectd start
service apache2 start
service statsite start