Commit ec1e5b33b2a5459dfea1aa81976ab9abdb5ee0f0

Authored by Etienne Pallier
1 parent 063ad5a8
Exists in dev

bugfix PYROS_DOCKER_UPDATE and comments

Showing 1 changed file with 44 additions and 13 deletions   Show diff stats
docker/PYROS_DOCKER_UPDATE
1 1 #!/usr/bin/env bash
2 2  
  3 +# In docker/ folder
  4 +#root_folder=$(pwd 2>&1)
  5 +
3 6 # PRE-CONDITION : pyros container must be running
4   -root_folder=$(pwd 2>&1)
5 7 # If no container is running Start it
6   -if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ]
7   -then
  8 +if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then
8 9 echo "pyros-db or pyros weren't running, starting them..."
9 10 ./PYROS_DOCKER_START
10 11 #./PYROS_DOCKER_START.bat
11 12 fi
12 13  
13   -# 1) Update Guitastro
14   -echo "Updating Guitastro source code"
  14 +# I - Update Guitastro
  15 +echo
  16 +echo "**********************************"
  17 +echo "I - Updating Guitastro source code"
  18 +echo "**********************************"
  19 +echo
  20 +# Go to GuitAstro/ folder
15 21 cd ../vendor/guitastro/
16   -gitpull_output=$(git pull 2>&1)
17 22 already_uptodate="Déjà à jour."
  23 +gitpull_output=$(git pull 2>&1)
18 24 if [ $? -eq 1 ]; then
19 25 if [[ "$gitpull_output"!="$already_uptodate" ]]; then
20 26 echo "Git pull failed. Error message is:"
... ... @@ -23,6 +29,7 @@ if [ $? -eq 1 ]; then
23 29 fi
24 30 fi
25 31 echo $gitpull_output
  32 +# Check if exists file changed that requires rebuild
26 33 check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
27 34 for file in "${check_files[@]}"
28 35 do
... ... @@ -31,10 +38,17 @@ do
31 38 return 1
32 39 fi
33 40 done
  41 +cd - > /dev/null
34 42  
35   -# 2) Update PyROS
36   -cd $root_folder
37   -echo "Updating PyROS source code"
  43 +# II - Update PyROS
  44 +#cd $root_folder
  45 +echo
  46 +echo "**********************************"
  47 +echo "II - Updating PyROS source code"
  48 +echo "**********************************"
  49 +echo
  50 +# Go to PYROS/ folder
  51 +cd ../
38 52 gitpull_output=$(git pull 2>&1)
39 53 if [ $? -eq 1 ]; then
40 54 if [[ "$gitpull_output"!="$already_uptodate" ]]; then
... ... @@ -44,6 +58,7 @@ if [ $? -eq 1 ]; then
44 58 fi
45 59 fi
46 60 echo $gitpull_output
  61 +# Check if exists file changed that requires rebuild
47 62 check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
48 63 for file in "${check_files[@]}"
49 64 do
... ... @@ -52,19 +67,35 @@ do
52 67 return 1
53 68 fi
54 69 done
  70 +cd - > /dev/null
  71 +
55 72  
56 73 # TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml
57 74 # Tell user to rebuild
58 75  
59 76  
60   -# 3) Update all observatories with git repo
61   -for dir in ../../PYROS_OBSERVATORY/* ; do
  77 +# III - Update all observatories with git repo
  78 +echo
  79 +echo "**********************************"
  80 +echo "III - Updating PyROS Observatory(ies)"
  81 +echo "**********************************"
  82 +echo
  83 +# Go to PYROS observatories folder
  84 +cd ../../PYROS_OBSERVATORY/
  85 +for dir in * ; do
  86 + cd $dir
62 87 if [ -d .git ] ; then
63 88 echo "Updating observatory $dir source code"
64 89 git pull
65 90 fi
  91 + cd ../
66 92 done
  93 +cd ../PYROS/docker/
67 94  
68   -# 3) pyros.py update => update BD + doc + Guitastro requirements
  95 +# IV - pyros.py update => update BD + doc
  96 +echo
  97 +echo "**********************************"
  98 +echo "IV - Updating PyROS Doc & Database"
  99 +echo "**********************************"
  100 +echo
69 101 docker compose exec pyros python3 pyros.py update
70   -
... ...