ProxmoxVE-CommunityScripts/install/odoo-install.sh
2025-10-26 02:04:09 +01:00

98 lines
3.6 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/tteck/Proxmox/raw/main/LICENSE
# Source: https://github.com/odoo/odoo
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y git
$STD curl https://pyenv.run | bash
$STD echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$STD echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$STD echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$STD source ~/.bashrc
$STD pyenv install 3.10.19
$STD pyenv global 3.10.19
$STD apt install -y python3-lxml
$STD apt install -y python3-ldap
$STD apt install -y python3-xlwt
$STD apt install -y python3-num2words
$STD apt install -y python3-stdnum
$STD apt install -y python3-autocommand python3-inflect python3-jaraco.context python3-jaraco.functools python3-more-itertools python3-pkg-resources python3-typeguard python3-pkg-resources
curl -fsSL "http://archive.ubuntu.com/ubuntu/pool/universe/l/lxml-html-clean/python3-lxml-html-clean_0.1.1-1_all.deb" -o /opt/python3-lxml-html-clean.deb
$STD apt install -y /opt/python3-lxml-html-clean.deb
curl -fsSL "http://archive.ubuntu.com/ubuntu/pool/universe/v/vatnumber/python3-vatnumber_1.2-9_all.deb" -o /opt/python3-vatnumber.deb
$STD apt install -y /opt/python3-vatnumber.deb
curl -fsSL "http://archive.ubuntu.com/ubuntu/pool/universe/p/pypdf2/python3-pypdf2_2.12.1-4_all.deb" -o /opt/python3-pypdf2.deb
$STD apt install -y /opt/python3-pypdf2.deb
msg_ok "Installed Dependencies"
PG_VERSION="13.16" setup_postgresql
RELEASE=$(curl -fsSL https://nightly.odoo.com/ | grep -oE 'href="[0-9]+\.[0-9]+/nightly"' | head -n1 | cut -d'"' -f2 | cut -d/ -f1)
msg_ok "Skipping installation of recent v$RELEASE and installing v13.0 instead"
RELEASE="13.0"
LATEST_VERSION=$(curl -fsSL "https://nightly.odoo.com/${RELEASE}/nightly/deb/" |
grep -oP "odoo_${RELEASE}\.\d+_all\.deb" |
sed -E "s/odoo_(${RELEASE}\.[0-9]+)_all\.deb/\1/" |
sort -V |
tail -n1)
msg_info "Setup Odoo $RELEASE with $LATEST_VERSION"
curl -fsSL "https://nightly.odoo.com/${RELEASE}/nightly/deb/odoo_${LATEST_VERSION}_all.deb" -o /opt/odoo.deb
$STD apt install -y /opt/odoo.deb
msg_ok "Setup Odoo $RELEASE with $LATEST_VERSION"
msg_info "Setup PostgreSQL Database"
DB_NAME="odoo"
DB_USER="odoo_usr"
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
$STD sudo -u postgres psql -c "ALTER DATABASE $DB_NAME OWNER TO $DB_USER;"
$STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;"
{
echo "Odoo-Credentials"
echo -e "Odoo Database User: $DB_USER"
echo -e "Odoo Database Password: $DB_PASS"
echo -e "Odoo Database Name: $DB_NAME"
} >>~/odoo.creds
msg_ok "Setup PostgreSQL"
msg_info "Configuring Odoo"
sed -i \
-e "s|^;*db_host *=.*|db_host = localhost|" \
-e "s|^;*db_port *=.*|db_port = 5432|" \
-e "s|^;*db_user *=.*|db_user = $DB_USER|" \
-e "s|^;*db_password *=.*|db_password = $DB_PASS|" \
/etc/odoo/odoo.conf
$STD sudo -u odoo odoo -c /etc/odoo/odoo.conf -d odoo -i base --stop-after-init
echo "${LATEST_VERSION}" >/opt/"${APPLICATION}"_version.txt
msg_ok "Configured Odoo"
msg_info "Restarting Odoo"
systemctl restart odoo
msg_ok "Restarted Odoo"
motd_ssh
customize
msg_info "Cleaning up"
rm -f /opt/odoo.deb
rm -f /opt/python3-lxml-html-clean.deb
$STD apt -y autoremove
$STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned"