Install Pandora in a less ugly way
- Don't customize manage.py - Use pip -e instead of manual call - Fix deprecation warning
This commit is contained in:
parent
4b8079bae7
commit
929f1afd69
@ -24,7 +24,7 @@ cp ${SOURCE_DIR}/pandora/srv/pandora/static/oxjs/source/UI/json/locale.cs.json /
|
||||
|
||||
# Create Python virtualenv
|
||||
virtualenv --system-site-packages -p /usr/bin/python3 /srv/pandora
|
||||
cd /srv/pandora/src/oxtimelines && /srv/pandora/bin/python setup.py develop
|
||||
/srv/pandora/bin/pip install -e /srv/pandora/src/oxtimelines
|
||||
/srv/pandora/bin/pip install -r /srv/pandora/requirements.txt
|
||||
|
||||
# Create PostgreSQL user and database
|
||||
@ -62,9 +62,10 @@ sudo -u pandora /srv/pandora/pandora/manage.py init_db
|
||||
export PANDORA_ADMIN_USER=admin
|
||||
export PANDORA_ADMIN_EMAIL=admin@example.com
|
||||
export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
||||
cp ${SOURCE_DIR}/pandora/srv/pandora/pandora/user/management/commands/createadmin.py /srv/pandora/pandora/user/management/commands/createadmin.py
|
||||
sudo -u pandora /srv/pandora/pandora/manage.py createadmin --username "${PANDORA_ADMIN_USER}" --email "${PANDORA_ADMIN_EMAIL}" --password "${PANDORA_ADMIN_PWD}"
|
||||
rm -f /srv/pandora/pandora/user/management/commands/createadmin.py
|
||||
export PANDORA_ADMIN_HASH=$(cd /srv/pandora && DJANGO_SETTINGS_MODULE=pandora.settings /srv/pandora/bin/python -c "from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))")
|
||||
envsubst <${SOURCE_DIR}/pandora/tmp/pandora-adminpwd.sql >/tmp/pandora-adminpwd.sql
|
||||
sudo -u postgres psql -f /tmp/pandora-adminpwd.sql pandora
|
||||
rm -f /tmp/pandora-adminpwd.sql
|
||||
|
||||
# Create nginx site definition
|
||||
cp ${SOURCE_DIR}/pandora/etc/nginx/sites-available/pandora /etc/nginx/sites-available/pandora
|
||||
|
@ -13,5 +13,4 @@ XACCELREDIRECT = True
|
||||
GOOGLE_API_KEY = 'AIzaSyBvIF3D550tlpL6o1xRrDurGo-81VhHlOw'
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
JSON_DEBUG = DEBUG
|
||||
|
@ -1,17 +0,0 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import DEFAULT_DB_ALIAS
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--username', help='Specifies the login for the superuser.')
|
||||
parser.add_argument('--email', help='Specifies the email for the superuser.')
|
||||
parser.add_argument('--password', help='Specifies the password for the superuser.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
user_data = {
|
||||
'username': options['username'],
|
||||
'email': options['email'],
|
||||
'password': options['password']
|
||||
}
|
||||
get_user_model()._default_manager.db_manager(DEFAULT_DB_ALIAS).create_superuser(**user_data)
|
3
pandora/tmp/pandora-adminpwd.sql
Normal file
3
pandora/tmp/pandora-adminpwd.sql
Normal file
@ -0,0 +1,3 @@
|
||||
INSERT INTO auth_user (id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined) VALUES (nextval('auth_user_id_seq'), '${PANDORA_ADMIN_HASH}', NULL, true, '${PANDORA_ADMIN_USER}', '', '', '${PANDORA_ADMIN_EMAIL}', true, true, now());
|
||||
INSERT INTO user_userprofile (id, reset_code, level, files_updated, newsletter, ui, preferences, notes, user_id) VALUES
|
||||
(nextval('user_userprofile_id_seq'), NULL, 3, now(), true, '{}', '{}', '', 1);
|
Loading…
Reference in New Issue
Block a user