Commit 244ff69c9f558ef65d35905f246f3183a0b12412
1 parent
eea5b9a5
Exists in
master
Adiciona Makefile, corrige template pybossa.conf
Showing
3 changed files
with
148 additions
and
7 deletions
Show diff stats
.gitignore
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | *.db |
12 | 12 | *.noseids |
13 | 13 | *.pem |
14 | +*.save | |
14 | 15 | *.sql |
15 | 16 | *.swl |
16 | 17 | *.swm |
... | ... | @@ -25,6 +26,7 @@ alembic.ini |
25 | 26 | pybossa.conf |
26 | 27 | pybossa.wsgi |
27 | 28 | settings_local.py |
29 | +rq-scheduler.conf | |
28 | 30 | rq-worker.conf |
29 | 31 | test/test_cache.py |
30 | 32 | contrib/nginx/pybossa |
... | ... | @@ -40,5 +42,6 @@ vagrant_env/ |
40 | 42 | .ropeproject/ |
41 | 43 | .vagrant/ |
42 | 44 | doc/_build |
45 | +pybossa/translations | |
43 | 46 | pybossa/themes/crowdcrafting-theme/ |
44 | 47 | pybossa/themes/pybossa-default-theme/ | ... | ... |
... | ... | @@ -0,0 +1,145 @@ |
1 | +PROJECT_NAME = pybossa | |
2 | +PROJECT_DIR = $(CURDIR) | |
3 | +SED_REPLACE_ALL = sed -i "s/$(1)/$(2)/g" "$(3)" | |
4 | +SED_REPLACE_ALL_PATH = sed -i "s\#$(1)\#$(2)\#g" "$(3)" | |
5 | + | |
6 | +ifndef LOCALHOST | |
7 | + ifndef NETWORK_INTERFACE | |
8 | + NETWORK_INTERFACE := $(shell ip route | awk '{print $$5; exit}') | |
9 | + endif | |
10 | + ifdef NETWORK_INTERFACE | |
11 | + LOCALHOST := $(shell ip addr list ${NETWORK_INTERFACE} | grep "inet " | cut -d ' ' -f6 | cut -d/ -f1) | |
12 | + endif | |
13 | +endif | |
14 | + | |
15 | +ifndef LOCALHOST | |
16 | + LOCALHOST := localhost | |
17 | +endif | |
18 | + | |
19 | +install: uninstall install-dep config | |
20 | + @( \ | |
21 | + virtualenv ./env/; \ | |
22 | + . ./env/bin/activate; \ | |
23 | + pip install -U pip; \ | |
24 | + pip install -U uwsgi; \ | |
25 | + pip install -U ndg-httpsclient; \ | |
26 | + pip install -r requirements.txt; \ | |
27 | + ) | |
28 | + | |
29 | +config: | |
30 | + @ rm -f ./pybossa/translations | |
31 | + @ ln -sf ./pybossa/themes/default/translations/ ./pybossa/translations | |
32 | + @ cp alembic.ini.template alembic.ini | |
33 | + @ sudo service postgresql restart > /dev/null | |
34 | + -@ $(MAKE) -s drop-db > /dev/null | |
35 | + @ $(MAKE) -s create-db | |
36 | + @ $(info Using interface: ${NETWORK_INTERFACE}) | |
37 | + @ $(info Using local IP: ${LOCALHOST}) | |
38 | + @ cp settings_local.py.tmpl settings_local.py | |
39 | + @ cp ./contrib/${PROJECT_NAME}.wsgi.tmpl ./contrib/${PROJECT_NAME}.wsgi | |
40 | + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,${PROJECT_DIR},./contrib/${PROJECT_NAME}.wsgi) | |
41 | + @ cp ./contrib/apache/${PROJECT_NAME}.conf.tmpl ./contrib/apache/${PROJECT_NAME}.conf | |
42 | + @ $(call SED_REPLACE_ALL,ServerName localhost,ServerName ${LOCALHOST},./contrib/apache/${PROJECT_NAME}.conf) | |
43 | + @ $(call SED_REPLACE_ALL,user1,$$USER,./contrib/apache/${PROJECT_NAME}.conf) | |
44 | + @ $(call SED_REPLACE_ALL,group1,$$USER,./contrib/apache/${PROJECT_NAME}.conf) | |
45 | + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,${PROJECT_DIR},./contrib/apache/${PROJECT_NAME}.conf) | |
46 | + @ sudo install -m 755 -p ./contrib/apache/${PROJECT_NAME}.conf /etc/apache2/sites-available/${PROJECT_NAME}.conf | |
47 | + @ sudo a2ensite ${PROJECT_NAME}.conf | |
48 | + @ sudo rm -f /etc/apache2/sites-available/vlibras-wiki.conf /etc/apache2/sites-enabled/vlibras-wiki.conf | |
49 | + @ sudo service redis-server stop | |
50 | + @ sudo update-rc.d -f redis-server remove | |
51 | + -@ sudo killall redis-server | |
52 | + @ cp ./contrib/pybossa.ini.template ./contrib/pybossa.ini | |
53 | + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,${PROJECT_DIR},./contrib/pybossa.ini) | |
54 | + @ cp ./contrib/supervisor/rq-scheduler.conf.template ./contrib/supervisor/rq-scheduler.conf | |
55 | + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,${PROJECT_DIR},./contrib/supervisor/rq-scheduler.conf) | |
56 | + @ $(call SED_REPLACE_ALL,user=pybossa,user=$$USER,./contrib/supervisor/rq-scheduler.conf) | |
57 | + @ cp ./contrib/supervisor/rq-worker.conf.template ./contrib/supervisor/rq-worker.conf | |
58 | + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,${PROJECT_DIR},./contrib/supervisor/rq-worker.conf) | |
59 | + @ $(call SED_REPLACE_ALL,user=pybossa,user=$$USER,./contrib/supervisor/rq-worker.conf) | |
60 | + @ cp ./contrib/supervisor/pybossa.conf.template ./contrib/supervisor/pybossa.conf | |
61 | + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,${PROJECT_DIR},./contrib/supervisor/pybossa.conf) | |
62 | + @ $(call SED_REPLACE_ALL_PATH,pybossa.ini,contrib/pybossa.ini,./contrib/supervisor/pybossa.conf) | |
63 | + @ $(call SED_REPLACE_ALL,user=pybossa,user=$$USER,./contrib/supervisor/pybossa.conf) | |
64 | + @ sudo cp ./contrib/supervisor/pybossa.conf /etc/supervisor/conf.d/pybossa.conf | |
65 | + @ sudo cp ./contrib/supervisor/redis-sentinel.conf /etc/supervisor/conf.d/redis-sentinel.conf | |
66 | + @ sudo cp ./contrib/supervisor/redis-server.conf /etc/supervisor/conf.d/redis-server.conf | |
67 | + @ sudo cp ./contrib/supervisor/rq-scheduler.conf /etc/supervisor/conf.d/rq-scheduler.conf | |
68 | + @ sudo cp ./contrib/supervisor/rq-worker.conf /etc/supervisor/conf.d/rq-worker.conf | |
69 | + @ sudo cp ./contrib/redis-supervisor/redis.conf /etc/redis/redis.conf | |
70 | + @ sudo cp ./contrib/redis-supervisor/sentinel.conf /etc/redis/sentinel.conf | |
71 | + @ sudo chown redis:redis /etc/redis/redis.conf | |
72 | + @ sudo chown redis:redis /etc/redis/sentinel.conf | |
73 | + @ while ! sudo service supervisor restart; do echo "fail, retrying ..."; done | |
74 | + @ sudo supervisorctl restart rq-scheduler | |
75 | + @ sudo supervisorctl restart rq-worker | |
76 | + @ sudo supervisorctl restart pybossa | |
77 | + @ sudo service apache2 restart | |
78 | + @ sudo service apache2 reload | |
79 | + @ echo "\33[32;1mYou must create an account to administer the site then copy your API key\\33[0m" | |
80 | + @ $(MAKE) -s api-key | |
81 | + | |
82 | +api-key: | |
83 | + @( \ | |
84 | + echo -n "\33[34;1mInput your API key from pybossa account: \33[0m"; \ | |
85 | + unset APIKEY; \ | |
86 | + read APIKEY; \ | |
87 | + sed -i "/^export PYBOSSA_API_KEY=/d" ~/.bashrc ; \ | |
88 | + sed -i "\$$aexport PYBOSSA_API_KEY=\"$$APIKEY\"" ~/.bashrc; \ | |
89 | + echo "\33[33;1mtype: \33[32;1mexport PYBOSSA_API_KEY=\"$$APIKEY\"\\33[0m"; \ | |
90 | + echo "\33[33;1mtype: \33[32;1msource ~/.bashrc\\33[0m"; \ | |
91 | + echo "\33[33;1mor open a new terminal\\33[0m"; \ | |
92 | + ) | |
93 | + | |
94 | +clean: | |
95 | + @ find . -regextype posix-awk -regex "(.*.log|.*.pyc)" -type f -print -delete | |
96 | + | |
97 | +uninstall: clean | |
98 | + @ rm -rf ./env/ | |
99 | + @ rm -f ./settings_local.py | |
100 | + @ rm -f ./contrib/${PROJECT_NAME}.wsgi | |
101 | + @ rm -f ./contrib/apache/${PROJECT_NAME}.conf | |
102 | + @ sudo rm -f /etc/apache2/sites-available/${PROJECT_NAME}.conf | |
103 | + @ sudo rm -f /etc/apache2/sites-enabled/${PROJECT_NAME}.conf | |
104 | + | |
105 | +run: | |
106 | + @ ( \ | |
107 | + . ./env/bin/activate; \ | |
108 | + python main.py; \ | |
109 | + ) | |
110 | + | |
111 | +uninstall-dep: | |
112 | + @ sudo apt-get -y purge --auto-remove apache2 apache2-bin apache2-data apache2-utils supervisor redis-server && sudo apt-get -y autoremove | |
113 | + @ sudo rm -rf "/etc/apache2" "/var/log/apache2" "/var/log/redis" "/var/log/supervisor" | |
114 | + | |
115 | +install-dep: | |
116 | + @ sudo apt-get update && \ | |
117 | + sudo apt-get install -y git-core \ | |
118 | + postgresql postgresql-server-dev-all libpq-dev python-psycopg2 \ | |
119 | + python-virtualenv \ | |
120 | + python-dev build-essential libjpeg-dev libssl-dev swig libffi-dev \ | |
121 | + redis-server \ | |
122 | + supervisor \ | |
123 | + apache2 apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-wsgi | |
124 | + @ echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf | |
125 | + @ sudo a2enconf servername | |
126 | + @ sudo a2enmod headers | |
127 | + -@ sudo a2dissite 000-default.conf | |
128 | + | |
129 | +PYBOSSA_DB_USERNAME = pybossa | |
130 | +PYBOSSA_DB_PASSWORD = tester | |
131 | +PYBOSSA_DB_PSQL = psql -c | |
132 | +PYBOSSA_DB_CREATE = ${PYBOSSA_DB_PSQL} \"CREATE USER pybossa WITH PASSWORD '${PYBOSSA_DB_PASSWORD}'\"; | |
133 | +PYBOSSA_DB_CREATE += ${PYBOSSA_DB_PSQL} \"CREATE DATABASE pybossa OWNER ${PYBOSSA_DB_USERNAME}\"; | |
134 | +PYBOSSA_DB_DROP = ${PYBOSSA_DB_PSQL} \"DROP DATABASE ${PYBOSSA_DB_USERNAME}\"; | |
135 | +PYBOSSA_DB_DROP += ${PYBOSSA_DB_PSQL} \"DROP USER ${PYBOSSA_DB_USERNAME}\"; | |
136 | + | |
137 | +create-db: | |
138 | + @ sudo su postgres -c "${PYBOSSA_DB_CREATE}" | |
139 | + @( \ | |
140 | + . ./env/bin/activate; \ | |
141 | + python cli.py db_create; \ | |
142 | + ) | |
143 | + | |
144 | +drop-db: | |
145 | + @ sudo su postgres -c "${PYBOSSA_DB_DROP}" | ... | ... |
contrib/apache/pybossa.conf.tmpl
... | ... | @@ -12,13 +12,6 @@ |
12 | 12 | Require all granted |
13 | 13 | </Directory> |
14 | 14 | |
15 | - Alias /pybossa <path-to-project>/view | |
16 | - <Directory <path-to-project>/view> | |
17 | - Order deny,allow | |
18 | - Allow from all | |
19 | - Require all granted | |
20 | - </Directory> | |
21 | - | |
22 | 15 | Header set Access-Control-Allow-Origin "*" |
23 | 16 | |
24 | 17 | ServerAdmin webmaster@localhost | ... | ... |