#!/usr/bin/env bash # In docker/ folder docker_folder=$(pwd 2>&1) # 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 # Main function git pull & rebuild if necessary already_uptodate="Déjà à jour." check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in" "install/requirements.txt" "doc_rst/requirements.in" "doc_rst/requirements.txt") 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 # test only #gitpull_output=$gitpull_output."Dockerfile " # Check if exists file changed that requires rebuild #for file in "${check_files[@]}" for f in $check_files ; do #echo "check $f" #if [ $f == "doc_rst/requirements.txt" ] ; then if grep -q "$f" <<< "$gitpull_output" ; then echo "WARNING : One of docker related files ($f) has been changed. You should build again the PyROS Image before going on with the UPDATE..." echo "=> Build & start again the PyROS image ? ([y]/n)" read input ; [ -z ${input} ] && input="y" [ $input != "y" ] && exit 1 (cd $docker_folder && ./PYROS_DOCKER_BUILD && ./PYROS_DOCKER_START) # BUILF only once !!! break fi done cd - > /dev/null } # I - Update Guitastro echo echo "**********************************" echo "I - Updating Guitastro source code" echo "**********************************" echo git_pull ../vendor/guitastro/ # II - Update PyROS echo echo "**********************************" echo "II - Updating PyROS source code" echo "**********************************" echo git_pull ../ # 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 fi done #cd ../PYROS/docker/ cd $docker_folder # 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