Skip to content
Snippets Groups Projects
entrypoint.sh 1.22 KiB
Newer Older
ynerant's avatar
ynerant committed
#!/bin/sh
ynerant's avatar
ynerant committed
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
me5na7qbjqbrp's avatar
me5na7qbjqbrp committed
# SPDX-License-Identifier: GPL-3.0-or-later

if [ -z ${NOTE_URL+x} ]; then
  echo "Warning: your env files are not configurated."
else
ynerant's avatar
ynerant committed
  sed -i -e "s/example.com/$NOTE_URL/g" /var/www/note_kfet/apps/member/fixtures/initial.json
  sed -i -e "s/localhost/$NOTE_URL/g" /var/www/note_kfet/note_kfet/fixtures/initial.json
  sed -i -e "s/\"\.\*\"/\"https?:\/\/$NOTE_URL\/.*\"/g" /var/www/note_kfet/note_kfet/fixtures/cas.json
  sed -i -e "s/REPLACEME/La Note Kfet \\\\ud83c\\\\udf7b/g" /var/www/note_kfet/note_kfet/fixtures/cas.json
me5na7qbjqbrp's avatar
me5na7qbjqbrp committed
# Set up Django project
python3 manage.py collectstatic --noinput
python3 manage.py compilemessages
python3 manage.py compilejsmessages
me5na7qbjqbrp's avatar
me5na7qbjqbrp committed
python3 manage.py migrate
ynerant's avatar
ynerant committed

me5na7qbjqbrp's avatar
me5na7qbjqbrp committed
if [ "$1" ]; then
    # Command passed
    echo "Running $@..."
    $@
ynerant's avatar
ynerant committed
else
me5na7qbjqbrp's avatar
me5na7qbjqbrp committed
    # Launch server
    if [ "$DJANGO_APP_STAGE" = "prod" ]; then
        uwsgi --http-socket 0.0.0.0:8080 --master --plugins python3 \
              --module note_kfet.wsgi:application --env DJANGO_SETTINGS_MODULE=note_kfet.settings \
              --processes 4 --static-map /static=/var/www/note_kfet/static --harakiri=20 --max-requests=5000 --vacuum
me5na7qbjqbrp's avatar
me5na7qbjqbrp committed
    else
        python3 manage.py runserver 0.0.0.0:8080;
    fi
ynerant's avatar
ynerant committed
fi