OpenSlides/server/docker/entrypoint-dev

44 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
set -e
function isSettingsFileOk() {
# Forbidden keys to set
# - OPENSLIDES_USER_DATA_DIR
# - SESSION_ENGINE
if grep -q "OPENSLIDES_USER_DATA_DIR.*=" /app/personal_data/var/settings.py; then
echo "Found forbidden key OPENSLIDES_USER_DATA_DIR"
return 1;
fi
if grep -q "SESSION_ENGINE.*=" /app/personal_data/var/settings.py; then
echo "Found forbidden key SESSION_ENGINE"
return 1;
fi
return 0;
}
/app/docker/wait-for-dev-dependencies.sh
if [[ ! -f "/app/personal_data/var/settings.py" ]]; then
echo "Create settings"
python manage.py createsettings
else
echo "Settings exists - checking for invalid configurations"
if ! isSettingsFileOk; then
echo "Settings are not ok."
echo "Saving old settings in settings.py.bak"
mv /app/personal_data/var/settings.py /app/personal_data/var/settings.py.bak
python manage.py createsettings
else
echo "Settings are ok."
fi
fi
sed -i -e "s/SECRET_KEY.*$/SECRET_KEY = 'development'/" /app/personal_data/var/settings.py
python -u manage.py migrate
exec "$@"