PYROS_DOCKER_UPDATE
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/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