Browse Source

Set nounset on Bash scripts (fixes #860)

pull/1760/head
Alexander Kurakin 2 years ago
parent
commit
81dcf4197d
11 changed files with 47 additions and 4 deletions
  1. 2
      tools/azure.sh
  2. 5
      tools/create-admin.sh
  3. 4
      tools/create-package.sh
  4. 2
      tools/dev-celery.sh
  5. 9
      tools/dev-django.sh
  6. 1
      tools/dev-nuxt.sh
  7. 6
      tools/heroku.sh
  8. 3
      tools/install-mssql.sh
  9. 2
      tools/prod-celery.sh
  10. 8
      tools/prod-django.sh
  11. 9
      tools/run.sh

2
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 [[ -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 if ! az account show >/dev/null; then echo "Must be logged into Azure" >&2; exit 2; fi
set -o nounset
az group create \ az group create \
--location "${DOCCANO_LOCATION}" \ --location "${DOCCANO_LOCATION}" \
--name "${DOCCANO_RESOURCE_GROUP}" --name "${DOCCANO_RESOURCE_GROUP}"

5
tools/create-admin.sh

@ -1,8 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [[ "$#" -ne 3 ]]; then echo "Usage: $0 <username> <email> <password>" >&2; exit 1; fi
set -o errexit set -o errexit
set -o nounset
if [[ "$#" -ne 3 ]]; then echo "Usage: $0 <username> <email> <password>" >&2; exit 1; fi
python app/manage.py wait_for_db python app/manage.py wait_for_db
python app/manage.py migrate python app/manage.py migrate

4
tools/create-package.sh

@ -1,4 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit
set -o nounset
mkdir -p backend/client mkdir -p backend/client
cd frontend cd frontend

2
tools/dev-celery.sh

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit set -o errexit
set -o nounset
cd "/src/backend" cd "/src/backend"

9
tools/dev-django.sh

@ -1,6 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit 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" app="/src/backend"
echo "Initializing database" echo "Initializing database"
@ -18,4 +25,4 @@ if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMI
fi fi
echo "Starting django" 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}

1
tools/dev-nuxt.sh

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit set -o errexit
set -o nounset
root="$(dirname "$0")/.." root="$(dirname "$0")/.."
app="${root}/frontend" app="${root}/frontend"

6
tools/heroku.sh

@ -2,6 +2,12 @@
set -o errexit 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 python /doccano/backend/manage.py migrate
if [ -n "$ADMIN_USER_NAME" ]; then 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" python /doccano/backend/manage.py create_admin --noinput --username="$ADMIN_USER_NAME" --email="$ADMIN_CONTACT_EMAIL" --password="$ADMIN_PASSWORD"

3
tools/install-mssql.sh

@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit
set -o nounset
# parse arguments # parse arguments
mode="prod" mode="prod"
for opt in "$@"; do for opt in "$@"; do

2
tools/prod-celery.sh

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit set -o errexit
set -o nounset
cd /backend cd /backend

8
tools/prod-django.sh

@ -2,6 +2,12 @@
set -o errexit 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" echo "Making staticfiles"
static_dir=staticfiles static_dir=staticfiles
if [[ ! -d $static_dir ]] || [[ -z $(ls -A $static_dir) ]]; then if [[ ! -d $static_dir ]] || [[ -z $(ls -A $static_dir) ]]; then
@ -25,4 +31,4 @@ if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMI
fi fi
echo "Starting django" 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

9
tools/run.sh

@ -2,6 +2,15 @@
set -o errexit 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" echo "Making staticfiles"
static_dir=staticfiles static_dir=staticfiles
mkdir -p client/dist/static mkdir -p client/dist/static

Loading…
Cancel
Save