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 #!/usr/bin/env bash 1 #!/usr/bin/env bash
2 2
  3 +# In docker/ folder
  4 +#root_folder=$(pwd 2>&1)
  5 +
3 # PRE-CONDITION : pyros container must be running 6 # PRE-CONDITION : pyros container must be running
4 -root_folder=$(pwd 2>&1)  
5 # If no container is running Start it 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 echo "pyros-db or pyros weren't running, starting them..." 9 echo "pyros-db or pyros weren't running, starting them..."
9 ./PYROS_DOCKER_START 10 ./PYROS_DOCKER_START
10 #./PYROS_DOCKER_START.bat 11 #./PYROS_DOCKER_START.bat
11 fi 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 cd ../vendor/guitastro/ 21 cd ../vendor/guitastro/
16 -gitpull_output=$(git pull 2>&1)  
17 already_uptodate="Déjà à jour." 22 already_uptodate="Déjà à jour."
  23 +gitpull_output=$(git pull 2>&1)
18 if [ $? -eq 1 ]; then 24 if [ $? -eq 1 ]; then
19 if [[ "$gitpull_output"!="$already_uptodate" ]]; then 25 if [[ "$gitpull_output"!="$already_uptodate" ]]; then
20 echo "Git pull failed. Error message is:" 26 echo "Git pull failed. Error message is:"
@@ -23,6 +29,7 @@ if [ $? -eq 1 ]; then @@ -23,6 +29,7 @@ if [ $? -eq 1 ]; then
23 fi 29 fi
24 fi 30 fi
25 echo $gitpull_output 31 echo $gitpull_output
  32 +# Check if exists file changed that requires rebuild
26 check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") 33 check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
27 for file in "${check_files[@]}" 34 for file in "${check_files[@]}"
28 do 35 do
@@ -31,10 +38,17 @@ do @@ -31,10 +38,17 @@ do
31 return 1 38 return 1
32 fi 39 fi
33 done 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 gitpull_output=$(git pull 2>&1) 52 gitpull_output=$(git pull 2>&1)
39 if [ $? -eq 1 ]; then 53 if [ $? -eq 1 ]; then
40 if [[ "$gitpull_output"!="$already_uptodate" ]]; then 54 if [[ "$gitpull_output"!="$already_uptodate" ]]; then
@@ -44,6 +58,7 @@ if [ $? -eq 1 ]; then @@ -44,6 +58,7 @@ if [ $? -eq 1 ]; then
44 fi 58 fi
45 fi 59 fi
46 echo $gitpull_output 60 echo $gitpull_output
  61 +# Check if exists file changed that requires rebuild
47 check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") 62 check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
48 for file in "${check_files[@]}" 63 for file in "${check_files[@]}"
49 do 64 do
@@ -52,19 +67,35 @@ do @@ -52,19 +67,35 @@ do
52 return 1 67 return 1
53 fi 68 fi
54 done 69 done
  70 +cd - > /dev/null
  71 +
55 72
56 # TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml 73 # TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml
57 # Tell user to rebuild 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 if [ -d .git ] ; then 87 if [ -d .git ] ; then
63 echo "Updating observatory $dir source code" 88 echo "Updating observatory $dir source code"
64 git pull 89 git pull
65 fi 90 fi
  91 + cd ../
66 done 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 docker compose exec pyros python3 pyros.py update 101 docker compose exec pyros python3 pyros.py update
70 -