Commit 156992e1bf788fff9421c9e6d6e167237d892f1c

Authored by Etienne Pallier
1 parent ec1e5b33
Exists in dev

Refactorisation PYROS_DOCKER_UPDATE

Showing 1 changed file with 37 additions and 44 deletions   Show diff stats
docker/PYROS_DOCKER_UPDATE
... ... @@ -3,6 +3,34 @@
3 3 # In docker/ folder
4 4 #root_folder=$(pwd 2>&1)
5 5  
  6 +already_uptodate="Déjà à jour."
  7 +check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
  8 +check_files="${check_files[@]}"
  9 +function git_pull {
  10 + dir=$1
  11 + #echo $check_files
  12 + cd $dir
  13 + gitpull_output=$(git pull 2>&1)
  14 + # IF git pull error (other than $already_uptodate) => stop
  15 + if [[ $? -eq 1 && "$gitpull_output"!="$already_uptodate" ]]; then
  16 + echo "Git pull failed. Error message is:"
  17 + echo $gitpull_output
  18 + exit 1
  19 + fi
  20 + echo $gitpull_output
  21 + # Check if exists file changed that requires rebuild
  22 + #for file in "${check_files[@]}"
  23 + for f in $check_files ; do
  24 + #echo "check $f"
  25 + if grep -q "$f" <<< "$gitpull_output"; then
  26 + echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image"
  27 + return 1
  28 + fi
  29 + done
  30 + cd - > /dev/null
  31 +}
  32 +
  33 +
6 34 # PRE-CONDITION : pyros container must be running
7 35 # If no container is running Start it
8 36 if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then
... ... @@ -18,27 +46,10 @@ echo &quot;I - Updating Guitastro source code&quot;
18 46 echo "**********************************"
19 47 echo
20 48 # Go to GuitAstro/ folder
21   -cd ../vendor/guitastro/
22   -already_uptodate="Déjà à jour."
23   -gitpull_output=$(git pull 2>&1)
24   -if [ $? -eq 1 ]; then
25   - if [[ "$gitpull_output"!="$already_uptodate" ]]; then
26   - echo "Git pull failed. Error message is:"
27   - echo $gitpull_output
28   - exit 1
29   - fi
30   -fi
31   -echo $gitpull_output
32   -# Check if exists file changed that requires rebuild
33   -check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
34   -for file in "${check_files[@]}"
35   -do
36   - if grep -q "$file" <<< "$gitpull_output"; then
37   - echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image"
38   - return 1
39   - fi
40   -done
41   -cd - > /dev/null
  49 +git_pull ../vendor/guitastro/
  50 +#check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
  51 +#git_pull ../vendor/guitastro/ ${check_files[@]}
  52 +
42 53  
43 54 # II - Update PyROS
44 55 #cd $root_folder
... ... @@ -48,26 +59,9 @@ echo &quot;II - Updating PyROS source code&quot;
48 59 echo "**********************************"
49 60 echo
50 61 # Go to PYROS/ folder
51   -cd ../
52   -gitpull_output=$(git pull 2>&1)
53   -if [ $? -eq 1 ]; then
54   - if [[ "$gitpull_output"!="$already_uptodate" ]]; then
55   - echo "Git pull failed. Error message is:"
56   - echo $gitpull_output
57   - exit 1
58   - fi
59   -fi
60   -echo $gitpull_output
  62 +git_pull ../
61 63 # Check if exists file changed that requires rebuild
62   -check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
63   -for file in "${check_files[@]}"
64   -do
65   - if grep -q "$file" <<< "$gitpull_output"; then
66   - echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image"
67   - return 1
68   - fi
69   -done
70   -cd - > /dev/null
  64 +#check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in")
71 65  
72 66  
73 67 # TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml
... ... @@ -83,12 +77,11 @@ echo
83 77 # Go to PYROS observatories folder
84 78 cd ../../PYROS_OBSERVATORY/
85 79 for dir in * ; do
86   - cd $dir
87   - if [ -d .git ] ; then
  80 + if [ -d $dir/.git ] ; then
88 81 echo "Updating observatory $dir source code"
89   - git pull
  82 + git_pull $dir
  83 + #cd ../
90 84 fi
91   - cd ../
92 85 done
93 86 cd ../PYROS/docker/
94 87  
... ...