Blame view

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

a56e6e0e   Etienne Pallier   comments and shor...
3
# PRE-CONDITION : pyros container must be running
0a1f1d83   Alexis Koralewski   Add file checking...
4
root_folder=$(pwd 2>&1)
7407f600   Etienne Pallier   petites ameliorat...
5
# If no container is running Start it
e1d22a59   Alexis Koralewski   Change redis cont...
6
if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ]
e1e75163   Alexis Koralewski   fixing issue with...
7
then
ec4214ff   Alexis Koralewski   Renaming pyros co...
8
    echo "pyros-db or pyros weren't running, starting them..."
b1e4e4dd   Etienne Pallier   Renamed scripts P...
9
    ./PYROS_DOCKER_START
2da110b4   Etienne Pallier   fix call to START...
10
    #./PYROS_DOCKER_START.bat
e1e75163   Alexis Koralewski   fixing issue with...
11
fi
f11ebe06   Etienne Pallier   Dockerfile cleanu...
12

7407f600   Etienne Pallier   petites ameliorat...
13
# 1) Update Guitastro
f11ebe06   Etienne Pallier   Dockerfile cleanu...
14
echo "Updating Guitastro source code"
0a1f1d83   Alexis Koralewski   Add file checking...
15
16
cd ../vendor/guitastro/
gitpull_output=$(git pull 2>&1)
063ad5a8   Alexis Koralewski   add check of git ...
17
18
19
20
21
22
23
24
already_uptodate="Déjà à jour."
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...
25
26
27
28
29
30
31
32
33
echo $gitpull_output
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
7407f600   Etienne Pallier   petites ameliorat...
34
35

# 2) Update PyROS
0a1f1d83   Alexis Koralewski   Add file checking...
36
cd $root_folder
f11ebe06   Etienne Pallier   Dockerfile cleanu...
37
echo "Updating PyROS source code"
0a1f1d83   Alexis Koralewski   Add file checking...
38
gitpull_output=$(git pull 2>&1)
063ad5a8   Alexis Koralewski   add check of git ...
39
40
41
42
43
44
45
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...
46
47
48
49
50
51
52
53
54
55
56
57
58
echo $gitpull_output
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

# 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...
59

a56e6e0e   Etienne Pallier   comments and shor...
60
61
62
63
64
65
# 3) Update all observatories with git repo
for dir in ../../PYROS_OBSERVATORY/* ; do
    if [ -d .git ] ; then 
        echo "Updating observatory $dir source code"
        git pull
    fi
3be8b2fc   Alexis Koralewski   Add git pull of o...
66
67
done

7407f600   Etienne Pallier   petites ameliorat...
68
# 3) pyros.py update => update BD + doc + Guitastro requirements
1b11a72f   Alexis Koralewski   Update docker scr...
69
docker compose exec pyros python3 pyros.py update
e1e75163   Alexis Koralewski   fixing issue with...