From 0d9e39622650eac8853a49cc2dca7389141643ba Mon Sep 17 00:00:00 2001 From: afrizagilleon Date: Thu, 25 Jul 2024 11:53:18 +0700 Subject: [PATCH 1/5] Create Python virtual environment, activate it and install the requirements Odoo then deactivate it --- odoo_install.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/odoo_install.sh b/odoo_install.sh index 3bd0b90..6e63d81 100644 --- a/odoo_install.sh +++ b/odoo_install.sh @@ -100,9 +100,6 @@ echo -e "\n--- Installing Python 3 + pip3 --" sudo apt-get install python3 python3-pip sudo apt-get install git python3-cffi build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libpng-dev libjpeg-dev gdebi -y -echo -e "\n---- Install python packages/requirements ----" -sudo -H pip3 install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt - echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----" sudo apt-get install nodejs npm -y sudo npm install -g rtlcss @@ -140,6 +137,8 @@ sudo adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'ODOO' - #The user should also be added to the sudo'ers group. sudo adduser $OE_USER sudo + + echo -e "\n---- Create Log directory ----" sudo mkdir /var/log/$OE_USER sudo chown $OE_USER:$OE_USER /var/log/$OE_USER @@ -180,6 +179,18 @@ echo -e "\n---- Create custom module directory ----" sudo su $OE_USER -c "mkdir $OE_HOME/custom" sudo su $OE_USER -c "mkdir $OE_HOME/custom/addons" +#-------------------------------------------------- +# Install Dependencies of ODOO +#-------------------------------------------------- +echo -e "\n--- Installing Python 3 + pip3 --" +# Path to the virtual environment +venv_path="/$OE_HOME/$OE_USER-venv" +#Create a new Python virtual environment for Odoo +sudo su $OE_USER -c "python3 -m venv $venv_path" +# Activate the virtual environment using sudo +echo -e "\n---- Install python packages/requirements ----" +sudo -H -u "$OE_USER" bash -c "source $venv_path/bin/activate && pip3 install wheel && pip3 install -r $OE_HOME_EXT/requirements.txt && deactivate" + echo -e "\n---- Setting permissions on home folder ----" sudo chown -R $OE_USER:$OE_USER $OE_HOME/* From 342df17439797190ac6f5711f3a1ef46d093d3b8 Mon Sep 17 00:00:00 2001 From: afrizagilleon Date: Thu, 25 Jul 2024 11:57:09 +0700 Subject: [PATCH 2/5] Update Daemon Service Script --- odoo_install.sh | 89 ++++++++++++------------------------------------- 1 file changed, 21 insertions(+), 68 deletions(-) diff --git a/odoo_install.sh b/odoo_install.sh index 6e63d81..8328f78 100644 --- a/odoo_install.sh +++ b/odoo_install.sh @@ -230,76 +230,29 @@ sudo chmod 755 $OE_HOME_EXT/start.sh #-------------------------------------------------- echo -e "* Create init file" -cat < ~/$OE_CONFIG -#!/bin/sh -### BEGIN INIT INFO -# Provides: $OE_CONFIG -# Required-Start: \$remote_fs \$syslog -# Required-Stop: \$remote_fs \$syslog -# Should-Start: \$network -# Should-Stop: \$network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Enterprise Business Applications -# Description: ODOO Business Applications -### END INIT INFO -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin -DAEMON=$OE_HOME_EXT/odoo-bin -NAME=$OE_CONFIG -DESC=$OE_CONFIG -# Specify the user name (Default: odoo). -USER=$OE_USER -# Specify an alternate config file (Default: /etc/openerp-server.conf). -CONFIGFILE="/etc/${OE_CONFIG}.conf" -# pidfile -PIDFILE=/var/run/\${NAME}.pid -# Additional options that are passed to the Daemon. -DAEMON_OPTS="-c \$CONFIGFILE" -[ -x \$DAEMON ] || exit 0 -[ -f \$CONFIGFILE ] || exit 0 -checkpid() { -[ -f \$PIDFILE ] || return 1 -pid=\`cat \$PIDFILE\` -[ -d /proc/\$pid ] && return 0 -return 1 -} -case "\${1}" in -start) -echo -n "Starting \${DESC}: " -start-stop-daemon --start --quiet --pidfile \$PIDFILE \ ---chuid \$USER --background --make-pidfile \ ---exec \$DAEMON -- \$DAEMON_OPTS -echo "\${NAME}." -;; -stop) -echo -n "Stopping \${DESC}: " -start-stop-daemon --stop --quiet --pidfile \$PIDFILE \ ---oknodo -echo "\${NAME}." -;; -restart|force-reload) -echo -n "Restarting \${DESC}: " -start-stop-daemon --stop --quiet --pidfile \$PIDFILE \ ---oknodo -sleep 1 -start-stop-daemon --start --quiet --pidfile \$PIDFILE \ ---chuid \$USER --background --make-pidfile \ ---exec \$DAEMON -- \$DAEMON_OPTS -echo "\${NAME}." -;; -*) -N=/etc/init.d/\$NAME -echo "Usage: \$NAME {start|stop|restart|force-reload}" >&2 -exit 1 -;; -esac -exit 0 +cat < ~/$OE_USER.service +[Unit] +Description=$OE_USER +Requires=postgresql.service +After=network.target postgresql.service + +[Service] +Type=simple +SyslogIdentifier=$OE_USER +PermissionsStartOnly=true +User=$OE_USER +Group=$OE_USER +ExecStart=$OE_HOME/$OE_USER-venv/bin/python3 $OE_HOME/$OE_CONFIG/odoo-bin -c /etc/$OE_CONFIG.conf +StandardOutput=journal+console +Restart=always +RestartSec=5 + + +[Install] +WantedBy=multi-user.target EOF -echo -e "* Security Init File" -sudo mv ~/$OE_CONFIG /etc/init.d/$OE_CONFIG -sudo chmod 755 /etc/init.d/$OE_CONFIG -sudo chown root: /etc/init.d/$OE_CONFIG +sudo mv ~/$OE_USER.service /etc/systemd/system/$OE_USER.service echo -e "* Start ODOO on Startup" sudo update-rc.d $OE_CONFIG defaults From f3568e2cf567f7dc389d24b07975b2ece5918979 Mon Sep 17 00:00:00 2001 From: afrizagilleon Date: Thu, 25 Jul 2024 12:00:24 +0700 Subject: [PATCH 3/5] Restart daemon and enable system for OE_USER --- odoo_install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odoo_install.sh b/odoo_install.sh index 8328f78..91a409c 100644 --- a/odoo_install.sh +++ b/odoo_install.sh @@ -255,7 +255,9 @@ EOF sudo mv ~/$OE_USER.service /etc/systemd/system/$OE_USER.service echo -e "* Start ODOO on Startup" -sudo update-rc.d $OE_CONFIG defaults +sudo systemctl daemon-reload +# enable odoo +sudo systemctl enable --now $OE_USER #-------------------------------------------------- # Install Nginx if needed From 6e81ab03ed2d81a14d59bbcd57f478cc915a9ca1 Mon Sep 17 00:00:00 2001 From: afrizagilleon Date: Thu, 25 Jul 2024 12:09:57 +0700 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1fbafc8..bc5c2fb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you set the parameter ```INSTALL_NGINX``` to ```True``` you should also confi ##### 1. Download the script: ``` -sudo wget https://raw.githubusercontent.com/Yenthe666/InstallScript/17.0/odoo_install.sh +sudo wget https://raw.githubusercontent.com/afrizagilleon/OdooSetupServer/17.0/odoo_install.sh ``` ##### 2. Modify the parameters as you wish. There are a few things you can configure, this is the most used list:
From 438b975a9994f3f0b95d2f0c34e0c886683b3bec Mon Sep 17 00:00:00 2001 From: Afriza Gilleon Ginting <41586762+afrizagilleon@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:50:29 +0700 Subject: [PATCH 5/5] Update README.md change the "Download script" command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc5c2fb..2a5a485 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you set the parameter ```INSTALL_NGINX``` to ```True``` you should also confi ##### 1. Download the script: ``` -sudo wget https://raw.githubusercontent.com/afrizagilleon/OdooSetupServer/17.0/odoo_install.sh +sudo wget https://raw.githubusercontent.com/Yenthe666/InstallScript/16.0/odoo_install.sh ``` ##### 2. Modify the parameters as you wish. There are a few things you can configure, this is the most used list: