====== Setup Template DB Script ======
* This script is designed to automate the setup of **//Odoo//** databases with and without demo data. It interacts with Docker containers running **//Odoo//** and **PostgreSQL** to **//create//**, **//update//**, and **//manage//** databases.
==== Link ====
* You can find the script on **[[https://git.elosys.net/sys/rembin/-/blob/master/setup_template_db.sh?ref_type=heads|Gitlab]]**
==== Usage ====
* Navigate to rembin/ directory
* execute the script :
./setup_template_db.sh
* ****: The version number of **//Odoo//** to use for database creation.
=== Example ===
./setup_template_db.sh 14
* This command sets up Odoo databases using version 14, creating databases both with and without demo data.
==== Dependencies ====
* **Docker**: The script relies on Docker for containerization.
* **PostgreSQL**: The script uses PostgreSQL for database management.
==== Variables ====
* **VERSION**: The version number of **//Odoo//** provided as the first argument to the script.
* **DBASENAME**: The base name for the **//Odoo//** database. It is composed of "**base**" followed by the version number.
* **IMAGE**: The Docker image name for **//Odoo//**, derived from the version number.
* **FILESTORE**: The directory path for storing files related to **//Odoo//**.
==== Functions ====
* **setup_template_dbs()**: This function sets up **//Odoo//** databases with and without demo data.
* **Parameters**:
* **$1**: The name of the **//database//**.
* **$2**: The Docker image for **//Odoo//**.
* **Steps**:
* Checks if the **//database//** exists. If yes, ''deletes'' it.
* Checks if the **//database//** with demo data exists. If yes, ''deletes'' it.
* Creates a **//database//** with demo data.
* Stops and removes the Docker container after initialization.
* Creates a **//database//** without demo data.
==== Workflow ====
- Checks if the script is provided with the required version number. If not, it displays an ''error'' message and exits.
- Calls the **setup_template_dbs** function with the base database name and the **//Odoo//** Docker image.
==== Docker Configuration ====
* The script assumes the presence of a **//Docker//** network named **app_net**.
* It links the **//Odoo//** container with the **PostgreSQL** container named **pushdb**.
* It mounts the **FILESTORE** directory to **/var/lib/odoo** in the **//Odoo//** container for file storage.
----
--- //[[nadirhabib96@gmail.com|Nadir Habib]] 2024/04/27 22:02//