taiga/launch

85 lines
3.4 KiB
Plaintext
Raw Normal View History

2016-04-10 17:21:26 +00:00
#!/bin/bash
# Debug
# set -x
# Do Not Change these variables unless you know what you are doing
export ESC=$
export DJANGO_SECRET_KEY=$(openssl rand -hex 32)
# Default variables. These shall be overridden :-)
export GUNICORN_WORKERS=${GUNICORN_WORKERS:-1}
export SITE_URI=${SITE_URI:-http://example.com}
export SITE_FQDN=$(echo $SITE_URI | sed -e "s/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/")
2017-09-08 16:58:23 +00:00
[[ "${SITE_URI::5}" == "https" ]] && SITE_SCHEME="https" || SITE_SCHEME="http"
2016-04-10 17:21:26 +00:00
export SITE_SCHEME
2017-09-08 16:58:23 +00:00
[[ ${PUBLIC_REGISTER,,} == "false" ]] \
2016-04-10 17:21:26 +00:00
&& { PUBLIC_REGISTER="False"; PUBLIC_REGISTER_JS="false"; } \
|| { PUBLIC_REGISTER="True"; PUBLIC_REGISTER_JS="true"; }
export PUBLIC_REGISTER PUBLIC_REGISTER_JS
export ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com}
export NOREPLY_EMAIL=${NOREPLY_EMAIL:-no-reply@example.com}
export TAIGA_DB_HOST=${TAIGA_DB_HOST:-postgres}
export TAIGA_DB_PORT=${TAIGA_DB_PORT:-5432}
export TAIGA_DB_NAME=${TAIGA_DB_NAME:-taiga}
export TAIGA_DB_USER=${TAIGA_DB_USER:-taiga}
export TAIGA_DB_PASSWORD=${TAIGA_DB_PASSWORD:-mysecretpassword}
export EMAIL_HOST=${EMAIL_HOST:-localhost}
export EMAIL_HOST_USER=${EMAIL_HOST_USER:-}
export EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD:-}
export EMAIL_HOST_PORT=${EMAIL_HOST_PORT:-587}
export EMAIL_USE_TLS=${EMAIL_USE_TLS:-False}
export EMAIL_BACKEND=${EMAIL_BACKEND:-django.core.mail.backends.smtp.EmailBackend}
2016-04-10 17:21:26 +00:00
# Generate configs based on the template seeds
envsubst < /tmp/taiga.tmpl > /etc/nginx/sites-enabled/taiga
envsubst < /tmp/circus.ini.tmpl > $DATA/circus.ini
envsubst < /tmp/conf.json.tmpl > $DATA/taiga-front-dist/dist/conf.json
envsubst < /tmp/local.py.tmpl > $DATA/taiga-back/settings/local.py
envsubst < /tmp/already_initialized.tmpl > /already_initialized
chmod +x /already_initialized
2016-04-10 17:21:26 +00:00
# Keep sensitive information out of here
unset DJANGO_SECRET_KEY TAIGA_DB_PASSWORD
2016-05-20 16:12:19 +00:00
# Make sure the dynamic data is writable by the circus/gunicorn
2017-09-08 16:58:23 +00:00
chown -Rh $USER:$GROUP $DATA/media $DATA/static $DATA/taiga-back/taiga/locale $DATA/logs
2016-04-10 17:21:26 +00:00
# Make sure the PostgreSQL database is up and ready
while ! timeout 1 bash -c 'cat < /dev/null > /dev/tcp/$TAIGA_DB_HOST/$TAIGA_DB_PORT' >/dev/null 2>&1; do
echo "Waiting for $TAIGA_DB_HOST:$TAIGA_DB_PORT to be Ready ..."
sleep 1
done
# This will make a tiny delay which will help to ensure the database is up and
# running before it will be seeded/updated
/already_initialized
2016-04-10 17:21:26 +00:00
2017-06-27 21:27:00 +00:00
# TODO: in case if /already_initialized fails, the bad things will happen, like the default: admin:123123 ... need to make this more robust.
2016-04-10 17:21:26 +00:00
# Upgrade DB schemas, etc...
# This is important when Taiga's codebase gets updated
2017-06-27 21:27:00 +00:00
su -s /bin/bash $USER -c 'source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
workon venvtaiga
2016-04-10 17:21:26 +00:00
cd $DATA/taiga-back
2016-04-11 08:38:01 +00:00
python manage.py migrate --noinput
/already_initialized || ( python manage.py loaddata initial_user \
&& python manage.py loaddata initial_project_templates \
&& python manage.py loaddata initial_role \
&& echo "First run: A new user admin with password 123123 has been created. Please change the password once you login." )
2016-04-11 08:38:01 +00:00
python manage.py compilemessages
python manage.py collectstatic --noinput
2016-04-10 17:21:26 +00:00
deactivate'
2016-04-11 08:41:44 +00:00
# (Optional) Fill Taiga with the Sample data
2016-04-10 17:21:26 +00:00
# su -s /bin/sh $USER -c '. $DATA/venvtaiga/bin/activate
# cd $DATA/taiga-back
2016-04-11 08:38:01 +00:00
# python manage.py sample_data
2016-04-10 17:21:26 +00:00
# deactivate'
# Launch the backend
service nginx start
su -s /bin/sh $USER -c '/usr/local/bin/circusd "$DATA/circus.ini"'