Files
pyShelf/configure
th3r00t 68d453edc8 Phased out nginx in favor of running django under daphne with asgi.
Adjusted the docker image in favor of this, & fixed urls.py which was
missing the static request responder.
2020-09-11 16:50:17 -04:00

45 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import sys
import json
from pathlib import Path
from django.core.management.utils import get_random_secret_key
from src.backend.lib.pyShelf import Admin
def load_config():
with open('config.json',"r") as file:
config = json.load(file)
file.close()
return config
def write_config(config):
with open('config.json',"w") as file:
json.dump(config, file)
file.close()
def set_secret(config=load_config()):
if config["SECRET"] == "":
config["SECRET"] = get_random_secret_key()
write_config(config)
print(config["SECRET"])
else:
print("Secret already set, skipping.")
def init_django_database():
cmds = [
'python3 manage.py makemigrations',
'python3 manage.py makemigrations interface',
'python3 manage.py migrate',
'python3 manage.py migrate interface',
]
os.chdir("src")
for cmd in cmds:
os.system(cmd)
os.chdir("../")
set_secret()
init_django_database()
Admin(Path.cwd()).createsuperuser()