diff --git a/tools/azure.sh b/tools/azure.sh index d08a19e9..b661b590 100755 --- a/tools/azure.sh +++ b/tools/azure.sh @@ -11,6 +11,8 @@ if [[ -z "${DOCCANO_ADMIN_CONTACT_EMAIL}" ]]; then echo "Missing DOCCANO_ADMIN_C if [[ -z "${DOCCANO_ADMIN_PASSWORD}" ]]; then echo "Missing DOCCANO_ADMIN_PASSWORD environment variable" >&2; exit 1; fi if ! az account show >/dev/null; then echo "Must be logged into Azure" >&2; exit 2; fi +set -o nounset + az group create \ --location "${DOCCANO_LOCATION}" \ --name "${DOCCANO_RESOURCE_GROUP}" diff --git a/tools/create-admin.sh b/tools/create-admin.sh index d17e4ddd..72d76622 100755 --- a/tools/create-admin.sh +++ b/tools/create-admin.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash -if [[ "$#" -ne 3 ]]; then echo "Usage: $0 " >&2; exit 1; fi - set -o errexit +set -o nounset + +if [[ "$#" -ne 3 ]]; then echo "Usage: $0 " >&2; exit 1; fi python app/manage.py wait_for_db python app/manage.py migrate diff --git a/tools/create-package.sh b/tools/create-package.sh index e9896c8a..99b5e96f 100755 --- a/tools/create-package.sh +++ b/tools/create-package.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash + +set -o errexit +set -o nounset + mkdir -p backend/client cd frontend diff --git a/tools/dev-celery.sh b/tools/dev-celery.sh index ec4e61e5..0c60a90c 100755 --- a/tools/dev-celery.sh +++ b/tools/dev-celery.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash + set -o errexit +set -o nounset cd "/src/backend" diff --git a/tools/dev-django.sh b/tools/dev-django.sh index de8d16c2..bbb5b9ea 100755 --- a/tools/dev-django.sh +++ b/tools/dev-django.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash + set -o errexit +if [[ -z "${ADMIN_USERNAME}" ]]; then echo "Missing ADMIN_USERNAME environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_PASSWORD}" ]]; then echo "Missing ADMIN_PASSWORD environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_EMAIL}" ]]; then echo "Missing ADMIN_EMAIL environment variable" >&2; exit 1; fi + +set -o nounset + app="/src/backend" echo "Initializing database" @@ -18,4 +25,4 @@ if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMI fi echo "Starting django" -python -u "${app}/manage.py" runserver 0.0.0.0:8000 +python -u "${app}/manage.py" runserver ${HOST:-0.0.0.0}:${PORT:-8000} diff --git a/tools/dev-nuxt.sh b/tools/dev-nuxt.sh index 772bb16b..36c38d62 100755 --- a/tools/dev-nuxt.sh +++ b/tools/dev-nuxt.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -o errexit +set -o nounset root="$(dirname "$0")/.." app="${root}/frontend" diff --git a/tools/heroku.sh b/tools/heroku.sh index 07443663..f6252026 100644 --- a/tools/heroku.sh +++ b/tools/heroku.sh @@ -2,6 +2,12 @@ set -o errexit +if [[ -z "${ADMIN_USER_NAME}" ]]; then echo "Missing ADMIN_USER_NAME environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_PASSWORD}" ]]; then echo "Missing ADMIN_PASSWORD environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_CONTACT_EMAIL}" ]]; then echo "Missing ADMIN_CONTACT_EMAIL environment variable" >&2; exit 1; fi + +set -o nounset + python /doccano/backend/manage.py migrate if [ -n "$ADMIN_USER_NAME" ]; then python /doccano/backend/manage.py create_admin --noinput --username="$ADMIN_USER_NAME" --email="$ADMIN_CONTACT_EMAIL" --password="$ADMIN_PASSWORD" diff --git a/tools/install-mssql.sh b/tools/install-mssql.sh index 358ad44b..c7b9d794 100755 --- a/tools/install-mssql.sh +++ b/tools/install-mssql.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +set -o errexit +set -o nounset + # parse arguments mode="prod" for opt in "$@"; do diff --git a/tools/prod-celery.sh b/tools/prod-celery.sh index 73c4971f..0ffba164 100755 --- a/tools/prod-celery.sh +++ b/tools/prod-celery.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash + set -o errexit +set -o nounset cd /backend diff --git a/tools/prod-django.sh b/tools/prod-django.sh index 7c38b719..976075ea 100755 --- a/tools/prod-django.sh +++ b/tools/prod-django.sh @@ -2,6 +2,12 @@ set -o errexit +if [[ -z "${ADMIN_USERNAME}" ]]; then echo "Missing ADMIN_USERNAME environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_PASSWORD}" ]]; then echo "Missing ADMIN_PASSWORD environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_EMAIL}" ]]; then echo "Missing ADMIN_EMAIL environment variable" >&2; exit 1; fi + +set -o nounset + echo "Making staticfiles" static_dir=staticfiles if [[ ! -d $static_dir ]] || [[ -z $(ls -A $static_dir) ]]; then @@ -25,4 +31,4 @@ if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMI fi echo "Starting django" -gunicorn --bind="0.0.0.0:${PORT:-8000}" --workers="${WORKERS:-4}" config.wsgi --timeout 300 +gunicorn --bind="${HOST:-0.0.0.0}:${PORT:-8000}" --workers="${WORKERS:-4}" config.wsgi --timeout 300 diff --git a/tools/run.sh b/tools/run.sh index 84eb4cbe..5a008a02 100755 --- a/tools/run.sh +++ b/tools/run.sh @@ -2,6 +2,15 @@ set -o errexit +if [[ -z "${ADMIN_USERNAME}" ]]; then echo "Missing ADMIN_USERNAME environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_PASSWORD}" ]]; then echo "Missing ADMIN_PASSWORD environment variable" >&2; exit 1; fi +if [[ -z "${ADMIN_EMAIL}" ]]; then echo "Missing ADMIN_EMAIL environment variable" >&2; exit 1; fi +if [[ -z "${PORT}" ]]; then echo "Missing PORT environment variable" >&2; exit 1; fi +if [[ -z "${WORKERS}" ]]; then echo "Missing WORKERS environment variable" >&2; exit 1; fi +if [[ -z "${CELERY_WORKERS}" ]]; then echo "Missing CELERY_WORKERS environment variable" >&2; exit 1; fi + +set -o nounset + echo "Making staticfiles" static_dir=staticfiles mkdir -p client/dist/static