mirror of
https://github.com/Screenly/Anthias.git
synced 2025-12-23 22:38:05 -05:00
38 lines
1.1 KiB
Bash
Executable File
38 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
ENVIRONMENT=${ENVIRONMENT:-production}
|
|
|
|
mkdir -p \
|
|
/data/.config \
|
|
/data/.screenly \
|
|
/data/.screenly/backups \
|
|
/data/screenly_assets
|
|
|
|
cp -n /usr/src/app/ansible/roles/screenly/files/screenly.conf /data/.screenly/screenly.conf
|
|
cp -n /usr/src/app/ansible/roles/screenly/files/default_assets.yml /data/.screenly/default_assets.yml
|
|
|
|
echo "Running migration..."
|
|
|
|
# The following block ensures that the migration is transactional and that the
|
|
# database is not left in an inconsistent state if the migration fails.
|
|
|
|
if [ -f /data/.screenly/screenly.db ]; then
|
|
./manage.py dbbackup --noinput --clean && \
|
|
./manage.py migrate --fake-initial --noinput || \
|
|
./manage.py dbrestore --noinput
|
|
else
|
|
./manage.py migrate && \
|
|
./manage.py dbbackup --noinput --clean
|
|
fi
|
|
|
|
if [[ "$ENVIRONMENT" == "development" ]]; then
|
|
echo "Starting Django development server..."
|
|
npm install && npm run build
|
|
./manage.py runserver 0.0.0.0:8080
|
|
else
|
|
echo "Generating Django static files..."
|
|
./manage.py collectstatic --clear --noinput
|
|
echo "Starting Gunicorn..."
|
|
python run_gunicorn.py
|
|
fi
|