2020-05-28 11:40:41 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2021-02-04 17:57:01 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-05-28 11:40:41 +02:00
|
|
|
wait-for-it -t 0 redis:6379
|
|
|
|
|
2021-01-20 09:10:23 +01:00
|
|
|
until pg_isready -h postgres -p 5432 -U openslides; do
|
2021-02-04 17:57:01 +01:00
|
|
|
echo "Waiting for Postgres to become available..."
|
|
|
|
sleep 3
|
2021-01-20 09:10:23 +01:00
|
|
|
done
|
|
|
|
|
2020-05-28 11:40:41 +02:00
|
|
|
if [[ ! -f "/app/personal_data/var/settings.py" ]]; then
|
|
|
|
echo "Create settings"
|
|
|
|
python manage.py createsettings
|
2021-02-04 17:57:01 +01:00
|
|
|
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
|
2020-05-28 11:40:41 +02:00
|
|
|
fi
|
|
|
|
|
2021-02-04 17:57:01 +01:00
|
|
|
sed -i -e "s/SECRET_KEY.*$/SECRET_KEY = 'development'/" /app/personal_data/var/settings.py
|
|
|
|
|
2020-05-28 11:40:41 +02:00
|
|
|
python -u manage.py migrate
|
|
|
|
|
|
|
|
exec "$@"
|