2026-02-15 01:07:25 -05:00
2020-07-05 22:38:14 -04:00
# ERPLibre production guide
2021-07-20 04:13:37 -04:00
## Requirement
2021-07-20 20:14:24 -04:00
2021-07-20 04:13:37 -04:00
- 5Go of disk space
2020-09-30 20:49:35 -04:00
## Production installation procedure
2020-07-05 22:38:14 -04:00
### 1. Clone the project:
2021-07-20 20:14:24 -04:00
2020-07-05 22:38:14 -04:00
```bash
2020-11-20 23:22:28 -05:00
git clone https://github.com/ERPLibre/ERPLibre.git
2020-07-14 03:38:47 -04:00
cd ERPLibre
2020-07-05 22:38:14 -04:00
```
### 2. Modify the parameters
2021-07-20 20:14:24 -04:00
2022-03-03 14:35:23 -05:00
Modify the file env_var.sh for production installation. Enable nginx if you need a proxy with `EL_INSTALL_NGINX` at
2022-05-26 22:13:47 -04:00
True. Redirect your DNS to the proxy's ip and add your A and AAAA into `EL_WEBSITE_NAME` with space between.
2020-07-05 22:38:14 -04:00
2021-07-20 16:19:01 -04:00
### 3. Execute the scripts:
2021-07-20 02:56:14 -04:00
#### With proxy nginx production, install certbot before for SSL
2021-07-20 20:14:24 -04:00
2021-07-20 02:56:14 -04:00
```bash
# Snap installation
# https://snapcraft.io/docs/installing-snap-on-debian
sudo apt install -y snapd
sudo snap install core
sudo snap refresh core
# https://certbot.eff.org/lets-encrypt/debianbuster-nginx
2026-01-10 04:51:34 -05:00
# Certbot
2021-07-20 02:56:14 -04:00
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
```
2020-09-11 14:38:28 -04:00
#### Ubuntu 18.04 server
2021-07-20 20:14:24 -04:00
2020-09-11 14:38:28 -04:00
```bash
2023-01-02 20:33:57 -05:00
./script/install/install_dev.sh
./script/install/install_production.sh
2020-09-11 14:38:28 -04:00
```
2021-07-20 20:14:24 -04:00
2023-01-02 20:33:57 -05:00
A service is running by SystemD. You can access it with the DNS name found in `env_var.sh`
2020-09-11 14:38:28 -04:00
#### Ubuntu 20.04 server
2021-07-20 20:14:24 -04:00
2020-09-11 14:38:28 -04:00
Apply fix libpng12-0: https://www.linuxuprising.com/2018/05/fix-libpng12-0-missing-in-ubuntu-1804.html
2020-07-05 22:38:14 -04:00
```bash
2023-01-02 20:33:57 -05:00
./script/install/install_dev.sh
./script/install/install_production.sh
2020-07-05 22:38:14 -04:00
```
2021-07-20 20:14:24 -04:00
2023-01-02 20:33:57 -05:00
A service is running by SystemD, you can access it with the DNS name found in `env_var.sh`
2020-07-14 03:38:47 -04:00
### 4. SSL:
2021-07-20 20:14:24 -04:00
2020-09-11 14:38:28 -04:00
Generate a ssl certificate
2021-07-20 20:14:24 -04:00
2020-07-14 03:38:47 -04:00
```bash
sudo certbot --nginx
```
## Watch log
2021-07-20 20:14:24 -04:00
2020-07-14 03:38:47 -04:00
```bash
sudo systemctl -feu [EL_USER]
```
## Run by address ip
2021-07-20 20:14:24 -04:00
2020-09-30 20:49:35 -04:00
Comment the following line in `/[EL_USER]/erplibre/config.conf`
2021-07-20 20:14:24 -04:00
2020-07-14 03:38:47 -04:00
```
2024-04-23 00:50:09 -04:00
xmlrpc_interface = 0.0.0.0
proxy_mode = True
2020-07-14 03:38:47 -04:00
```
2021-07-20 20:14:24 -04:00
2020-09-30 20:49:35 -04:00
Add your address ip server_name in nginx config `/etc/nginx/sites-available/[EL_WEBSITE_NAME]`
2020-07-14 03:38:47 -04:00
Restart daemon:
2021-07-20 20:14:24 -04:00
2020-07-14 03:38:47 -04:00
```bash
sudo systemctl restart nginx
sudo systemctl restart [EL_USER]
```
2020-07-05 22:38:14 -04:00
## Production execution
2021-07-20 20:14:24 -04:00
2020-07-05 22:38:14 -04:00
```bash
cd /[EL_USER]/erplibre
./run.sh -d [DATABASE] --no-database-list
```
2020-09-30 20:49:35 -04:00
## Move prod database to dev
2021-07-20 20:14:24 -04:00
When moving prod database to your dev environment, you want to remove email servers and install user test to test the
2023-09-07 15:19:13 -04:00
database. WARNING, this is not safe for production, you will expose all data.
1. Copy your database image to directory image_db, exemple the image name is `my_db.zip`
1. Run
2021-07-20 20:14:24 -04:00
2020-07-05 22:38:14 -04:00
```bash
2023-09-07 15:19:13 -04:00
./script/database/db_restore.py --clean_cache --database test_my_db --image my_db
./script/addons/update_prod_to_dev.sh test_my_db
2020-07-05 22:38:14 -04:00
```
2020-07-12 22:49:25 -04:00
## Update production
2021-07-20 20:14:24 -04:00
2020-09-30 20:49:35 -04:00
Update all features.
2021-07-20 20:14:24 -04:00
2020-07-12 22:49:25 -04:00
```bash
2024-12-02 05:27:57 -05:00
./run.sh --limit-time-real 99999 --no-http --stop-after-init -u all -d DATABASE
2020-07-12 22:49:25 -04:00
```
2020-07-31 15:21:54 -04:00
2020-07-28 06:09:58 -04:00
# Postgresql
2021-07-20 20:14:24 -04:00
2021-07-20 16:19:01 -04:00
To show config files:
2020-07-28 06:09:58 -04:00
> psql -U postgres -c 'SHOW config_file'
2020-09-30 20:49:35 -04:00
Edit this file to accept interface from all networks:
2020-07-28 06:09:58 -04:00
> /var/lib/postgres/data/postgresql.conf
2020-07-31 15:21:54 -04:00
# Delete an instance in production
2021-07-20 20:14:24 -04:00
2021-07-20 16:19:01 -04:00
CAUTION, this will delete user's home, it's irrevocable.
2021-07-20 20:14:24 -04:00
2020-07-31 15:21:54 -04:00
```bash
2023-01-02 20:33:57 -05:00
./script/database/delete_production.sh
2020-07-31 15:21:54 -04:00
```
2021-03-18 22:22:36 -04:00
# Update ip when public ip change with CloudFlare and crontab
2024-12-28 22:34:06 -05:00
First you need a valid python3 interpreter running with cloudflare module installed: (make sure your pip3 pointing the right python3)
2021-03-18 22:22:36 -04:00
```bash
2024-12-28 22:34:06 -05:00
pip3 install cloudflare==2.20.0
2021-03-18 22:22:36 -04:00
```
2024-12-28 22:34:06 -05:00
Then you need to create the cfg files with credentials for your cloudflare account.
```bash
mkdir ~/.cloudflare
```
2026-02-15 01:07:25 -05:00
2021-03-18 22:22:36 -04:00
Edit ~/.cloudflare/cloudflare.cfg
2021-07-20 20:14:24 -04:00
2021-03-18 22:22:36 -04:00
```
[PROFILE_NAME]
email=EMAIL
2024-12-28 22:34:06 -05:00
token=TOKEN (Use the global API key so that it works)
2021-03-18 22:22:36 -04:00
```
2024-12-28 22:34:06 -05:00
Add your cron and specify the python3 you want to use with it.
- USER is the local user with permissions to execute the script
- PATH is path to inside of ERPLibre/deployment/ folder
- PROFILE_NAME must match the PROFILE_NAME in cloudflare.cfg
- CLOUDFLARE_ZONE_NAME is the name of the website zone on cloudflare
- DNS_NAME is the name of one DNS A record name available on that zone
Notes:
- Only one crontab is required because the script will automatically research all available zones with outdated ip and update them on all A records.
- For each crontab run, if public IP did not change compared to what is on cloudflare, the script will not do unnecessary changes and let everything as is.
2021-07-20 20:14:24 -04:00
2021-03-18 22:22:36 -04:00
```bash
vim /etc/crontab
# Add
2024-12-28 22:34:06 -05:00
*/5 * * * * USER cd PATH && python3 script/deployment/update_dns_cloudflare.py --profile PROFILE_NAME --zone_name CLOUDFLARE_ZONE_NAME --dns_name DNS_NAME --auto_sync
2021-03-18 22:22:36 -04:00
```
Check log with
2021-07-20 20:14:24 -04:00
2021-03-18 22:22:36 -04:00
```bash
sudo journalctl -feu cron
2021-07-20 16:19:01 -04:00
```
2022-01-25 22:29:13 -05:00
2024-12-28 22:34:06 -05:00
If you want to log what is happening and when the script is run, like logging when ip changes, you can add a logging part to your cron
```bash
vim /etc/crontab
# Add
*/5 * * * * USER cd PATH && python3 script/deployment/update_dns_cloudflare.py --profile PROFILE_NAME --zone_name CLOUDFLARE_ZONE_NAME --dns_name DNS_NAME --auto_sync > /home/USER/logs/update_dns_ZONE_NAME.log 2>& 1
```
You can then read all logs with this command (Need to have ts installed: sudo apt install moreutils)
```bash
tail -f /home/USER/logs/update_dns_ZONE_NAME.log | ts
```
2022-01-25 22:29:13 -05:00
# Docker
2022-03-03 14:35:23 -05:00
2022-01-25 22:29:13 -05:00
## Update
When update a docker, you need to update the list of module.
Run script to update configuration :
2022-03-03 14:35:23 -05:00
2022-01-25 22:29:13 -05:00
```bash
./script/docker/docker_gen_config.sh
```
Edit the docker-compose.yml and update the command line (change DATABASE) to :
2022-03-03 14:35:23 -05:00
2022-01-25 22:29:13 -05:00
```yaml
command: odoo --workers 2 -u erplibre_info -d DATABASE
```
Note, the goal is to call `env['ir.module.module'].update_list()` .
Restart the docker :
2022-03-03 14:35:23 -05:00
2022-01-25 22:29:13 -05:00
```bash
2024-04-22 23:45:53 -04:00
docker compose down
docker compose up -d
2022-01-25 22:29:13 -05:00
```
Revert the command in docker-compose.yml.
You can validate in log the update, you need to find `odoo.modules.loading: updating modules list` , check
2022-03-03 14:35:23 -05:00
2022-01-25 22:29:13 -05:00
```bash
2024-04-22 23:45:53 -04:00
docker compose logs -f
2022-01-25 22:29:13 -05:00
```
2023-01-02 01:57:18 -05:00
## Update all
Do a backup on url https://HOST/web/database/manager
Edit the docker-compose.yml and update the command line (change DATABASE) to :
```yaml
command: odoo --workers 2 -u all -d DATABASE
```
Watch log to see error, if you got error, you need to do some code to migrate your data, depend the case.
```bash
make docker_show_logs_live
2026-02-15 01:07:25 -05:00
```