-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_and_run.sh
executable file
·55 lines (45 loc) · 1.78 KB
/
build_and_run.sh
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
#!/bin/bash
# Set environment variables
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DB=postgres
export ODOO_DB_USER=odoo
export ODOO_DB_PASSWORD=odoo
export ODOO_DB_NAME=odoo
export ODOO_PORT=8069
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "Docker is not installed. Please install Docker and try again."
exit 1
fi
# Check if Docker service is running
docker info &> /dev/null
if [ $? -ne 0 ]; then
echo "Docker service is not running. Please start Docker and try again."
exit 1
fi
# Start the Docker Compose services
docker-compose up -d
# Wait for the PostgreSQL service to start
echo "Waiting for PostgreSQL to become available..."
count=0
until docker-compose exec postgres pg_isready -U postgres -d postgres -q || [ $count -eq 30 ]; do
sleep 1
((count++))
done
if [ $count -eq 30 ]; then
echo "Timed out waiting for PostgreSQL to become available."
exit 1
fi
# Connect to the PostgreSQL container and execute SQL commands
# docker-compose exec postgres psql -U postgres -d postgres -c "CREATE ROLE $POSTGRES_USER WITH SUPERUSER LOGIN PASSWORD '$POSTGRES_PASSWORD';"
docker-compose exec postgres psql -U postgres -d postgres -c "CREATE DATABASE $POSTGRES_DB;"
docker-compose exec postgres psql -U postgres -d postgres -c "CREATE USER $ODOO_DB_USER WITH PASSWORD '$ODOO_DB_PASSWORD';"
docker-compose exec postgres psql -U postgres -d postgres -c "GRANT ALL PRIVILEGES ON DATABASE $ODOO_DB_NAME TO $ODOO_DB_USER;"
docker-compose exec postgres psql -U postgres -d postgres -c "ALTER USER $ODOO_DB_USER CREATEDB;"
# Restart the Odoo service to apply the changes
docker-compose restart odoo
# Define the URL you want to open
URL="http://127.0.0.1:${ODOO_PORT}"
# Open the URL in the default browser
xdg-open "$URL"