Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bonnegent Sebastien
ede
Commits
f351c09e
Commit
f351c09e
authored
Mar 01, 2022
by
Bonnegent Sebastien
Browse files
remplacement du script ./make par ./do.sh
parent
cf81aaa0
Pipeline
#14436
failed with stage
in 1 minute and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
conf/settings.py
View file @
f351c09e
...
...
@@ -143,9 +143,9 @@ ORACLE_DSN_BASE = ""
ORACLE_USER
=
"QUAL"
ORACLE_PASSWORD
=
""
# mail from
FROM
=
"noreply@insa-rouen.fr"
EMAIL_SUBJECT_PREFIX
=
"[EDE] "
# Message de relance
RELANCE
=
"""Bonjour,
...
...
do.sh
0 → 100755
View file @
f351c09e
#!/bin/bash
NORMAL
=
"
\0
33[0m"
GRAS
=
"
\0
33[1m"
RED
=
"
\0
33[31m"
GRE
=
"
\0
33[32m"
YEL
=
"
\0
33[33m"
BLU
=
"
\0
33[34m"
PUR
=
"
\0
33[35m"
CYA
=
"
\0
33[36m"
# container name
NAME
=
"ede"
function
my_help
{
cat
<<
'
EOF
'
Usage: ./make [a_command]
help : cette aide
Commandes pour le développement:
build : construction du container
smtp : lancement du faux serveur mail
migration : si besoin, créé les fichiers de migrations et le graph des modèles
sh : lancement de 'manage.py shell_plus' dans un container
start : lancement du container
test : lancement des tests, de pep8 et black pour le formatage
update_py : mise à jour des bibliothèques python
Commandes pour la production:
connexion_oracle: test la connexion vers la base Oracle et la présence des vues
import_oracle : importe les données d'oracle pour toutes les campagnes en attente
dump_questions : exporte seulement les questionnaires dans questionnaires.json
load_questions : charge les questionnaires par défaut
rapports : création des rapports
sh_prod : lancement de './manage.py shell_plus'
up_prod : mise à jour (git pull, pipenv install, migrate, collectstatic)
up_prod_imp : mise à jour importante (up_prod avec dump psql)
EOF
exit
1
}
function
must_succeed
{
# exec a command and return value
$*
if
[
!
$?
==
0
]
then
echo
-e
"
$RED
[erreur]
$*
$NORMAL
"
exit
42
fi
}
function
my_echo_warn
{
echo
-e
"
$YEL
>>
$*
$NORMAL
"
}
function
maj_pour_la_production
{
my_echo_warn
"git pull..."
git pull
my_echo_warn
"mise a jour du virtualenv..."
must_succeed pipenv
install
--ignore-pipfile
my_echo_warn
"collectstatic..."
pipenv run python3 ./manage.py collectstatic
--noinput
--no-post-process
my_echo_warn
"migrate..."
pipenv run python3 ./manage.py migrate
my_echo_warn
"django check deploy..."
pipenv run python3 ./manage.py check
--deploy
my_echo_warn
"restart de httpd"
systemctl restart httpd
}
if
[
!
$#
-eq
1
]
then
my_help
fi
case
"
$1
"
in
# pour le développement
test
)
my_echo_warn
"auto formatage du code..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
black
.
my_echo_warn
"django check..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py check
my_echo_warn
"pytest..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
pytest
--no-migrations
;;
migration
)
my_echo_warn
"recherche de migrations..."
must_succeed docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py makemigrations
my_echo_warn
"applications..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py migrate
my_echo_warn
"graphique des modèles..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py graph_models
-a
-o
graphs/complet.png
my_echo_warn
"git status..."
git status
;;
build
)
docker build
-t
$NAME
.
;;
start
)
docker run
-v
${
PWD
}
:/code
-p
8000:8000
-it
$NAME
python3 ./manage.py runserver
--trace
0.0.0.0:8000
;;
sh
)
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py shell_plus
;;
smtp
)
my_echo_warn
"> start smtp server (ctrl-c to stop) ..."
docker run
-v
${
PWD
}
:/code
-p
2525:2525
-it
$NAME
python3
-m
smtpd
-n
-c
DebuggingServer 0.0.0.0:2525
# docker run -v ${PWD}:/code -p 2525:2525 -it $NAME python3 ./manage.py mail_debug --use-settings
;;
update_py
)
docker run
-v
${
PWD
}
:/code
-it
$NAME
pipenv update
;;
# pour la production
dump_questions
)
my_echo_warn
"dump des questions..."
must_succeed pipenv run python3 ./manage.py dumpdata
\
--format
=
json
--indent
=
4 ede.Question ede.Theme
\
ede.Questionnaire
>
ede/fixtures/questionnaires.json
;;
sh_prod
)
pipenv run python3 ./manage.py shell_plus
;;
up_prod
)
maj_pour_la_production
;;
up_prod_imp
)
# echo "- arrêt de httpd"
# systemctl stop httpd
my_echo_warn
"sauvegarde des données avec pg_dumpall..."
if
[
!
-e
/var/lib/pgsql/backups/
]
then
mkdir
-p
/var/lib/pgsql/backups/
chown
postgres /var/lib/pgsql/backups/
fi
su postgres
-c
"pg_dumpall > /var/lib/pgsql/backups/dumpall_
$(
date
+%y%m%d
)
.sql"
maj_pour_la_production
;;
load_questions
)
pipenv run python3 ./manage.py loaddata questionnaires.json
;;
import_oracle
)
pipenv run python3 ./manage.py import_oracle
;;
rapports
)
pipenv run python3 ./manage.py fin_de_campagne
;;
connexion_oracle
)
pipenv run python3 ./manage.py test_connexion_oracle
;;
*
)
my_help
;;
esac
make
100755 → 100644
View file @
f351c09e
#!/bin/bash
NORMAL
=
"
\0
33[0m"
GRAS
=
"
\0
33[1m"
RED
=
"
\0
33[31m"
GRE
=
"
\0
33[32m"
YEL
=
"
\0
33[33m"
BLU
=
"
\0
33[34m"
PUR
=
"
\0
33[35m"
CYA
=
"
\0
33[36m"
# container name
NAME
=
"ede"
function
my_help
{
cat
<<
'
EOF
'
Usage: ./make [a_command]
help : cette aide
Commandes pour le développement:
build : construction du container
smtp : lancement du faux serveur mail
migration : si besoin, créé les fichiers de migrations et le graph des modèles
sh : lancement de 'manage.py shell_plus' dans un container
start : lancement du container
test : lancement des tests, de pep8 et black pour le formatage
update_py : mise à jour des bibliothèques python
Commandes pour la production:
connexion_oracle: test la connexion vers la base Oracle et la présence des vues
import_oracle : importe les données d'oracle pour toutes les campagnes en attente
dump_questions : exporte seulement les questionnaires dans questionnaires.json
load_questions : charge les questionnaires par défaut
rapports : création des rapports
sh_prod : lancement de './manage.py shell_plus'
up_prod : mise à jour (git pull, pipenv install, migrate, collectstatic)
up_prod_imp : mise à jour importante (up_prod avec dump psql)
EOF
exit
1
}
function
must_succeed
{
# exec a command and return value
$*
if
[
!
$?
==
0
]
then
echo
-e
"
$RED
[erreur]
$*
$NORMAL
"
exit
42
fi
}
function
my_echo_warn
{
echo
-e
"
$YEL
>>
$*
$NORMAL
"
}
function
maj_pour_la_production
{
my_echo_warn
"git pull..."
git pull
my_echo_warn
"mise a jour du virtualenv..."
must_succeed pipenv
install
--ignore-pipfile
my_echo_warn
"collectstatic..."
pipenv run python3 ./manage.py collectstatic
--noinput
--no-post-process
my_echo_warn
"migrate..."
pipenv run python3 ./manage.py migrate
my_echo_warn
"django check deploy..."
pipenv run python3 ./manage.py check
--deploy
my_echo_warn
"restart de httpd"
systemctl restart httpd
}
if
[
!
$#
-eq
1
]
then
my_help
fi
case
"
$1
"
in
# pour le développement
test
)
my_echo_warn
"auto formatage du code..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
black
.
my_echo_warn
"django check..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py check
my_echo_warn
"pytest..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
pytest
--no-migrations
;;
migration
)
my_echo_warn
"recherche de migrations..."
must_succeed docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py makemigrations
my_echo_warn
"applications..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py migrate
my_echo_warn
"graphique des modèles..."
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py graph_models
-a
-o
graphs/complet.png
my_echo_warn
"git status..."
git status
;;
build
)
docker build
-t
$NAME
.
;;
start
)
docker run
-v
${
PWD
}
:/code
-p
8000:8000
-it
$NAME
python3 ./manage.py runserver
--trace
0.0.0.0:8000
;;
sh
)
docker run
-v
${
PWD
}
:/code
-it
$NAME
python3 ./manage.py shell_plus
;;
smtp
)
my_echo_warn
"> start smtp server (ctrl-c to stop) ..."
docker run
-v
${
PWD
}
:/code
-p
2525:2525
-it
$NAME
python3
-m
smtpd
-n
-c
DebuggingServer 0.0.0.0:2525
# docker run -v ${PWD}:/code -p 2525:2525 -it $NAME python3 ./manage.py mail_debug --use-settings
;;
update_py
)
docker run
-v
${
PWD
}
:/code
-it
$NAME
pipenv update
;;
# pour la production
dump_questions
)
my_echo_warn
"dump des questions..."
must_succeed pipenv run python3 ./manage.py dumpdata
\
--format
=
json
--indent
=
4 ede.Question ede.Theme
\
ede.Questionnaire
>
ede/fixtures/questionnaires.json
;;
sh_prod
)
pipenv run python3 ./manage.py shell_plus
;;
up_prod
)
maj_pour_la_production
;;
up_prod_imp
)
# echo "- arrêt de httpd"
# systemctl stop httpd
my_echo_warn
"sauvegarde des données avec pg_dumpall..."
if
[
!
-e
/var/lib/pgsql/backups/
]
then
mkdir
-p
/var/lib/pgsql/backups/
chown
postgres /var/lib/pgsql/backups/
fi
su postgres
-c
"pg_dumpall > /var/lib/pgsql/backups/dumpall_
$(
date
+%y%m%d
)
.sql"
maj_pour_la_production
;;
load_questions
)
pipenv run python3 ./manage.py loaddata questionnaires.json
;;
import_oracle
)
pipenv run python3 ./manage.py import_oracle
;;
rapports
)
pipenv run python3 ./manage.py fin_de_campagne
;;
connexion_oracle
)
pipenv run python3 ./manage.py test_connexion_oracle
;;
*
)
my_help
;;
esac
echo
"Remplacer par le script: do.sh"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment