install.sh
1.37 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
#!/bin/bash
export COMPANY="foss"
export ODOO_REPO="odoo_repo_"$COMPANY""
export ODOO_LIB="odoo_lib_"$COMPANY""
export ODOO_ETC="odoo_etc_"$COMPANY""
export ODOO_BACKUP="odoo_backup_"$COMPANY""
export POSTGRES_PGDATA="postgres_pgdata_"$COMPANY""
function clone_data()
{
if [ "$1" = $ODOO_REPO ]; then
docker run -it --rm -v "$1":/webportal -w /webportal 2bas/repo /bin/bash "-c" "git clone --progress --branch release -v --depth 1 git@git.foss.com.ua:fossdoc/webportal.git .; exit;";
fi
}
function create_volume()
{
IS_EXIST_VOLUME="$(docker volume ls -q -f name="^${1}$")"
if [ -z "${IS_EXIST_VOLUME}" ];then
echo "create volume: ${1}";
docker volume create --name "$1";
clone_data "$1";
else
while true; do
read -p "Volume ${1} already exist. Overwrite (no|yes)?" ny
case $ny in
[Yy]* ) docker volume rm "$1";
docker volume create --name "$1";
clone_data "$1";
break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
}
create_volume $ODOO_REPO
docker run -it --rm -v "$ODOO_REPO":/webportal -w /webportal 2bas/repo /bin/bash "-c" "git pull; exit;"
create_volume $ODOO_LIB
create_volume $ODOO_ETC
create_volume $ODOO_BACKUP
create_volume $POSTGRES_PGDATA
rm -rf docker-compose.yml;
envsubst < "template.yml" > "docker-compose.yml";
docker-compose up -d --build
docker-compose logs -f