37 lines
1 KiB
Bash
37 lines
1 KiB
Bash
#!/bin/sh
|
|
|
|
_django_settings() {
|
|
# Returns the value of a Django settings.
|
|
echo $(python3 -c "
|
|
import ${DJANGO_SETTINGS_MODULE} as settings
|
|
print(settings.${1})")
|
|
}
|
|
|
|
|
|
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-gestioCOF.settings.dev}
|
|
# Tests that module exists
|
|
python3 -c "import ${DJANGO_SETTINGS_MODULE}"
|
|
|
|
echo "Django settings module: ${DJANGO_SETTINGS_MODULE}"
|
|
|
|
DBHOST=$(_django_settings DATABASES[\'default\'][\'HOST\'])
|
|
DBNAME=$(_django_settings DATABASES[\'default\'][\'NAME\'])
|
|
DBUSER=$(_django_settings DATABASES[\'default\'][\'USER\'])
|
|
DBPASSWORD=$(_django_settings DATABASES[\'default\'][\'PASSWORD\'])
|
|
|
|
_psql() {
|
|
PGPASSWORD=${DBPASSWORD} psql -h ${DBHOST} -d ${DBNAME} -U ${DBUSER} "$@"
|
|
}
|
|
|
|
echo "Database: ${DBNAME}"
|
|
|
|
SERVICE_DIR=${SERVICES_DIR:-/etc/systemd/system}
|
|
SERVICE_DAPHNE=${SERVICE_DIR}/${SERVICE_DAPHNE_FILENAME}
|
|
SERVICE_WORKER=${SERVICE_DIR}/${SERVICE_WORKER_FILENAME}
|
|
|
|
[ -e ${SERVICE_DAPHNE} ] || exit 1
|
|
[ -e ${SERVICE_WORKER} ] || exit 1
|
|
|
|
echo "Services:"
|
|
echo " - Daphne: ${SERVICE_DAPHNE}"
|
|
echo " - Worker: ${SERVICE_WORKER}"
|