Blame view

docker/PYROS_DOCKER_UPDATE 2.71 KB
e64cdd09   ALEXIS-PC\alexis   improving check a...
1
#!/usr/bin/env bash
e1e75163   Alexis Koralewski   fixing issue with...
2

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
3
4
5
# In docker/ folder
#root_folder=$(pwd 2>&1)

a56e6e0e   Etienne Pallier   comments and shor...
6
# PRE-CONDITION : pyros container must be running
7407f600   Etienne Pallier   petites ameliorat...
7
# If no container is running Start it
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
8
if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then
ec4214ff   Alexis Koralewski   Renaming pyros co...
9
    echo "pyros-db or pyros weren't running, starting them..."
b1e4e4dd   Etienne Pallier   Renamed scripts P...
10
    ./PYROS_DOCKER_START
2da110b4   Etienne Pallier   fix call to START...
11
    #./PYROS_DOCKER_START.bat
e1e75163   Alexis Koralewski   fixing issue with...
12
fi
f11ebe06   Etienne Pallier   Dockerfile cleanu...
13

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
14
15
16
17
18
19
20
# I - Update Guitastro
echo
echo "**********************************"
echo "I - Updating Guitastro source code"
echo "**********************************"
echo
# Go to GuitAstro/ folder
0a1f1d83   Alexis Koralewski   Add file checking...
21
cd ../vendor/guitastro/
063ad5a8   Alexis Koralewski   add check of git ...
22
already_uptodate="Déjà à jour."
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
23
gitpull_output=$(git pull 2>&1)
063ad5a8   Alexis Koralewski   add check of git ...
24
25
26
27
28
29
30
if [ $? -eq 1 ]; then
    if [[ "$gitpull_output"!="$already_uptodate" ]]; then
        echo "Git pull failed. Error message is:"
        echo $gitpull_output
        exit 1
    fi
fi
0a1f1d83   Alexis Koralewski   Add file checking...
31
echo $gitpull_output
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
32
# Check if exists file changed that requires rebuild
0a1f1d83   Alexis Koralewski   Add file checking...
33
34
35
36
37
38
39
40
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
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
41
cd - > /dev/null
7407f600   Etienne Pallier   petites ameliorat...
42

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
43
44
45
46
47
48
49
50
51
# II - Update PyROS
#cd $root_folder
echo
echo "**********************************"
echo "II - Updating PyROS source code"
echo "**********************************"
echo
# Go to PYROS/ folder
cd ../
0a1f1d83   Alexis Koralewski   Add file checking...
52
gitpull_output=$(git pull 2>&1)
063ad5a8   Alexis Koralewski   add check of git ...
53
54
55
56
57
58
59
if [ $? -eq 1 ]; then
    if [[ "$gitpull_output"!="$already_uptodate" ]]; then
        echo "Git pull failed. Error message is:"
        echo $gitpull_output
        exit 1
    fi
fi
0a1f1d83   Alexis Koralewski   Add file checking...
60
echo $gitpull_output
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
61
# Check if exists file changed that requires rebuild
0a1f1d83   Alexis Koralewski   Add file checking...
62
63
64
65
66
67
68
69
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
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
70
71
cd - > /dev/null

0a1f1d83   Alexis Koralewski   Add file checking...
72
73
74
75

# TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml
# Tell user to rebuild

f11ebe06   Etienne Pallier   Dockerfile cleanu...
76

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
77
78
79
80
81
82
83
84
85
86
# 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
    cd $dir
a56e6e0e   Etienne Pallier   comments and shor...
87
88
89
90
    if [ -d .git ] ; then 
        echo "Updating observatory $dir source code"
        git pull
    fi
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
91
    cd ../
3be8b2fc   Alexis Koralewski   Add git pull of o...
92
done
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
93
cd ../PYROS/docker/
3be8b2fc   Alexis Koralewski   Add git pull of o...
94

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
95
96
97
98
99
100
# IV - pyros.py update => update BD + doc
echo
echo "**********************************"
echo "IV - Updating PyROS Doc & Database"
echo "**********************************"
echo
1b11a72f   Alexis Koralewski   Update docker scr...
101
docker compose exec pyros python3 pyros.py update