Refactoring & consistency changes
Make all scripts executable Disable debug mode by default Use eager tasks by default Fix typo in settings Refactoring
This commit is contained in:
@@ -14,7 +14,7 @@ from core.models import User
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Performs sanity checks on the Shynet setup"
|
||||
help = "Internal command to perform startup sanity checks."
|
||||
|
||||
def check_migrations(self):
|
||||
from django.db.migrations.executor import MigrationExecutor
|
||||
@@ -1,44 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Check if Setup is necessary, do setup as needed
|
||||
sanity_results=( $(python manage.py sanity_checks) )
|
||||
if [[ ${sanity_results[0]} == True ]]; then
|
||||
echo "Running Migrations..."
|
||||
{
|
||||
python manage.py migrate && echo "Migrations Done"
|
||||
} || {
|
||||
echo "Failed Migrations, exiting" && exit 1
|
||||
}
|
||||
else
|
||||
echo "Migrations Unecessary, skipping"
|
||||
fi
|
||||
if [[ ${sanity_results[1]} == True ]]; then
|
||||
echo "Running CreateAdmin..."
|
||||
{
|
||||
temppwd=$( python manage.py registeradmin $SHYNET_EMAIL ) && echo "Admin Created, password $temppwd"
|
||||
} || {
|
||||
echo "Failed CreateAdmin, exiting" & exit 1
|
||||
}
|
||||
else
|
||||
echo "CreateAdmin Unecessary, skipping"
|
||||
fi
|
||||
if [[ ${sanity_results[2]} == True ]]; then
|
||||
echo "Setting Hostname..."
|
||||
{
|
||||
python manage.py hostname $SHYNET_HOST && echo "Host Set"
|
||||
} || {
|
||||
echo "Failed setting Hostname, exiting" & exit 1
|
||||
}
|
||||
else
|
||||
echo "Hostname Unecessary, skipping"
|
||||
fi
|
||||
if [[ ${sanity_results[3]} == True ]]; then
|
||||
echo "Setting Hostname..."
|
||||
{
|
||||
python manage.py whitelabel $SHYNET_NAME && echo "WhiteLabel Set"
|
||||
} || {
|
||||
echo "Failed Migrations, exiting" & exit 1
|
||||
}
|
||||
else
|
||||
echo "WhiteLabel Unecessary, skipping"
|
||||
|
||||
if [[ $PERFORM_CHECKS_AND_SETUP == True ]]; then
|
||||
./startup_checks.sh
|
||||
fi
|
||||
|
||||
./webserver.sh
|
||||
|
||||
@@ -27,7 +27,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "onlyusethisindev")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = os.getenv("DEBUG", "True") == "True"
|
||||
DEBUG = os.getenv("DEBUG", "False") == "True"
|
||||
|
||||
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "*").split(",")
|
||||
|
||||
@@ -214,7 +214,7 @@ SITE_ID = 1
|
||||
|
||||
# Celery
|
||||
|
||||
CELERY_TASK_ALWAYS_EAGER = os.getenv("CELERY_TASK_ALWAYS_EAGER", "False") == "True"
|
||||
CELERY_TASK_ALWAYS_EAGER = os.getenv("CELERY_TASK_ALWAYS_EAGER", "True") == "True"
|
||||
|
||||
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL")
|
||||
CELERY_REDIS_SOCKET_TIMEOUT = 15
|
||||
|
||||
0
shynet/ssl.webserver.sh
Normal file → Executable file
0
shynet/ssl.webserver.sh
Normal file → Executable file
45
shynet/startup_checks.sh
Executable file
45
shynet/startup_checks.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Check if setup is necessary, do setup as needed
|
||||
echo "Performing startup checks..."
|
||||
sanity_results=( $(./manage.py startup_checks) )
|
||||
if [[ ${sanity_results[0]} == True ]]; then
|
||||
echo "Running migrations (setting up DB)..."
|
||||
{
|
||||
./manage.py migrate && echo "Migrations complete!"
|
||||
} || {
|
||||
echo "Migrations failed, exiting" && exit 1
|
||||
}
|
||||
else
|
||||
echo "Database is ready to go."
|
||||
fi
|
||||
if [[ -n $SHYNET_ADMIN_EMAIL && ${sanity_results[1]} == True ]]; then
|
||||
echo "Creating an admin user..."
|
||||
{
|
||||
temppwd=$( ./manage.py registeradmin $SHYNET_ADMIN_EMAIL ) && echo "Admin user ($SHYNET_ADMIN_EMAIL) created! Password: $temppwd"
|
||||
} || {
|
||||
echo "Failed to create admin, exiting" & exit 1
|
||||
}
|
||||
else
|
||||
echo "Making no changes to admin user."
|
||||
fi
|
||||
if [[ -n $SHYNET_HOST && ${sanity_results[2]} == True ]]; then
|
||||
echo "Setting hostname..."
|
||||
{
|
||||
./manage.py hostname $SHYNET_HOST && echo "Hostname set to $SHYNET_HOST!"
|
||||
} || {
|
||||
echo "Failed setting hostname, exiting" & exit 1
|
||||
}
|
||||
else
|
||||
echo "Making no changes to hostname."
|
||||
fi
|
||||
if [[ -n $SHYNET_WHITELABEL && ${sanity_results[3]} == True ]]; then
|
||||
echo "Setting whitelabel..."
|
||||
{
|
||||
./manage.py whitelabel $SHYNET_WHITELABEL && echo "Whitelabel set! Whitelabel: $SHYNET_WHITELABEL"
|
||||
} || {
|
||||
echo "Failed to set whitelabel, exiting" & exit 1
|
||||
}
|
||||
else
|
||||
echo "Making no changes to whitelabel."
|
||||
fi
|
||||
echo "Startup checks complete!"
|
||||
Reference in New Issue
Block a user