#!/usr/bin/env bash # 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 echo "pyros-db or pyros weren't running, starting them..." ./PYROS_DOCKER_START #./PYROS_DOCKER_START.bat fi # I - Update Guitastro echo echo "**********************************" echo "I - Updating Guitastro source code" echo "**********************************" echo # Go to GuitAstro/ folder 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 echo echo "**********************************" echo "II - Updating PyROS source code" echo "**********************************" echo # Go to PYROS/ folder git_pull ../ # Check if exists file changed that requires rebuild #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 # Tell user to rebuild # III - Update all observatories with git repo echo echo "**********************************" echo "III - Updating PyROS Observatory(ies)" echo "**********************************" echo # Go to PYROS observatories folder cd ../../PYROS_OBSERVATORY/ for dir in * ; do if [ -d $dir/.git ] ; then echo "Updating observatory $dir source code" git_pull $dir #cd ../ fi done cd ../PYROS/docker/ # IV - pyros.py update => update BD + doc echo echo "**********************************" echo "IV - Updating PyROS Doc & Database" echo "**********************************" echo docker compose exec pyros python3 pyros.py update