install.sh
1.58 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
#!/bin/bash
export COMPANY="foss"
function write_data()
{
if [ -f data/"$1".tar.gz ]; then
docker run -it --rm -v "$1":/webportal -v $(pwd)/data:/backup busybox tar zxvf /backup/"$1".tar.gz -C / webportal
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"
write_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";
write_data "$1"
break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
}
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""
create_volume $ODOO_REPO
REPO_IMAGE_NAME="2bas/repo"
IS_EXIST_REPO="$(docker images | grep ^\\b${REPO_IMAGE_NAME})"
if [ -z "${IS_EXIST_REPO}" ];then
echo "Build ${REPO_IMAGE_NAME}:"
docker build -t ${REPO_IMAGE_NAME} -f repo/Dockerfile ./repo/.
else
echo "${REPO_IMAGE_NAME} already exist"
fi
docker run -it --rm -v "$ODOO_REPO":/webportal -w /webportal "$REPO_IMAGE_NAME" /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