diff --git a/docker/PYROS_DOCKER_UPDATE b/docker/PYROS_DOCKER_UPDATE index f99f8d9..4f82862 100755 --- a/docker/PYROS_DOCKER_UPDATE +++ b/docker/PYROS_DOCKER_UPDATE @@ -3,6 +3,34 @@ # In docker/ folder #root_folder=$(pwd 2>&1) +already_uptodate="Déjà à jour." +check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") +check_files="${check_files[@]}" +function git_pull { + dir=$1 + #echo $check_files + cd $dir + gitpull_output=$(git pull 2>&1) + # IF git pull error (other than $already_uptodate) => stop + if [[ $? -eq 1 && "$gitpull_output"!="$already_uptodate" ]]; then + echo "Git pull failed. Error message is:" + echo $gitpull_output + exit 1 + fi + echo $gitpull_output + # Check if exists file changed that requires rebuild + #for file in "${check_files[@]}" + for f in $check_files ; do + #echo "check $f" + if grep -q "$f" <<< "$gitpull_output"; then + echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image" + return 1 + fi + done + cd - > /dev/null +} + + # PRE-CONDITION : pyros container must be running # If no container is running Start it if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then @@ -18,27 +46,10 @@ echo "I - Updating Guitastro source code" echo "**********************************" echo # Go to GuitAstro/ folder -cd ../vendor/guitastro/ -already_uptodate="Déjà à jour." -gitpull_output=$(git pull 2>&1) -if [ $? -eq 1 ]; then - if [[ "$gitpull_output"!="$already_uptodate" ]]; then - echo "Git pull failed. Error message is:" - echo $gitpull_output - exit 1 - fi -fi -echo $gitpull_output -# Check if exists file changed that requires rebuild -check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") -for file in "${check_files[@]}" -do - if grep -q "$file" <<< "$gitpull_output"; then - echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image" - return 1 - fi -done -cd - > /dev/null +git_pull ../vendor/guitastro/ +#check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") +#git_pull ../vendor/guitastro/ ${check_files[@]} + # II - Update PyROS #cd $root_folder @@ -48,26 +59,9 @@ echo "II - Updating PyROS source code" echo "**********************************" echo # Go to PYROS/ folder -cd ../ -gitpull_output=$(git pull 2>&1) -if [ $? -eq 1 ]; then - if [[ "$gitpull_output"!="$already_uptodate" ]]; then - echo "Git pull failed. Error message is:" - echo $gitpull_output - exit 1 - fi -fi -echo $gitpull_output +git_pull ../ # Check if exists file changed that requires rebuild -check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") -for file in "${check_files[@]}" -do - if grep -q "$file" <<< "$gitpull_output"; then - echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image" - return 1 - fi -done -cd - > /dev/null +#check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") # TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml @@ -83,12 +77,11 @@ echo # Go to PYROS observatories folder cd ../../PYROS_OBSERVATORY/ for dir in * ; do - cd $dir - if [ -d .git ] ; then + if [ -d $dir/.git ] ; then echo "Updating observatory $dir source code" - git pull + git_pull $dir + #cd ../ fi - cd ../ done cd ../PYROS/docker/ -- libgit2 0.21.2