From efddadb89892d84f60b43c5d53c55e8fa4d3f439 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 5 Jan 2019 13:13:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .travis.yml | 6 +----- init_db.sh | 19 +++++++++++++++++++ oj/dev_settings.py | 4 ++-- 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100755 init_db.sh diff --git a/.gitignore b/.gitignore index d4b59810..8b3b73ff 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ data/config/* http_locations.conf https_locations.conf +venv/ diff --git a/.travis.yml b/.travis.yml index 9edf0294..ac84fa0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,11 @@ language: python python: - "3.6" services: - - redis-server - docker -before_install: - - docker pull postgres:10 - - docker run -it -d -e POSTGRES_DB=onlinejudge -e POSTGRES_USER=onlinejudge -e POSTGRES_PASSWORD=onlinejudge -p 127.0.0.1:5433:5432 postgres:10 install: - pip install -r deploy/requirements.txt - echo `cat /dev/urandom | head -1 | md5sum | head -c 32` > data/config/secret.key - - sleep 10 && python manage.py migrate + - ./init_db.sh script: - docker ps -a - flake8 . diff --git a/init_db.sh b/init_db.sh new file mode 100755 index 00000000..6fc29b06 --- /dev/null +++ b/init_db.sh @@ -0,0 +1,19 @@ +#! /bin/bash +set -x + +if [[ ! -f manage.py ]]; then + echo "No manage.py, wrong location" + exit 1 +fi + +sleep 2 +docker rm -f oj-postgres-dev oj-redis-dev +docker run -it -d -e POSTGRES_DB=onlinejudge -e POSTGRES_USER=onlinejudge -e POSTGRES_PASSWORD=onlinejudge -p 127.0.0.1:5435:5432 --name oj-postgres-dev postgres:10 +docker run -it -d -p 127.0.0.1:6380:6379 --name oj-redis-dev redis:4.0-alpine + +if [ "$1" = "--migrate" ]; then + sleep 3 + echo `cat /dev/urandom | head -1 | md5sum | head -c 32` > data/config/secret.key + python manage.py migrate + python manage.py inituser --username root --password rootroot --action create_super_admin +fi \ No newline at end of file diff --git a/oj/dev_settings.py b/oj/dev_settings.py index 5c75a0b2..4736c69f 100644 --- a/oj/dev_settings.py +++ b/oj/dev_settings.py @@ -7,7 +7,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'HOST': '127.0.0.1', - 'PORT': 5433, + 'PORT': 5435, 'NAME': "onlinejudge", 'USER': "onlinejudge", 'PASSWORD': 'onlinejudge' @@ -16,7 +16,7 @@ DATABASES = { REDIS_CONF = { "host": "127.0.0.1", - "port": "6379" + "port": "6380" }