-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathubuntu.bash
More file actions
executable file
·155 lines (124 loc) · 3.91 KB
/
ubuntu.bash
File metadata and controls
executable file
·155 lines (124 loc) · 3.91 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
function installDependencies
{
printHeader 'INSTALL DEPENDENCIES'
apt-get update
apt-get -y upgrade
apt-get -y install apache2
apt-get -y install erlang-os-mon
apt-get -y install erlang-snmp
apt-get -y install libapache2-mod-python
apt-get -y install libapache2-mod-wsgi
apt-get -y install memcached
apt-get -y install python-cairo-dev
apt-get -y install python-dev
apt-get -y install python-django
apt-get -y install python-ldap
apt-get -y install python-memcache
apt-get -y install python-pip
apt-get -y install python-pysqlite2
apt-get -y install rabbitmq-server
apt-get -y install sqlite3
apt-get -y install expect
pip install django-tagging
}
function installGraphite
{
printHeader 'INSTALL GRAPHITE'
pip install carbon
pip install graphite-web
pip install whisper
pip install Twisted==11.1.0
}
function configApache
{
printHeader 'CONFIG APACHE'
local oldWSGISocketPrefix="$(escapeSearchPattern 'WSGISocketPrefix run/wsgi')"
local newWSGISocketPrefix="$(escapeSearchPattern 'WSGISocketPrefix /var/run/apache2/wsgi')"
sed "s@${oldWSGISocketPrefix}@${newWSGISocketPrefix}@g" '/opt/graphite/examples/example-graphite-vhost.conf' > '/etc/apache2/sites-available/default'
}
function configGraphite
{
printHeader 'CONFIG GRAPHITE'
mv '/opt/graphite/conf/carbon.conf.example' '/opt/graphite/conf/carbon.conf'
mv '/opt/graphite/conf/storage-schemas.conf.example' '/opt/graphite/conf/storage-schemas.conf'
mv '/opt/graphite/conf/graphite.wsgi.example' '/opt/graphite/conf/graphite.wsgi'
cd '/opt/graphite/webapp/graphite'
python manage.py syncdb --noinput
python manage.py createsuperuser --username="${1}" --email="${3}" --noinput
expect << DONE
spawn python manage.py changepassword "${1}"
expect "Password: "
send -- "${2}\r"
expect "Password (again): "
send -- "${2}\r"
expect eof
DONE
mv '/opt/graphite/webapp/graphite/local_settings.py.example' '/opt/graphite/webapp/graphite/local_settings.py'
chown -R www-data:www-data '/opt/graphite/storage'
}
function restartServers
{
printHeader 'RESTART SERVERS'
"${appPath}/bin/restart"
}
function displayUsage
{
local scriptName="$(basename ${0})"
echo -e "\033[1;35m"
echo "SYNOPSIS :"
echo -e " ${scriptName} -h -l <LOGIN> -p <PASSWORD> -e <EMAIL>\n"
echo "DESCRIPTION :"
echo " -h Help page"
echo " -l Graphite Browser admin-user's login (require)"
echo " -p Graphite Browser admin-user's password (require)"
echo " -e Graphite Browser admin-user's email (require)"
echo -e "\033[1;36m"
echo "EXAMPLES :"
echo " ${scriptName} -h"
echo " ${scriptName} -l 'root' -p 'root' -e 'root@localhost.com'"
echo -e "\033[0m"
exit 1
}
function main
{
appPath="$(cd "$(dirname "${0}")" && pwd)"
source "${appPath}/lib/util.bash" || exit 1
while getopts ':hl:p:e:' option
do
case "${option}" in
h)
displayUsage
;;
l)
local login="${OPTARG}"
;;
p)
local password="${OPTARG}"
;;
e)
local email="${OPTARG}"
;;
*)
;;
esac
done
OPTIND=1
if [[ "$(isEmptyString ${login})" = 'true' || "$(isEmptyString ${password})" = 'true' || "$(isEmptyString ${email})" = 'true' ]]
then
error 'ERROR: login, password, or email not found!'
displayUsage
fi
if [[ "$(isValidEmail ${email})" = 'false' ]]
then
error 'ERROR: invalid email!'
exit 1
fi
checkRequireRootUser
installDependencies
installGraphite
configApache
configGraphite "${login}" "${password}" "${email}"
restartServers
}
main "${@}"