From d5c1dc238bcb9e9ae1c4685e5c7a2024f9c4e2ca Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 07:32:28 +0000 Subject: [PATCH] feat: Add Odoo installation script for Debian/Ubuntu This commit introduces a new shell script, `installer.sh`, designed to automate the installation of Odoo (master branch) on Debian/Ubuntu-based systems, such as a Hetzner VPS. The script performs the following key actions: - Updates system packages. - Installs essential dependencies (Python, PostgreSQL, Node.js, build tools). - Configures a PostgreSQL user and database for Odoo. - Creates a dedicated system user for Odoo. - Clones the Odoo source code from GitHub (master branch). - Sets up a Python virtual environment and installs Odoo's Python dependencies. - Installs wkhtmltopdf (0.12.5) and its dependencies for report generation. - Creates an Odoo configuration file (`/etc/odoo18.conf`) with default settings. - Sets up a systemd service (`odoo18.service`) to manage the Odoo server. - Includes error handling (`set -e`) and progress messages. The script provides instructions for download and execution and includes warnings regarding default passwords that you should change in a production environment. --- installer.sh | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 installer.sh diff --git a/installer.sh b/installer.sh new file mode 100644 index 0000000..0e0adc8 --- /dev/null +++ b/installer.sh @@ -0,0 +1,198 @@ +#!/bin/bash + +# Odoo Installation Script for Debian/Ubuntu +# +# This script automates the installation of Odoo on a Debian/Ubuntu based system. +# +# To run this script: +# 1. Download it: wget -O install_odoo.sh +# 2. Make it executable: chmod +x install_odoo.sh +# 3. Run it: ./install_odoo.sh +# +# IMPORTANT: Review this script before running it on your system. +# Some commands require sudo privileges and will modify your system. +# It is recommended to run this script on a fresh Debian/Ubuntu installation. + +# Exit immediately if a command exits with a non-zero status. +set -e + +echo "Starting Odoo installation script..." + +# Step 1: Update and Upgrade System Packages +echo "Step 1: Updating and upgrading system packages..." +sudo apt-get update +sudo apt-get upgrade -y +echo "System packages updated and upgraded successfully." + +# Step 2: Install Essential Dependencies +echo "Step 2: Installing essential dependencies..." +sudo apt-get install -y python3-pip +sudo apt-get install -y python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev + +# Create a symbolic link for nodejs if it doesn't exist +if [ ! -f /usr/bin/node ]; then + echo "Creating symbolic link for nodejs..." + sudo ln -s /usr/bin/nodejs /usr/bin/node +fi + +sudo npm install -g less less-plugin-clean-css +sudo apt-get install -y node-less +echo "Essential dependencies installed successfully." + +# Step 3: Install and Configure PostgreSQL +echo "Step 3: Installing and configuring PostgreSQL..." +sudo apt-get install -y postgresql + +echo "Creating PostgreSQL user for Odoo..." +sudo su - postgres -c "createuser --createdb --username postgres --no-createrole --superuser odoo18" + +# IMPORTANT: This script uses a default password '123456' for the PostgreSQL user 'odoo18'. +# It is STRONGLY recommended to change this password for security reasons. +# You will also need to update the 'db_password' in the Odoo configuration file (/etc/odoo18.conf) if you change it. +echo "Setting password for PostgreSQL user 'odoo18'. You might be prompted by PostgreSQL." +echo "Using default password '123456'. Please change this in a production environment." +sudo su - postgres -c "psql -c \"ALTER USER odoo18 WITH PASSWORD '123456';\"" +echo "PostgreSQL installed and configured successfully." + +# Step 4: Create Odoo System User +echo "Step 4: Creating Odoo system user..." +sudo adduser --system --home=/opt/odoo18 --group odoo18 +echo "Odoo system user created successfully." + +# Step 5: Download Odoo Source Code +echo "Step 5: Downloading Odoo source code..." +sudo apt-get install -y git +echo "Cloning Odoo repository (this may take some time)..." +# Create the directory /opt/odoo18 if it doesn't exist and set ownership +sudo mkdir -p /opt/odoo18 +sudo chown odoo18:odoo18 /opt/odoo18 +sudo su - odoo18 -s /bin/bash -c "git clone https://www.github.com/odoo/odoo --depth 1 --branch master --single-branch /opt/odoo18" +echo "Odoo source code downloaded successfully." + +# Step 6: Set Up Python Virtual Environment +echo "Step 6: Setting up Python virtual environment..." +sudo apt-get install -y python3-venv +sudo python3 -m venv /opt/odoo18/venv +echo "Python virtual environment created. Installing Python dependencies..." +sudo /opt/odoo18/venv/bin/pip install -r /opt/odoo18/requirements.txt +echo "Python dependencies installed successfully." + +# Step 7: Install wkhtmltopdf +echo "Step 7: Installing wkhtmltopdf..." +# Download libssl1.1 - necessary for wkhtmltopdf 0.12.5 on newer Ubuntu versions +echo "Downloading libssl1.1..." +sudo wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb -P /tmp/ +echo "Installing libssl1.1..." +sudo dpkg -i /tmp/libssl1.1_1.1.1f-1ubuntu2_amd64.deb + +echo "Downloading wkhtmltopdf..." +sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb -P /tmp/ +echo "Installing xfonts-75dpi..." +sudo apt-get install -y xfonts-75dpi +echo "Installing wkhtmltopdf..." +sudo dpkg -i /tmp/wkhtmltox_0.12.5-1.bionic_amd64.deb + +echo "Fixing any potential dependency issues..." +sudo apt-get install -f -y + +echo "Cleaning up downloaded .deb files..." +sudo rm /tmp/*.deb +echo "wkhtmltopdf installed successfully." + +# Step 8: Configure Odoo +echo "Step 8: Configuring Odoo..." +sudo cp /opt/odoo18/debian/odoo.conf /etc/odoo18.conf + +echo "Modifying Odoo configuration file (/etc/odoo18.conf)..." +sudo sed -i "s/^admin_passwd = .*/admin_passwd = admin/" /etc/odoo18.conf +# Ensure db_host, db_port, db_user, db_password are set or add them if not present +sudo sed -i "/^db_host = .*/c\db_host = localhost" /etc/odoo18.conf +sudo sed -i "/^db_port = .*/c\db_port = 5432" /etc/odoo18.conf +sudo sed -i "/^db_user = .*/c\db_user = odoo18" /etc/odoo18.conf +# IMPORTANT: The password '123456' below MUST match the password set for the PostgreSQL user 'odoo18'. +# If you changed the PostgreSQL password, update it here as well. +sudo sed -i "/^db_password = .*/c\db_password = 123456" /etc/odoo18.conf +# Add addons_path if it doesn't exist, or replace it +if grep -q "^addons_path =" /etc/odoo18.conf; then + sudo sed -i "s|^addons_path = .*|addons_path = /opt/odoo18/addons,/opt/odoo18/odoo/addons|" /etc/odoo18.conf +else + echo "addons_path = /opt/odoo18/addons,/opt/odoo18/odoo/addons" | sudo tee -a /etc/odoo18.conf +fi +# Add logfile if it doesn't exist, or replace it +if grep -q "^logfile =" /etc/odoo18.conf; then + sudo sed -i "s|^logfile = .*|logfile = /var/log/odoo/odoo18.log|" /etc/odoo18.conf +else + echo "logfile = /var/log/odoo/odoo18.log" | sudo tee -a /etc/odoo18.conf +fi +# Add default_productivity_apps if it doesn't exist, or replace it +if grep -q "^default_productivity_apps =" /etc/odoo18.conf; then + sudo sed -i "s/^default_productivity_apps = .*/default_productivity_apps = True/" /etc/odoo18.conf +else + echo "default_productivity_apps = True" | sudo tee -a /etc/odoo18.conf +fi + +echo "Setting ownership and permissions for Odoo configuration file..." +sudo chown odoo18: /etc/odoo18.conf +sudo chmod 640 /etc/odoo18.conf +echo "Odoo configured successfully." + +# Step 9: Set Up Logging +echo "Step 9: Setting up logging..." +sudo mkdir -p /var/log/odoo +sudo chown odoo18:root /var/log/odoo +echo "Logging setup successfully." + +# Step 10: Create Systemd Service File +echo "Step 10: Creating Systemd service file..." +sudo tee /etc/systemd/system/odoo18.service <:8069" +echo " " +echo "Default Odoo admin password (master password for managing databases): admin" +echo "Default PostgreSQL user 'odoo18' password: '123456' (Change this!)" +echo "Odoo configuration file: /etc/odoo18.conf" +echo "Odoo log file: /var/log/odoo/odoo18.log" +echo "Odoo addons path: /opt/odoo18/addons, /opt/odoo18/odoo/addons" +echo "Odoo source code: /opt/odoo18" +echo "Odoo Python virtual environment: /opt/odoo18/venv" +echo "----------------------------------------------------------------" + +exit 0