forked from globocom/GloboNetworkAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant_provision.sh
55 lines (46 loc) · 1.78 KB
/
vagrant_provision.sh
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
#!/bin/bash
apt-get install vim -y
apt-get install memcached -y
apt-get install python-pip -y
apt-get install libmysqlclient-dev -y
apt-get install python-dev -y
apt-get install libldap2-dev libsasl2-dev libssl-dev -y
# RabbitMQ
apt-get install rabbitmq-server -y
rabbitmq-plugins enable rabbitmq_management
rabbitmq-server restart &
rabbitmqctl add_user networkapi networkapi
rabbitmqctl add_vhost tasks
rabbitmqctl add_user tasks tasks
rabbitmqctl change_password networkapi networkapi
rabbitmqctl change_password tasks tasks
rabbitmqctl set_user_tags networkapi administrator
rabbitmqctl set_permissions -p / networkapi ".*" ".*" ".*"
rabbitmqctl set_permissions -p tasks networkapi ".*" ".*" ".*"
rabbitmqctl set_permissions -p tasks tasks ".*" ".*" ".*"
pip install gunicorn
pip install virtualenv virtualenvwrapper
echo -e "PYTHONPATH=\"/vagrant/networkapi:/vagrant/$PYTHONPATH\"" >> /etc/environment
cat > /etc/init.d/gunicorn_networkapi <<- EOM
#!/bin/bash
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
/usr/local/bin/gunicorn -c /vagrant/gunicorn.conf.py wsgi:application
EOM
chmod 777 /etc/init.d/gunicorn_networkapi
update-rc.d gunicorn_networkapi defaults
export PYTHONPATH="/vagrant/networkapi:/vagrant/$PYTHONPATH"
cd /vagrant/
./start_networkapi.sh
source networkapi_venv/bin/activate
mysql -u root -h localhost -e 'drop database if exists networkapi;'
mysql -u root -h localhost -e 'create database networkapi;'
cd /vagrant/dbmigrate; db-migrate --show-sql
mysql -u root -h localhost networkapi < /vagrant/dev/load_example_environment.sql