Commit fed87ce272b4fc01b5482d5fb74108be3db77b4e

Authored by André Araújo
1 parent 85bc0ddf
Exists in master

Fix Makefile

Showing 1 changed file with 63 additions and 58 deletions   Show diff stats
@@ -3,9 +3,14 @@ PROJECT_DIR = $(CURDIR) @@ -3,9 +3,14 @@ PROJECT_DIR = $(CURDIR)
3 SED_REPLACE_ALL = sed -i "s/$(1)/$(2)/g" "$(3)" 3 SED_REPLACE_ALL = sed -i "s/$(1)/$(2)/g" "$(3)"
4 SED_REPLACE_ALL_PATH = sed -i "s\#$(1)\#$(2)\#g" "$(3)" 4 SED_REPLACE_ALL_PATH = sed -i "s\#$(1)\#$(2)\#g" "$(3)"
5 5
  6 +VLIBRAS_NAME ?= vlibras-wiki
  7 +VLIBRAS_WIKILIBRAS_ENV := /etc/profile.d/${VLIBRAS_NAME}_env.sh
  8 +
  9 +-include "${VLIBRAS_WIKILIBRAS_ENV}"
  10 +
6 ifndef LOCALHOST 11 ifndef LOCALHOST
7 ifndef NETWORK_INTERFACE 12 ifndef NETWORK_INTERFACE
8 - NETWORK_INTERFACE := $(shell ip route | awk '{print $$5; exit}') 13 + NETWORK_INTERFACE := $(shell ip route | grep "default" | awk '{print $$5; exit}')
9 endif 14 endif
10 ifdef NETWORK_INTERFACE 15 ifdef NETWORK_INTERFACE
11 LOCALHOST := $(shell ip addr list ${NETWORK_INTERFACE} | grep "inet " | cut -d ' ' -f6 | cut -d/ -f1) 16 LOCALHOST := $(shell ip addr list ${NETWORK_INTERFACE} | grep "inet " | cut -d ' ' -f6 | cut -d/ -f1)
@@ -13,63 +18,68 @@ ifndef LOCALHOST @@ -13,63 +18,68 @@ ifndef LOCALHOST
13 endif 18 endif
14 19
15 ifndef LOCALHOST 20 ifndef LOCALHOST
16 - LOCALHOST := localhost 21 + LOCALHOST := 127.0.0.1
17 endif 22 endif
18 23
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 - ) 24 +install: uninstall install-dep config build
28 25
29 config: 26 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) 27 + @ cp ./alembic.ini.template ./alembic.ini
  28 + @ cp ./settings_local.py.tmpl ./settings_local.py
  29 + @ cp ./contrib/pybossa.wsgi.tmpl ./contrib/pybossa.wsgi
  30 + @ cp ./contrib/apache/pybossa.conf.tmpl ./contrib/apache/pybossa.conf
  31 + @ cp ./contrib/pybossa.ini.template ./contrib/pybossa.ini
54 @ cp ./contrib/supervisor/rq-scheduler.conf.template ./contrib/supervisor/rq-scheduler.conf 32 @ 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) 33 + @ cp ./contrib/supervisor/rq-worker.conf.template ./contrib/supervisor/rq-worker.conf
  34 + @ cp ./contrib/supervisor/pybossa.conf.template ./contrib/supervisor/pybossa.conf
  35 + @ ln -sf ./pybossa/themes/default/translations/ ./pybossa/translations
  36 + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,$(CURDIR),./contrib/pybossa.wsgi)
  37 + @ $(call SED_REPLACE_ALL,ServerName localhost,ServerName ${LOCALHOST},./contrib/apache/pybossa.conf)
  38 + @ $(call SED_REPLACE_ALL,user1,$$USER,./contrib/apache/pybossa.conf)
  39 + @ $(call SED_REPLACE_ALL,group1,$$USER,./contrib/apache/pybossa.conf)
  40 + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,$(CURDIR),./contrib/apache/pybossa.conf)
  41 + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,$(CURDIR),./contrib/pybossa.ini)
  42 + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,$(CURDIR),./contrib/supervisor/rq-scheduler.conf)
56 @ $(call SED_REPLACE_ALL,user=pybossa,user=$$USER,./contrib/supervisor/rq-scheduler.conf) 43 @ $(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) 44 + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,$(CURDIR),./contrib/supervisor/rq-worker.conf)
59 @ $(call SED_REPLACE_ALL,user=pybossa,user=$$USER,./contrib/supervisor/rq-worker.conf) 45 @ $(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) 46 + @ $(call SED_REPLACE_ALL_PATH,/home/pybossa/pybossa,$(CURDIR),./contrib/supervisor/pybossa.conf)
62 @ $(call SED_REPLACE_ALL_PATH,pybossa.ini,contrib/pybossa.ini,./contrib/supervisor/pybossa.conf) 47 @ $(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) 48 @ $(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 49 + @ sudo install -m 755 -p ./contrib/apache/pybossa.conf /etc/apache2/sites-available/pybossa.conf
  50 + @ sudo install -m 644 -p ./contrib/redis-supervisor/redis.conf /etc/redis/redis.conf
  51 + @ sudo install -m 644 -p ./contrib/redis-supervisor/sentinel.conf /etc/redis/sentinel.conf
  52 + @ sudo install -m 644 -p ./contrib/supervisor/pybossa.conf /etc/supervisor/conf.d/pybossa.conf
  53 + @ sudo install -m 644 -p ./contrib/supervisor/redis-sentinel.conf /etc/supervisor/conf.d/redis-sentinel.conf
  54 + @ sudo install -m 644 -p ./contrib/supervisor/redis-server.conf /etc/supervisor/conf.d/redis-server.conf
  55 + @ sudo install -m 644 -p ./contrib/supervisor/rq-scheduler.conf /etc/supervisor/conf.d/rq-scheduler.conf
  56 + @ sudo install -m 644 -p ./contrib/supervisor/rq-worker.conf /etc/supervisor/conf.d/rq-worker.conf
71 @ sudo chown redis:redis /etc/redis/redis.conf 57 @ sudo chown redis:redis /etc/redis/redis.conf
72 @ sudo chown redis:redis /etc/redis/sentinel.conf 58 @ sudo chown redis:redis /etc/redis/sentinel.conf
  59 + @ [ -e /etc/apache2/sites-enabled/vlibras-wiki.conf ] || sudo a2ensite pybossa.conf
  60 + @ sudo service redis-server stop
  61 + @ sudo update-rc.d -f redis-server remove
  62 + -@ sudo killall redis-server
  63 + @ # sudo rm -f /etc/apache2/sites-available/vlibras-wiki.conf /etc/apache2/sites-enabled/vlibras-wiki.conf
  64 +
  65 +env:
  66 + @ ( \
  67 + virtualenv ./env/; \
  68 + . ./env/bin/activate; \
  69 + pip install -U pip; \
  70 + pip install -U uwsgi; \
  71 + pip install -U ndg-httpsclient; \
  72 + pip install -r requirements.txt; \
  73 + )
  74 +
  75 +build: env
  76 + -@ sudo service postgresql restart > /dev/null
  77 + -@ $(MAKE) -s drop-db > /dev/null
  78 + -@ $(MAKE) -s create-db > /dev/null
  79 + @( \
  80 + . ./env/bin/activate; \
  81 + python cli.py db_create; \
  82 + )
73 @ while ! sudo service supervisor restart; do echo "fail, retrying ..."; done 83 @ while ! sudo service supervisor restart; do echo "fail, retrying ..."; done
74 @ sudo supervisorctl restart rq-scheduler 84 @ sudo supervisorctl restart rq-scheduler
75 @ sudo supervisorctl restart rq-worker 85 @ sudo supervisorctl restart rq-worker
@@ -126,20 +136,15 @@ install-dep: @@ -126,20 +136,15 @@ install-dep:
126 @ sudo a2enmod headers 136 @ sudo a2enmod headers
127 -@ sudo a2dissite 000-default.conf 137 -@ sudo a2dissite 000-default.conf
128 138
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}\"; 139 +PYBOSSA_DB_USERNAME := pybossa
  140 +PYBOSSA_DB_PASSWORD := tester
  141 +PYBOSSA_DB_CREATE := psql -c \"CREATE USER pybossa WITH PASSWORD '${PYBOSSA_DB_PASSWORD}'\";
  142 +PYBOSSA_DB_CREATE += psql -c \"CREATE DATABASE pybossa OWNER ${PYBOSSA_DB_USERNAME}\";
  143 +PYBOSSA_DB_DROP := psql -c \"DROP DATABASE ${PYBOSSA_DB_USERNAME}\";
  144 +PYBOSSA_DB_DROP += psql -c \"DROP USER ${PYBOSSA_DB_USERNAME}\";
136 145
137 create-db: 146 create-db:
138 @ sudo su postgres -c "${PYBOSSA_DB_CREATE}" 147 @ sudo su postgres -c "${PYBOSSA_DB_CREATE}"
139 - @( \  
140 - . ./env/bin/activate; \  
141 - python cli.py db_create; \  
142 - )  
143 148
144 drop-db: 149 drop-db:
145 @ sudo su postgres -c "${PYBOSSA_DB_DROP}" 150 @ sudo su postgres -c "${PYBOSSA_DB_DROP}"