From b3a42ff78c66694b3ed46bf183bc20c2dd7f07c3 Mon Sep 17 00:00:00 2001 From: eribeiro Date: Mon, 30 Mar 2020 13:30:49 -0300 Subject: [PATCH] Refatora scripts bash --- busy-wait.sh | 2 +- check_solr.sh | 2 +- docker-env.sh | 2 +- gunicorn_start.sh | 2 +- release.sh | 2 +- sapl/legacy/run_legacy_tests.sh | 2 +- sapl/legacy/scripts/migra_dbs.sh | 2 +- sapl/legacy/scripts/migra_um_db.sh | 2 +- sapl/legacy/scripts/recria_dbs_postgres.sh | 2 +- sapl/legacy/scripts/recria_um_db_postgres.sh | 2 ++ sapl/legacy/scripts/shell_para_migracao.sh | 2 +- scripts/atualizar_producao.sh | 2 +- scripts/create_admin_user.sh | 2 +- scripts/django/check_migrations.sh | 2 +- scripts/django/check_qa.sh | 2 +- scripts/django/fix_qa.sh | 2 +- scripts/django/gerar_grafico_apps.sh | 2 +- scripts/django/reset_all_migrations.sh | 2 +- scripts/django/test_and_check_qa.sh | 2 +- scripts/hooks/instalar_hooks_git.sh | 2 +- scripts_docker/remove-all-containers.sh | 2 +- scripts_docker/remove-db.sh | 2 +- scripts_docker/restore-db.sh | 3 ++- scripts_docker/shell_sapl.sh | 2 +- simple_gunicorn.sh | 2 ++ start.sh | 2 +- 26 files changed, 29 insertions(+), 24 deletions(-) diff --git a/busy-wait.sh b/busy-wait.sh index 73fde5c6b..ed07a4262 100644 --- a/busy-wait.sh +++ b/busy-wait.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash while true; do COUNT_PG=`psql $1 -c '\l \q' | grep sapl | wc -l` diff --git a/check_solr.sh b/check_solr.sh index c600466bb..370b4adcf 100644 --- a/check_solr.sh +++ b/check_solr.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Pass the base SOLR URL as parameter, i.e., bash check_solr http://localhost:8983 diff --git a/docker-env.sh b/docker-env.sh index 07528b0f1..a14cff6ee 100644 --- a/docker-env.sh +++ b/docker-env.sh @@ -1,4 +1,4 @@ -#/bin/bash +#!/usr/bin/env bash KEY=`python gen-key.py` echo $KEY diff --git a/gunicorn_start.sh b/gunicorn_start.sh index 862221a29..019ccaaed 100755 --- a/gunicorn_start.sh +++ b/gunicorn_start.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # As seen in http://tutos.readthedocs.org/en/latest/source/ndg.html diff --git a/release.sh b/release.sh index b99dbf05c..0be28cb1a 100755 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## ## Versioning info: [major].[minor].[patch][-RC[num]], example: 3.1.159, 3.1.159-RC1 diff --git a/sapl/legacy/run_legacy_tests.sh b/sapl/legacy/run_legacy_tests.sh index da8a79410..6b7491e81 100755 --- a/sapl/legacy/run_legacy_tests.sh +++ b/sapl/legacy/run_legacy_tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # All tests under this directory are excluded in default pytest.ini # To run them use this script in this directory diff --git a/sapl/legacy/scripts/migra_dbs.sh b/sapl/legacy/scripts/migra_dbs.sh index 3620da089..891263d40 100755 --- a/sapl/legacy/scripts/migra_dbs.sh +++ b/sapl/legacy/scripts/migra_dbs.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # rodar esse script na raiz do projeto diff --git a/sapl/legacy/scripts/migra_um_db.sh b/sapl/legacy/scripts/migra_um_db.sh index 613fd0a4d..20556ae18 100755 --- a/sapl/legacy/scripts/migra_um_db.sh +++ b/sapl/legacy/scripts/migra_um_db.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # rodar esse script na raiz do projeto if [ $# -eq 1 ]; then diff --git a/sapl/legacy/scripts/recria_dbs_postgres.sh b/sapl/legacy/scripts/recria_dbs_postgres.sh index 450a306b4..a5eab1ed7 100755 --- a/sapl/legacy/scripts/recria_dbs_postgres.sh +++ b/sapl/legacy/scripts/recria_dbs_postgres.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # (Re)cria todos os bancos postgres para migração # cria um banco postgres (de mesmo nome) para cada banco mysql cujo nome começa com "sapl_" diff --git a/sapl/legacy/scripts/recria_um_db_postgres.sh b/sapl/legacy/scripts/recria_um_db_postgres.sh index 48b3d8adf..a98056f13 100755 --- a/sapl/legacy/scripts/recria_um_db_postgres.sh +++ b/sapl/legacy/scripts/recria_um_db_postgres.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # (Re)cria um db postgres # uso: recria_um_db_postgres diff --git a/sapl/legacy/scripts/shell_para_migracao.sh b/sapl/legacy/scripts/shell_para_migracao.sh index fb0f3c6de..e7272d7ea 100755 --- a/sapl/legacy/scripts/shell_para_migracao.sh +++ b/sapl/legacy/scripts/shell_para_migracao.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Inicia um shell_plus com as configurações de migração usando um banco específico # Uso: ./shell_para_migracao.sh diff --git a/scripts/atualizar_producao.sh b/scripts/atualizar_producao.sh index 6649d3078..1534d9c77 100755 --- a/scripts/atualizar_producao.sh +++ b/scripts/atualizar_producao.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash git pull --rebase workon sapl pip install -r requirements/dev-requirements.txt diff --git a/scripts/create_admin_user.sh b/scripts/create_admin_user.sh index e7e5c64cc..a9457b11c 100755 --- a/scripts/create_admin_user.sh +++ b/scripts/create_admin_user.sh @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell --plain diff --git a/scripts/django/check_migrations.sh b/scripts/django/check_migrations.sh index dc78641cd..42be681da 100755 --- a/scripts/django/check_migrations.sh +++ b/scripts/django/check_migrations.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # a verificação de migrations pendentes deve passar diff --git a/scripts/django/check_qa.sh b/scripts/django/check_qa.sh index a145bee7a..acb89a190 100755 --- a/scripts/django/check_qa.sh +++ b/scripts/django/check_qa.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Verifica se um breakpoint foi esquecido no código me=`basename "$0"` diff --git a/scripts/django/fix_qa.sh b/scripts/django/fix_qa.sh index cb0f24001..43790b1a7 100755 --- a/scripts/django/fix_qa.sh +++ b/scripts/django/fix_qa.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # QA fix: Use ese script para corrigir automaticamente vários # problemas de estilo e boas práticas no código. diff --git a/scripts/django/gerar_grafico_apps.sh b/scripts/django/gerar_grafico_apps.sh index ab6bf9a84..6578f6e08 100755 --- a/scripts/django/gerar_grafico_apps.sh +++ b/scripts/django/gerar_grafico_apps.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash git_project_root=$(git rev-parse --show-toplevel) cd ${git_project_root} diff --git a/scripts/django/reset_all_migrations.sh b/scripts/django/reset_all_migrations.sh index d3f2cfbe4..ce8e0a50f 100755 --- a/scripts/django/reset_all_migrations.sh +++ b/scripts/django/reset_all_migrations.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Sends all django migrations to the trash bin # Requires trash-cli. To install: diff --git a/scripts/django/test_and_check_qa.sh b/scripts/django/test_and_check_qa.sh index 024139bba..37599bb19 100755 --- a/scripts/django/test_and_check_qa.sh +++ b/scripts/django/test_and_check_qa.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # QA checks: run this before every commit diff --git a/scripts/hooks/instalar_hooks_git.sh b/scripts/hooks/instalar_hooks_git.sh index 4c276b069..755bdc63c 100755 --- a/scripts/hooks/instalar_hooks_git.sh +++ b/scripts/hooks/instalar_hooks_git.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ln -s -f `pwd`/scripts/hooks/pre-commit .git/hooks/pre-commit diff --git a/scripts_docker/remove-all-containers.sh b/scripts_docker/remove-all-containers.sh index a3d8fc624..aca1baa10 100755 --- a/scripts_docker/remove-all-containers.sh +++ b/scripts_docker/remove-all-containers.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash sudo docker stop $(docker ps -a -q) # Para containers sudo docker rm $(sudo docker ps -a -q) # Remove containers sudo docker rmi -f $( sudo docker images -q ) # Remove imagens diff --git a/scripts_docker/remove-db.sh b/scripts_docker/remove-db.sh index c911bc2a7..d61aa4c5a 100755 --- a/scripts_docker/remove-db.sh +++ b/scripts_docker/remove-db.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash sudo docker stop sapl_localhost_1 sudo docker rm sapl_localhost_1 sudo docker rmi -f postgres diff --git a/scripts_docker/restore-db.sh b/scripts_docker/restore-db.sh index 8a40a2296..8ace338ed 100755 --- a/scripts_docker/restore-db.sh +++ b/scripts_docker/restore-db.sh @@ -1,2 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash + sudo pg_restore --disable-triggers --data-only sapl_30-03-16.tar | docker exec -i sapl_localhost_1 psql -U sapl diff --git a/scripts_docker/shell_sapl.sh b/scripts_docker/shell_sapl.sh index 4c993a61d..7ac9d488a 100755 --- a/scripts_docker/shell_sapl.sh +++ b/scripts_docker/shell_sapl.sh @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash docker run --rm -ti sapl_web /bin/sh diff --git a/simple_gunicorn.sh b/simple_gunicorn.sh index 970e67a04..977d44288 100755 --- a/simple_gunicorn.sh +++ b/simple_gunicorn.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + DJANGODIR=/var/interlegis/sapl # Django project directory (*) DJANGO_SETTINGS_MODULE=sapl.settings # which settings file should Django use (*) DJANGO_WSGI_MODULE=sapl.wsgi # WSGI module name (*) diff --git a/start.sh b/start.sh index bea1eb959..cec16f6c7 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash create_env() { echo "[ENV FILE] creating .env file..."