PYROS_DOCKER_UPDATE
2.62 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
94
#!/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