Commit 021d32f0835024fe8308ff1e7a140f0d8924ebae

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

Adiciona script com usuário padrão

Showing 2 changed files with 67 additions and 79 deletions   Show diff stats
Makefile
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   -VLIBRAS_NAME ?= vlibras-wiki
7   -VLIBRAS_WIKILIBRAS_ENV := /etc/profile.d/${VLIBRAS_NAME}_env.sh
8   -
9   --include "${VLIBRAS_WIKILIBRAS_ENV}"
10   -
11   -ifndef LOCALHOST
12   - ifndef NETWORK_INTERFACE
13   - NETWORK_INTERFACE := $(shell ip route | grep "default" | awk '{print $$5; exit}')
14   - endif
15   - ifdef NETWORK_INTERFACE
16   - LOCALHOST := $(shell ip addr list ${NETWORK_INTERFACE} | grep "inet " | cut -d ' ' -f6 | cut -d/ -f1)
  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 IP
  7 + ifneq ($(shell ip route | grep "default" | awk '{print $$5; exit}'),)
  8 + IP := $(shell ip route get 1 | awk '{print $$7; exit}')
  9 + else
  10 + IP := 127.0.0.1
17 11 endif
18 12 endif
19 13  
20   -ifndef LOCALHOST
21   - LOCALHOST := 127.0.0.1
22   -endif
  14 +LOCALHOST ?= ${IP}
  15 +
  16 +install: .install config build
  17 +
  18 +build: env create-db
  19 + @ sudo chown redis:redis /etc/redis/redis.conf
  20 + @ sudo chown redis:redis /etc/redis/sentinel.conf
  21 + @ sudo service redis-server stop
  22 + @ sudo update-rc.d -f redis-server remove
  23 + @ while ! sudo service supervisor restart; do echo "fail, retrying ..."; done
  24 + @ sudo supervisorctl restart rq-scheduler
  25 + @ sudo supervisorctl restart rq-worker
  26 + @ sudo supervisorctl restart pybossa
23 27  
24   -install: uninstall install-dep config build
  28 +clean:
  29 + @ find . -regextype posix-awk -regex "(.*.log|.*.pyc)" -type f -print -delete
25 30  
26 31 config:
27 32 @ cp ./alembic.ini.template ./alembic.ini
... ... @@ -54,55 +59,21 @@ config:
54 59 @ sudo install -m 644 -p ./contrib/supervisor/redis-server.conf /etc/supervisor/conf.d/redis-server.conf
55 60 @ sudo install -m 644 -p ./contrib/supervisor/rq-scheduler.conf /etc/supervisor/conf.d/rq-scheduler.conf
56 61 @ sudo install -m 644 -p ./contrib/supervisor/rq-worker.conf /etc/supervisor/conf.d/rq-worker.conf
57   - @ sudo chown redis:redis /etc/redis/redis.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
  62 + @ cat /etc/apache2/sites-available/pybossa.conf
  63 + @ ([ -e /etc/apache2/sites-enabled/wikilibras.conf ] && sudo a2dissite wikilibras.conf) || sudo a2ensite pybossa.conf
  64 + @ sudo service apache2 restart
  65 + @ sudo service apache2 reload
64 66  
65 67 env:
66 68 @ ( \
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   - )
83   - @ while ! sudo service supervisor restart; do echo "fail, retrying ..."; done
84   - @ sudo supervisorctl restart rq-scheduler
85   - @ sudo supervisorctl restart rq-worker
86   - @ sudo supervisorctl restart pybossa
87   - @ sudo service apache2 restart
88   - @ sudo service apache2 reload
89   - @ echo "\33[32;1mYou must create an account to administer the site then copy your API key\\33[0m"
90   - @ $(MAKE) -s api-key
91   -
92   -api-key:
93   - @( \
94   - echo -n "\33[34;1mInput your API key from pybossa account: \33[0m"; \
95   - unset APIKEY; \
96   - read APIKEY; \
97   - sed -i "/^export PYBOSSA_API_KEY=/d" ~/.bashrc ; \
98   - sed -i "\$$aexport PYBOSSA_API_KEY=\"$$APIKEY\"" ~/.bashrc; \
99   - echo "\33[33;1mtype: \33[32;1mexport PYBOSSA_API_KEY=\"$$APIKEY\"\\33[0m"; \
100   - echo "\33[33;1mtype: \33[32;1msource ~/.bashrc\\33[0m"; \
101   - echo "\33[33;1mor open a new terminal\\33[0m"; \
  69 + virtualenv ./env/; \
  70 + . ./env/bin/activate; \
  71 + pip install -U pip; \
  72 + pip install -U uwsgi; \
  73 + pip install -U ndg-httpsclient; \
  74 + pip install -r requirements.txt; \
102 75 )
103 76  
104   -clean:
105   - @ find . -regextype posix-awk -regex "(.*.log|.*.pyc)" -type f -print -delete
106 77  
107 78 uninstall: clean
108 79 @ rm -rf ./env/
... ... @@ -114,15 +85,11 @@ uninstall: clean
114 85  
115 86 run:
116 87 @ ( \
117   - . ./env/bin/activate; \
118   - python main.py; \
  88 + . ./env/bin/activate; \
  89 + python main.py; \
119 90 )
120 91  
121   -uninstall-dep:
122   - @ sudo apt-get -y purge --auto-remove apache2 apache2-bin apache2-data apache2-utils supervisor redis-server && sudo apt-get -y autoremove
123   - @ sudo rm -rf "/etc/apache2" "/var/log/apache2" "/var/log/redis" "/var/log/supervisor"
124   -
125   -install-dep:
  92 +.install:
126 93 @ sudo apt-get update && \
127 94 sudo apt-get install -y git-core \
128 95 postgresql postgresql-server-dev-all libpq-dev python-psycopg2 \
... ... @@ -136,15 +103,31 @@ install-dep:
136 103 @ sudo a2enmod headers
137 104 -@ sudo a2dissite 000-default.conf
138 105  
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}\";
  106 +PYBOSSA_DB_USERNAME := pybossa
  107 +PYBOSSA_DB_PASSWORD := tester
  108 +PYBOSSA_DB_CREATE := psql -c \"CREATE USER pybossa WITH PASSWORD '${PYBOSSA_DB_PASSWORD}'\";
  109 +PYBOSSA_DB_CREATE += psql -c \"CREATE DATABASE pybossa OWNER ${PYBOSSA_DB_USERNAME}\";
  110 +PYBOSSA_DB_DROP := psql -c \"DROP DATABASE ${PYBOSSA_DB_USERNAME}\";
  111 +PYBOSSA_DB_DROP += psql -c \"DROP USER ${PYBOSSA_DB_USERNAME}\";
  112 +PYBOSSA_DB_DUMPFILE := pybossa-dump.sql
  113 +PYBOSSA_DB_VERBOSE := -v
  114 +PYBOSSA_DB_ADMINFILE := wikilibras-pybossa.sql
145 115  
146   -create-db:
  116 +.postgresql:
  117 + -@ sudo service postgresql restart
  118 +
  119 +create-db: .postgresql env
147 120 @ sudo su postgres -c "${PYBOSSA_DB_CREATE}"
  121 + @ ( \
  122 + . ./env/bin/activate; \
  123 + python cli.py db_create; \
  124 + )
148 125  
149   -drop-db:
  126 +create-admin:
  127 + @ sudo su postgres -c "psql --set ON_ERROR_STOP=off -f ${PYBOSSA_DB_ADMINFILE} ${PYBOSSA_DB_USERNAME}"
  128 +
  129 +drop-db: .postgresql
150 130 @ sudo su postgres -c "${PYBOSSA_DB_DROP}"
  131 +
  132 +${PYBOSSA_DB_DUMPFILE}:
  133 + @ sudo su postgres -c "PGPASSWORD='${PYBOSSA_DB_PASSWORD}' pg_dump ${PYBOSSA_DB_VERBOSE} -b --inserts ${PYBOSSA_DB_USERNAME};" > ${PYBOSSA_DB_DUMPFILE}
... ...
wikilibras-pybossa.sql 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +-- how to install:
  2 +-- sudo su postgres -c "psql --set ON_ERROR_STOP=off -f wikilibras-pybossa.sql pybossa"
  3 +
  4 +INSERT INTO "user" VALUES (1, '2017-01-01T00:00:00.000000', 'wikilibras@lavid.ufpb.br', 'wikilibras', 'wikilibras', 'pt_BR', '2324bc23-7d6f-4840-8905-b1e6c1675eed', 'pbkdf2:sha1:1000$wIP6vkOx$99be5c325961aa39030bb10e3b58a85ac3bfaa90', true, false, false, NULL, NULL, NULL, NULL, NULL, NULL, false, true, false, true, '{}', 1);
  5 +SELECT pg_catalog.setval('user_id_seq', 1, true);
... ...