├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── odoo_install.sh
└── odoo_install_debian.sh
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: Yenthe666 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.swp
3 | *.tmp
4 | *.bak
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Yenthe V.G
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [Odoo](https://www.odoo.com "Odoo's Homepage") Install Script
2 |
3 | This script is based on the install script from André Schenkels (https://github.com/aschenkels-ictstudio/openerp-install-scripts)
4 | but goes a bit further and has been improved. This script will also give you the ability to define an xmlrpc_port in the .conf file that is generated under /etc/
5 | This script can be safely used in a multi-odoo code base server because the default Odoo port is changed BEFORE the Odoo is started.
6 |
7 | ## Installing Nginx
8 | If you set the parameter ```INSTALL_NGINX``` to ```True``` you should also configure workers. Without workers you will probably get connection loss issues. Look at [the deployment guide from Odoo](https://www.odoo.com/documentation/16.0/administration/install/deploy.html) on how to configure workers.
9 |
10 | ## Installation procedure
11 |
12 | ##### 1. Download the script:
13 | ```
14 | sudo wget https://raw.githubusercontent.com/Yenthe666/InstallScript/16.0/odoo_install.sh
15 | ```
16 | ##### 2. Modify the parameters as you wish.
17 | There are a few things you can configure, this is the most used list:
18 | ```OE_USER``` will be the username for the system user.
19 | ```GENERATE_RANDOM_PASSWORD``` if this is set to ```True``` the script will generate a random password, if set to ```False```we'll set the password that is configured in ```OE_SUPERADMIN```. By default the value is ```True``` and the script will generate a random and secure password.
20 | ```INSTALL_WKHTMLTOPDF``` set to ```False``` if you do not want to install Wkhtmltopdf, if you want to install it you should set it to ```True```.
21 | ```OE_PORT``` is the port where Odoo should run on, for example 8069.
22 | ```OE_VERSION``` is the Odoo version to install, for example ```16.0``` for Odoo V16.
23 | ```IS_ENTERPRISE``` will install the Enterprise version on top of ```16.0``` if you set it to ```True```, set it to ```False``` if you want the community version of Odoo 16.
24 | ```OE_SUPERADMIN``` is the master password for this Odoo installation.
25 | ```INSTALL_NGINX``` is set to ```False``` by default. Set this to ```True``` if you want to install Nginx.
26 | ```WEBSITE_NAME``` Set the website name here for nginx configuration
27 | ```ENABLE_SSL``` Set this to ```True``` to install [certbot](https://github.com/certbot/certbot) and configure nginx with https using a free Let's Encrypted certificate
28 | ```ADMIN_EMAIL``` Email is needed to register for Let's Encrypt registration. Replace the default placeholder with an email of your organisation.
29 | ```INSTALL_NGINX``` and ```ENABLE_SSL``` must be set to ```True``` and the placeholder in ```ADMIN_EMAIL``` must be replaced with a valid email address for certbot installation
30 | _By enabling SSL though Let's Encrypt you agree to the following [policies](https://www.eff.org/code/privacy/policy)_
31 |
32 | #### 3. Make the script executable
33 | ```
34 | sudo chmod +x odoo_install.sh
35 | ```
36 | ##### 4. Execute the script:
37 | ```
38 | sudo ./odoo_install.sh
39 | ```
40 |
41 | ## Where should I host Odoo?
42 | There are plenty of great services that offer good hosting. The script has been tested with a few major players such as [Google Cloud](https://cloud.google.com/), [Hetzner](https://www.hetzner.com/), [Amazon AWS](https://aws.amazon.com/) and [DigitalOcean](https://www.digitalocean.com/products/droplets/).
43 | If you'd like you can use my [DigitalOcean referral link](https://m.do.co/c/d605cc420682) which gives you a 200$ voucher for free for the first 60 days.
44 |
45 | ## Minimal server requirements
46 | While technically you can run an Odoo instance on 1GB (1024MB) of RAM it is absolutely not advised. A Linux instance typically uses 300MB-500MB and the rest has to be split among Odoo, postgreSQL and others. If you install an Odoo you should make sure to use at least 2GB of RAM. This script might fail with less resources too.
47 | There are known issues on DigitalOcean for example where the installation crashes on 1GB RAM machines. See https://github.com/Yenthe666/InstallScript/issues/243
48 |
49 |
--------------------------------------------------------------------------------
/odoo_install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | # Script for installing Odoo on Ubuntu 16.04, 18.04, 20.04 and 22.04 (could be used for other version too)
4 | # Author: Yenthe Van Ginneken
5 | #-------------------------------------------------------------------------------
6 | # This script will install Odoo on your Ubuntu server. It can install multiple Odoo instances
7 | # in one Ubuntu because of the different xmlrpc_ports
8 | #-------------------------------------------------------------------------------
9 | # Make a new file:
10 | # sudo nano odoo-install.sh
11 | # Place this content in it and then make the file executable:
12 | # sudo chmod +x odoo-install.sh
13 | # Execute the script to install Odoo:
14 | # ./odoo-install
15 | ################################################################################
16 |
17 | OE_USER="odoo"
18 | OE_HOME="/$OE_USER"
19 | OE_HOME_EXT="/$OE_USER/${OE_USER}-server"
20 | # The default port where this Odoo instance will run under (provided you use the command -c in the terminal)
21 | # Set to true if you want to install it, false if you don't need it or have it already installed.
22 | INSTALL_WKHTMLTOPDF="True"
23 | # Set the default Odoo port (you still have to use -c /etc/odoo-server.conf for example to use this.)
24 | OE_PORT="8069"
25 | # Choose the Odoo version which you want to install. For example: 16.0, 15.0, 14.0 or saas-22. When using 'master' the master version will be installed.
26 | # IMPORTANT! This script contains extra libraries that are specifically needed for Odoo 16.0
27 | OE_VERSION="16.0"
28 | # Set this to True if you want to install the Odoo enterprise version!
29 | IS_ENTERPRISE="False"
30 | # Installs postgreSQL V14 instead of defaults (e.g V12 for Ubuntu 20/22) - this improves performance
31 | INSTALL_POSTGRESQL_FOURTEEN="True"
32 | # Set this to True if you want to install Nginx!
33 | INSTALL_NGINX="False"
34 | # Set the superadmin password - if GENERATE_RANDOM_PASSWORD is set to "True" we will automatically generate a random password, otherwise we use this one
35 | OE_SUPERADMIN="admin"
36 | # Set to "True" to generate a random password, "False" to use the variable in OE_SUPERADMIN
37 | GENERATE_RANDOM_PASSWORD="True"
38 | OE_CONFIG="${OE_USER}-server"
39 | # Set the website name
40 | WEBSITE_NAME="_"
41 | # Set the default Odoo longpolling port (you still have to use -c /etc/odoo-server.conf for example to use this.)
42 | LONGPOLLING_PORT="8072"
43 | # Set to "True" to install certbot and have ssl enabled, "False" to use http
44 | ENABLE_SSL="True"
45 | # Provide Email to register ssl certificate
46 | ADMIN_EMAIL="odoo@example.com"
47 | ##
48 | ### WKHTMLTOPDF download links
49 | ## === Ubuntu Trusty x64 & x32 === (for other distributions please replace these two links,
50 | ## in order to have correct version of wkhtmltopdf installed, for a danger note refer to
51 | ## https://github.com/odoo/odoo/wiki/Wkhtmltopdf ):
52 | ## https://www.odoo.com/documentation/16.0/administration/install.html
53 |
54 | # Check if the operating system is Ubuntu 22.04
55 | if [[ $(lsb_release -r -s) == "22.04" ]]; then
56 | WKHTMLTOX_X64="https://packages.ubuntu.com/jammy/wkhtmltopdf"
57 | WKHTMLTOX_X32="https://packages.ubuntu.com/jammy/wkhtmltopdf"
58 | #No Same link works for both 64 and 32-bit on Ubuntu 22.04
59 | else
60 | # For older versions of Ubuntu
61 | WKHTMLTOX_X64="https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.$(lsb_release -c -s)_amd64.deb"
62 | WKHTMLTOX_X32="https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.$(lsb_release -c -s)_i386.deb"
63 | fi
64 |
65 | #--------------------------------------------------
66 | # Update Server
67 | #--------------------------------------------------
68 | echo -e "\n---- Update Server ----"
69 | # universe package is for Ubuntu 18.x
70 | sudo add-apt-repository universe
71 | # libpng12-0 dependency for wkhtmltopdf for older Ubuntu versions
72 | sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu/ xenial main"
73 | sudo apt-get update
74 | sudo apt-get upgrade -y
75 | sudo apt-get install libpq-dev
76 |
77 | #--------------------------------------------------
78 | # Install PostgreSQL Server
79 | #--------------------------------------------------
80 | echo -e "\n---- Install PostgreSQL Server ----"
81 | if [ $INSTALL_POSTGRESQL_FOURTEEN = "True" ]; then
82 | echo -e "\n---- Installing postgreSQL V14 due to the user it's choise ----"
83 | sudo curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
84 | sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
85 | sudo apt-get update
86 | sudo apt-get install postgresql-14
87 | else
88 | echo -e "\n---- Installing the default postgreSQL version based on Linux version ----"
89 | sudo apt-get install postgresql postgresql-server-dev-all -y
90 | fi
91 |
92 |
93 | echo -e "\n---- Creating the ODOO PostgreSQL User ----"
94 | sudo su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true
95 |
96 | #--------------------------------------------------
97 | # Install Dependencies
98 | #--------------------------------------------------
99 | echo -e "\n--- Installing Python 3 + pip3 --"
100 | sudo apt-get install python3 python3-pip
101 | 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
102 |
103 | echo -e "\n---- Install python packages/requirements ----"
104 | sudo -H pip3 install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt
105 |
106 | echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
107 | sudo apt-get install nodejs npm -y
108 | sudo npm install -g rtlcss
109 |
110 | #--------------------------------------------------
111 | # Install Wkhtmltopdf if needed
112 | #--------------------------------------------------
113 | if [ $INSTALL_WKHTMLTOPDF = "True" ]; then
114 | echo -e "\n---- Install wkhtml and place shortcuts on correct place for ODOO 13 ----"
115 | #pick up correct one from x64 & x32 versions:
116 | if [ "`getconf LONG_BIT`" == "64" ];then
117 | _url=$WKHTMLTOX_X64
118 | else
119 | _url=$WKHTMLTOX_X32
120 | fi
121 | sudo wget $_url
122 |
123 |
124 | if [[ $(lsb_release -r -s) == "22.04" ]]; then
125 | # Ubuntu 22.04 LTS
126 | sudo apt install wkhtmltopdf -y
127 | else
128 | # For older versions of Ubuntu
129 | sudo gdebi --n `basename $_url`
130 | fi
131 |
132 | sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
133 | sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
134 | else
135 | echo "Wkhtmltopdf isn't installed due to the choice of the user!"
136 | fi
137 |
138 | echo -e "\n---- Create ODOO system user ----"
139 | sudo adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'ODOO' --group $OE_USER
140 | #The user should also be added to the sudo'ers group.
141 | sudo adduser $OE_USER sudo
142 |
143 | echo -e "\n---- Create Log directory ----"
144 | sudo mkdir /var/log/$OE_USER
145 | sudo chown $OE_USER:$OE_USER /var/log/$OE_USER
146 |
147 | #--------------------------------------------------
148 | # Install ODOO
149 | #--------------------------------------------------
150 | echo -e "\n==== Installing ODOO Server ===="
151 | sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/
152 |
153 | if [ $IS_ENTERPRISE = "True" ]; then
154 | # Odoo Enterprise install!
155 | sudo pip3 install psycopg2-binary pdfminer.six
156 | echo -e "\n--- Create symlink for node"
157 | sudo ln -s /usr/bin/nodejs /usr/bin/node
158 | sudo su $OE_USER -c "mkdir $OE_HOME/enterprise"
159 | sudo su $OE_USER -c "mkdir $OE_HOME/enterprise/addons"
160 |
161 | GITHUB_RESPONSE=$(sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
162 | while [[ $GITHUB_RESPONSE == *"Authentication"* ]]; do
163 | echo "------------------------WARNING------------------------------"
164 | echo "Your authentication with Github has failed! Please try again."
165 | printf "In order to clone and install the Odoo enterprise version you \nneed to be an offical Odoo partner and you need access to\nhttp://github.com/odoo/enterprise.\n"
166 | echo "TIP: Press ctrl+c to stop this script."
167 | echo "-------------------------------------------------------------"
168 | echo " "
169 | GITHUB_RESPONSE=$(sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
170 | done
171 |
172 | echo -e "\n---- Added Enterprise code under $OE_HOME/enterprise/addons ----"
173 | echo -e "\n---- Installing Enterprise specific libraries ----"
174 | sudo -H pip3 install num2words ofxparse dbfread ebaysdk firebase_admin pyOpenSSL
175 | sudo npm install -g less
176 | sudo npm install -g less-plugin-clean-css
177 | fi
178 |
179 | echo -e "\n---- Create custom module directory ----"
180 | sudo su $OE_USER -c "mkdir $OE_HOME/custom"
181 | sudo su $OE_USER -c "mkdir $OE_HOME/custom/addons"
182 |
183 | echo -e "\n---- Setting permissions on home folder ----"
184 | sudo chown -R $OE_USER:$OE_USER $OE_HOME/*
185 |
186 | echo -e "* Create server config file"
187 |
188 |
189 | sudo touch /etc/${OE_CONFIG}.conf
190 | echo -e "* Creating server config file"
191 | sudo su root -c "printf '[options] \n; This is the password that allows database operations:\n' >> /etc/${OE_CONFIG}.conf"
192 | if [ $GENERATE_RANDOM_PASSWORD = "True" ]; then
193 | echo -e "* Generating random admin password"
194 | OE_SUPERADMIN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
195 | fi
196 | sudo su root -c "printf 'admin_passwd = ${OE_SUPERADMIN}\n' >> /etc/${OE_CONFIG}.conf"
197 | if [ $OE_VERSION > "11.0" ];then
198 | sudo su root -c "printf 'http_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf"
199 | else
200 | sudo su root -c "printf 'xmlrpc_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf"
201 | fi
202 | sudo su root -c "printf 'logfile = /var/log/${OE_USER}/${OE_CONFIG}.log\n' >> /etc/${OE_CONFIG}.conf"
203 |
204 | if [ $IS_ENTERPRISE = "True" ]; then
205 | sudo su root -c "printf 'addons_path=${OE_HOME}/enterprise/addons,${OE_HOME_EXT}/addons\n' >> /etc/${OE_CONFIG}.conf"
206 | else
207 | sudo su root -c "printf 'addons_path=${OE_HOME_EXT}/addons,${OE_HOME}/custom/addons\n' >> /etc/${OE_CONFIG}.conf"
208 | fi
209 | sudo chown $OE_USER:$OE_USER /etc/${OE_CONFIG}.conf
210 | sudo chmod 640 /etc/${OE_CONFIG}.conf
211 |
212 | echo -e "* Create startup file"
213 | sudo su root -c "echo '#!/bin/sh' >> $OE_HOME_EXT/start.sh"
214 | sudo su root -c "echo 'sudo -u $OE_USER $OE_HOME_EXT/odoo-bin --config=/etc/${OE_CONFIG}.conf' >> $OE_HOME_EXT/start.sh"
215 | sudo chmod 755 $OE_HOME_EXT/start.sh
216 |
217 | #--------------------------------------------------
218 | # Adding ODOO as a deamon (initscript)
219 | #--------------------------------------------------
220 |
221 | echo -e "* Create init file"
222 | cat < ~/$OE_CONFIG
223 | #!/bin/sh
224 | ### BEGIN INIT INFO
225 | # Provides: $OE_CONFIG
226 | # Required-Start: \$remote_fs \$syslog
227 | # Required-Stop: \$remote_fs \$syslog
228 | # Should-Start: \$network
229 | # Should-Stop: \$network
230 | # Default-Start: 2 3 4 5
231 | # Default-Stop: 0 1 6
232 | # Short-Description: Enterprise Business Applications
233 | # Description: ODOO Business Applications
234 | ### END INIT INFO
235 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
236 | DAEMON=$OE_HOME_EXT/odoo-bin
237 | NAME=$OE_CONFIG
238 | DESC=$OE_CONFIG
239 | # Specify the user name (Default: odoo).
240 | USER=$OE_USER
241 | # Specify an alternate config file (Default: /etc/openerp-server.conf).
242 | CONFIGFILE="/etc/${OE_CONFIG}.conf"
243 | # pidfile
244 | PIDFILE=/var/run/\${NAME}.pid
245 | # Additional options that are passed to the Daemon.
246 | DAEMON_OPTS="-c \$CONFIGFILE"
247 | [ -x \$DAEMON ] || exit 0
248 | [ -f \$CONFIGFILE ] || exit 0
249 | checkpid() {
250 | [ -f \$PIDFILE ] || return 1
251 | pid=\`cat \$PIDFILE\`
252 | [ -d /proc/\$pid ] && return 0
253 | return 1
254 | }
255 | case "\${1}" in
256 | start)
257 | echo -n "Starting \${DESC}: "
258 | start-stop-daemon --start --quiet --pidfile \$PIDFILE \
259 | --chuid \$USER --background --make-pidfile \
260 | --exec \$DAEMON -- \$DAEMON_OPTS
261 | echo "\${NAME}."
262 | ;;
263 | stop)
264 | echo -n "Stopping \${DESC}: "
265 | start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
266 | --oknodo
267 | echo "\${NAME}."
268 | ;;
269 | restart|force-reload)
270 | echo -n "Restarting \${DESC}: "
271 | start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
272 | --oknodo
273 | sleep 1
274 | start-stop-daemon --start --quiet --pidfile \$PIDFILE \
275 | --chuid \$USER --background --make-pidfile \
276 | --exec \$DAEMON -- \$DAEMON_OPTS
277 | echo "\${NAME}."
278 | ;;
279 | *)
280 | N=/etc/init.d/\$NAME
281 | echo "Usage: \$NAME {start|stop|restart|force-reload}" >&2
282 | exit 1
283 | ;;
284 | esac
285 | exit 0
286 | EOF
287 |
288 | echo -e "* Security Init File"
289 | sudo mv ~/$OE_CONFIG /etc/init.d/$OE_CONFIG
290 | sudo chmod 755 /etc/init.d/$OE_CONFIG
291 | sudo chown root: /etc/init.d/$OE_CONFIG
292 |
293 | echo -e "* Start ODOO on Startup"
294 | sudo update-rc.d $OE_CONFIG defaults
295 |
296 | #--------------------------------------------------
297 | # Install Nginx if needed
298 | #--------------------------------------------------
299 | if [ $INSTALL_NGINX = "True" ]; then
300 | echo -e "\n---- Installing and setting up Nginx ----"
301 | sudo apt install nginx -y
302 | cat < ~/odoo
303 | server {
304 | listen 80;
305 |
306 | # set proper server name after domain set
307 | server_name $WEBSITE_NAME;
308 |
309 | # Add Headers for odoo proxy mode
310 | proxy_set_header X-Forwarded-Host \$host;
311 | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
312 | proxy_set_header X-Forwarded-Proto \$scheme;
313 | proxy_set_header X-Real-IP \$remote_addr;
314 | add_header X-Frame-Options "SAMEORIGIN";
315 | add_header X-XSS-Protection "1; mode=block";
316 | proxy_set_header X-Client-IP \$remote_addr;
317 | proxy_set_header HTTP_X_FORWARDED_HOST \$remote_addr;
318 |
319 | # odoo log files
320 | access_log /var/log/nginx/$OE_USER-access.log;
321 | error_log /var/log/nginx/$OE_USER-error.log;
322 |
323 | # increase proxy buffer size
324 | proxy_buffers 16 64k;
325 | proxy_buffer_size 128k;
326 |
327 | proxy_read_timeout 900s;
328 | proxy_connect_timeout 900s;
329 | proxy_send_timeout 900s;
330 |
331 | # force timeouts if the backend dies
332 | proxy_next_upstream error timeout invalid_header http_500 http_502
333 | http_503;
334 |
335 | types {
336 | text/less less;
337 | text/scss scss;
338 | }
339 |
340 | # enable data compression
341 | gzip on;
342 | gzip_min_length 1100;
343 | gzip_buffers 4 32k;
344 | gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png;
345 | gzip_vary on;
346 | client_header_buffer_size 4k;
347 | large_client_header_buffers 4 64k;
348 | client_max_body_size 0;
349 |
350 | location / {
351 | proxy_pass http://127.0.0.1:$OE_PORT;
352 | # by default, do not forward anything
353 | proxy_redirect off;
354 | }
355 |
356 | location /longpolling {
357 | proxy_pass http://127.0.0.1:$LONGPOLLING_PORT;
358 | }
359 |
360 | location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
361 | expires 2d;
362 | proxy_pass http://127.0.0.1:$OE_PORT;
363 | add_header Cache-Control "public, no-transform";
364 | }
365 |
366 | # cache some static data in memory for 60mins.
367 | location ~ /[a-zA-Z0-9_-]*/static/ {
368 | proxy_cache_valid 200 302 60m;
369 | proxy_cache_valid 404 1m;
370 | proxy_buffering on;
371 | expires 864000;
372 | proxy_pass http://127.0.0.1:$OE_PORT;
373 | }
374 | }
375 | EOF
376 |
377 | sudo mv ~/odoo /etc/nginx/sites-available/$WEBSITE_NAME
378 | sudo ln -s /etc/nginx/sites-available/$WEBSITE_NAME /etc/nginx/sites-enabled/$WEBSITE_NAME
379 | sudo rm /etc/nginx/sites-enabled/default
380 | sudo service nginx reload
381 | sudo su root -c "printf 'proxy_mode = True\n' >> /etc/${OE_CONFIG}.conf"
382 | echo "Done! The Nginx server is up and running. Configuration can be found at /etc/nginx/sites-available/$WEBSITE_NAME"
383 | else
384 | echo "Nginx isn't installed due to choice of the user!"
385 | fi
386 |
387 | #--------------------------------------------------
388 | # Enable ssl with certbot
389 | #--------------------------------------------------
390 |
391 | if [ $INSTALL_NGINX = "True" ] && [ $ENABLE_SSL = "True" ] && [ $ADMIN_EMAIL != "odoo@example.com" ] && [ $WEBSITE_NAME != "_" ];then
392 | sudo apt-get update -y
393 | sudo apt install snapd -y
394 | sudo snap install core; snap refresh core
395 | sudo snap install --classic certbot
396 | sudo apt-get install python3-certbot-nginx -y
397 | sudo certbot --nginx -d $WEBSITE_NAME --noninteractive --agree-tos --email $ADMIN_EMAIL --redirect
398 | sudo service nginx reload
399 | echo "SSL/HTTPS is enabled!"
400 | else
401 | echo "SSL/HTTPS isn't enabled due to choice of the user or because of a misconfiguration!"
402 | if $ADMIN_EMAIL = "odoo@example.com";then
403 | echo "Certbot does not support registering odoo@example.com. You should use real e-mail address."
404 | fi
405 | if $WEBSITE_NAME = "_";then
406 | echo "Website name is set as _. Cannot obtain SSL Certificate for _. You should use real website address."
407 | fi
408 | fi
409 |
410 | echo -e "* Starting Odoo Service"
411 | sudo su root -c "/etc/init.d/$OE_CONFIG start"
412 | echo "-----------------------------------------------------------"
413 | echo "Done! The Odoo server is up and running. Specifications:"
414 | echo "Port: $OE_PORT"
415 | echo "User service: $OE_USER"
416 | echo "Configuraton file location: /etc/${OE_CONFIG}.conf"
417 | echo "Logfile location: /var/log/$OE_USER"
418 | echo "User PostgreSQL: $OE_USER"
419 | echo "Code location: $OE_USER"
420 | echo "Addons folder: $OE_USER/$OE_CONFIG/addons/"
421 | echo "Password superadmin (database): $OE_SUPERADMIN"
422 | echo "Start Odoo service: sudo service $OE_CONFIG start"
423 | echo "Stop Odoo service: sudo service $OE_CONFIG stop"
424 | echo "Restart Odoo service: sudo service $OE_CONFIG restart"
425 | if [ $INSTALL_NGINX = "True" ]; then
426 | echo "Nginx configuration file: /etc/nginx/sites-available/$WEBSITE_NAME"
427 | fi
428 | echo "-----------------------------------------------------------"
429 |
--------------------------------------------------------------------------------
/odoo_install_debian.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | # Script for installing Odoo on Debian 10.0 (could be used for other version too)
4 | # Authors: Yenthe Van Ginneken, César Cordero Rodríguez
5 | # Maintainers: Yenthe Van Ginneken, César Cordero Rodríguez
6 | #-------------------------------------------------------------------------------
7 | # This script will install Odoo on your Debian 10.0 server. It can install multiple Odoo instances
8 | # in one Debian because of the different xmlrpc_ports
9 | #-------------------------------------------------------------------------------
10 | # Make a new file:
11 | # sudo nano odoo-install.sh
12 | # Place this content in it and then make the file executable:
13 | # sudo chmod +x odoo-install.sh
14 | # Execute the script to install Odoo:
15 | # ./odoo-install
16 | ################################################################################
17 |
18 | OE_USER="odoo"
19 | OE_HOME="/$OE_USER"
20 | OE_HOME_EXT="/$OE_USER/${OE_USER}-server"
21 | # The default port where this Odoo instance will run under (provided you use the command -c in the terminal)
22 | # Set to true if you want to install it, false if you don't need it or have it already installed.
23 | INSTALL_WKHTMLTOPDF="True"
24 | # Set the default Odoo port (you still have to use -c /etc/odoo-server.conf for example to use this.)
25 | OE_PORT="8069"
26 | # Choose the Odoo version which you want to install. For example: 13.0, 12.0, 11.0 or saas-18. When using 'master' the master version will be installed.
27 | # IMPORTANT! This script contains extra libraries that are specifically needed for Odoo 13.0
28 | OE_VERSION="14.0"
29 | # Set this to True if you want to install the Odoo enterprise version!
30 | IS_ENTERPRISE="False"
31 | # Set this to True if you want to install Nginx!
32 | INSTALL_NGINX="False"
33 | # Set the superadmin password - if GENERATE_RANDOM_PASSWORD is set to "True" we will automatically generate a random password, otherwise we use this one
34 | OE_SUPERADMIN="admin"
35 | # Set to "True" to generate a random password, "False" to use the variable in OE_SUPERADMIN
36 | GENERATE_RANDOM_PASSWORD="True"
37 | OE_CONFIG="${OE_USER}-server"
38 | # Set the website name
39 | WEBSITE_NAME="_"
40 | # Set the default Odoo longpolling port (you still have to use -c /etc/odoo-server.conf for example to use this.)
41 | LONGPOLLING_PORT="8072"
42 |
43 | ##
44 | ### WKHTMLTOPDF download links
45 | ## === Debian Buster x64 & x32 === (for other distributions please replace these two links,
46 | ## in order to have correct version of wkhtmltopdf installed, for a danger note refer to
47 | ## https://github.com/odoo/odoo/wiki/Wkhtmltopdf ):
48 | ## https://www.odoo.com/documentation/12.0/setup/install.html#debian-ubuntu
49 |
50 | WKHTMLTOX_X64=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb
51 | WKHTMLTOX_X32=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_i386.deb
52 | #--------------------------------------------------
53 | # Update Server
54 | #--------------------------------------------------
55 | echo -e "\n---- Update Server ----"
56 | sudo apt-get update
57 | sudo apt-get upgrade -y
58 |
59 | #--------------------------------------------------
60 | # Install PostgreSQL Server
61 | #--------------------------------------------------
62 | echo -e "\n---- Install PostgreSQL Server ----"
63 | sudo apt-get install postgresql -y
64 |
65 | echo -e "\n---- Creating the ODOO PostgreSQL User ----"
66 | sudo su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true
67 |
68 | #--------------------------------------------------
69 | # Install Dependencies
70 | #--------------------------------------------------
71 | echo -e "\n--- Installing Python 3 + pip3 --"
72 | sudo apt-get install git python3 python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt1-dev -y
73 | sudo apt-get install libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less gdebi -y
74 |
75 | echo -e "\n---- Install python packages/requirements ----"
76 | sudo pip3 install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt
77 |
78 | echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
79 | sudo apt-get install nodejs npm -y
80 | sudo npm install -g rtlcss
81 |
82 | #--------------------------------------------------
83 | # Install Wkhtmltopdf if needed
84 | #--------------------------------------------------
85 | if [ $INSTALL_WKHTMLTOPDF = "True" ]; then
86 | echo -e "\n---- Install wkhtml and place shortcuts on correct place for ODOO 13 ----"
87 | #pick up correct one from x64 & x32 versions:
88 | if [ "`getconf LONG_BIT`" == "64" ];then
89 | _url=$WKHTMLTOX_X64
90 | else
91 | _url=$WKHTMLTOX_X32
92 | fi
93 | sudo wget $_url
94 | sudo gdebi --n `basename $_url`
95 | sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
96 | sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
97 | else
98 | echo "Wkhtmltopdf isn't installed due to the choice of the user!"
99 | fi
100 |
101 | echo -e "\n---- Create ODOO system user ----"
102 | sudo adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'ODOO' --group $OE_USER
103 | #The user should also be added to the sudo'ers group.
104 | sudo adduser $OE_USER sudo
105 |
106 | echo -e "\n---- Create Log directory ----"
107 | sudo mkdir /var/log/$OE_USER
108 | sudo chown $OE_USER:$OE_USER /var/log/$OE_USER
109 |
110 | #--------------------------------------------------
111 | # Install ODOO
112 | #--------------------------------------------------
113 | echo -e "\n==== Installing ODOO Server ===="
114 | sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/
115 |
116 | if [ $IS_ENTERPRISE = "True" ]; then
117 | # Odoo Enterprise install!
118 | echo -e "\n--- Create symlink for node"
119 | sudo ln -s /usr/bin/nodejs /usr/bin/node
120 | sudo su $OE_USER -c "mkdir $OE_HOME/enterprise"
121 | sudo su $OE_USER -c "mkdir $OE_HOME/enterprise/addons"
122 |
123 | GITHUB_RESPONSE=$(sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
124 | while [[ $GITHUB_RESPONSE == *"Authentication"* ]]; do
125 | echo "------------------------WARNING------------------------------"
126 | echo "Your authentication with Github has failed! Please try again."
127 | printf "In order to clone and install the Odoo enterprise version you \nneed to be an offical Odoo partner and you need access to\nhttp://github.com/odoo/enterprise.\n"
128 | echo "TIP: Press ctrl+c to stop this script."
129 | echo "-------------------------------------------------------------"
130 | echo " "
131 | GITHUB_RESPONSE=$(sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
132 | done
133 |
134 | echo -e "\n---- Added Enterprise code under $OE_HOME/enterprise/addons ----"
135 | echo -e "\n---- Installing Enterprise specific libraries ----"
136 | sudo pip3 install num2words ofxparse dbfread ebaysdk firebase_admin pyOpenSSL
137 | sudo npm install -g less
138 | sudo npm install -g less-plugin-clean-css
139 | fi
140 |
141 | echo -e "\n---- Create custom module directory ----"
142 | sudo su $OE_USER -c "mkdir $OE_HOME/custom"
143 | sudo su $OE_USER -c "mkdir $OE_HOME/custom/addons"
144 |
145 | echo -e "\n---- Setting permissions on home folder ----"
146 | sudo chown -R $OE_USER:$OE_USER $OE_HOME/*
147 |
148 | echo -e "* Create server config file"
149 |
150 |
151 | sudo touch /etc/${OE_CONFIG}.conf
152 | echo -e "* Creating server config file"
153 | sudo su root -c "printf '[options] \n; This is the password that allows database operations:\n' >> /etc/${OE_CONFIG}.conf"
154 | if [ $GENERATE_RANDOM_PASSWORD = "True" ]; then
155 | echo -e "* Generating random admin password"
156 | OE_SUPERADMIN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
157 | fi
158 | sudo su root -c "printf 'admin_passwd = ${OE_SUPERADMIN}\n' >> /etc/${OE_CONFIG}.conf"
159 | if [ $OE_VERSION >= "12.0" ]; then
160 | sudo su root -c "printf 'http_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf"
161 | else
162 | sudo su root -c "printf 'xmlrpc_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf"
163 | fi
164 | sudo su root -c "printf 'logfile = /var/log/${OE_USER}/${OE_CONFIG}.log\n' >> /etc/${OE_CONFIG}.conf"
165 |
166 | if [ $IS_ENTERPRISE = "True" ]; then
167 | sudo su root -c "printf 'addons_path=${OE_HOME}/enterprise/addons,${OE_HOME_EXT}/addons\n' >> /etc/${OE_CONFIG}.conf"
168 | else
169 | sudo su root -c "printf 'addons_path=${OE_HOME_EXT}/addons,${OE_HOME}/custom/addons\n' >> /etc/${OE_CONFIG}.conf"
170 | fi
171 | sudo chown $OE_USER:$OE_USER /etc/${OE_CONFIG}.conf
172 | sudo chmod 640 /etc/${OE_CONFIG}.conf
173 |
174 | echo -e "* Create startup file"
175 | sudo su root -c "echo '#!/bin/sh' >> $OE_HOME_EXT/start.sh"
176 | sudo su root -c "echo 'sudo -u $OE_USER $OE_HOME_EXT/odoo-bin --config=/etc/${OE_CONFIG}.conf' >> $OE_HOME_EXT/start.sh"
177 | sudo chmod 755 $OE_HOME_EXT/start.sh
178 |
179 | #--------------------------------------------------
180 | # Adding ODOO as a deamon (initscript)
181 | #--------------------------------------------------
182 |
183 | echo -e "* Create init file"
184 | cat < ~/$OE_CONFIG
185 | #!/bin/sh
186 | ### BEGIN INIT INFO
187 | # Provides: $OE_CONFIG
188 | # Required-Start: \$remote_fs \$syslog
189 | # Required-Stop: \$remote_fs \$syslog
190 | # Should-Start: \$network
191 | # Should-Stop: \$network
192 | # Default-Start: 2 3 4 5
193 | # Default-Stop: 0 1 6
194 | # Short-Description: Enterprise Business Applications
195 | # Description: ODOO Business Applications
196 | ### END INIT INFO
197 | PATH=/bin:/sbin:/usr/bin
198 | DAEMON=$OE_HOME_EXT/odoo-bin
199 | NAME=$OE_CONFIG
200 | DESC=$OE_CONFIG
201 | # Specify the user name (Default: odoo).
202 | USER=$OE_USER
203 | # Specify an alternate config file (Default: /etc/openerp-server.conf).
204 | CONFIGFILE="/etc/${OE_CONFIG}.conf"
205 | # pidfile
206 | PIDFILE=/var/run/\${NAME}.pid
207 | # Additional options that are passed to the Daemon.
208 | DAEMON_OPTS="-c \$CONFIGFILE"
209 | [ -x \$DAEMON ] || exit 0
210 | [ -f \$CONFIGFILE ] || exit 0
211 | checkpid() {
212 | [ -f \$PIDFILE ] || return 1
213 | pid=\`cat \$PIDFILE\`
214 | [ -d /proc/\$pid ] && return 0
215 | return 1
216 | }
217 | case "\${1}" in
218 | start)
219 | echo -n "Starting \${DESC}: "
220 | start-stop-daemon --start --quiet --pidfile \$PIDFILE \
221 | --chuid \$USER --background --make-pidfile \
222 | --exec \$DAEMON -- \$DAEMON_OPTS
223 | echo "\${NAME}."
224 | ;;
225 | stop)
226 | echo -n "Stopping \${DESC}: "
227 | start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
228 | --oknodo
229 | echo "\${NAME}."
230 | ;;
231 | restart|force-reload)
232 | echo -n "Restarting \${DESC}: "
233 | start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
234 | --oknodo
235 | sleep 1
236 | start-stop-daemon --start --quiet --pidfile \$PIDFILE \
237 | --chuid \$USER --background --make-pidfile \
238 | --exec \$DAEMON -- \$DAEMON_OPTS
239 | echo "\${NAME}."
240 | ;;
241 | *)
242 | N=/etc/init.d/\$NAME
243 | echo "Usage: \$NAME {start|stop|restart|force-reload}" >&2
244 | exit 1
245 | ;;
246 | esac
247 | exit 0
248 | EOF
249 |
250 | echo -e "* Security Init File"
251 | sudo mv ~/$OE_CONFIG /etc/init.d/$OE_CONFIG
252 | sudo chmod 755 /etc/init.d/$OE_CONFIG
253 | sudo chown root: /etc/init.d/$OE_CONFIG
254 |
255 | echo -e "* Start ODOO on Startup"
256 | sudo update-rc.d $OE_CONFIG defaults
257 |
258 | #--------------------------------------------------
259 | # Install Nginx if needed
260 | #--------------------------------------------------
261 | if [ $INSTALL_NGINX = "True" ]; then
262 | echo -e "\n---- Installing and setting up Nginx ----"
263 | sudo apt install nginx -y
264 | cat < ~/odoo
265 | server {
266 | listen 80;
267 |
268 | # set proper server name after domain set
269 | server_name $WEBSITE_NAME;
270 |
271 | # Add Headers for odoo proxy mode
272 | proxy_set_header X-Forwarded-Host \$host;
273 | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
274 | proxy_set_header X-Forwarded-Proto \$scheme;
275 | proxy_set_header X-Real-IP \$remote_addr;
276 | add_header X-Frame-Options "SAMEORIGIN";
277 | add_header X-XSS-Protection "1; mode=block";
278 | proxy_set_header X-Client-IP \$remote_addr;
279 | proxy_set_header HTTP_X_FORWARDED_HOST \$remote_addr;
280 |
281 | # odoo log files
282 | access_log /var/log/nginx/$OE_USER-access.log;
283 | error_log /var/log/nginx/$OE_USER-error.log;
284 |
285 | # increase proxy buffer size
286 | proxy_buffers 16 64k;
287 | proxy_buffer_size 128k;
288 |
289 | proxy_read_timeout 900s;
290 | proxy_connect_timeout 900s;
291 | proxy_send_timeout 900s;
292 |
293 | # force timeouts if the backend dies
294 | proxy_next_upstream error timeout invalid_header http_500 http_502
295 | http_503;
296 |
297 | types {
298 | text/less less;
299 | text/scss scss;
300 | }
301 |
302 | # enable data compression
303 | gzip on;
304 | gzip_min_length 1100;
305 | gzip_buffers 4 32k;
306 | gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png;
307 | gzip_vary on;
308 | client_header_buffer_size 4k;
309 | large_client_header_buffers 4 64k;
310 | client_max_body_size 0;
311 |
312 | location / {
313 | proxy_pass http://127.0.0.1:$OE_PORT;
314 | # by default, do not forward anything
315 | proxy_redirect off;
316 | }
317 |
318 | location /longpolling {
319 | proxy_pass http://127.0.0.1:$LONGPOLLING_PORT;
320 | }
321 | location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
322 | expires 2d;
323 | proxy_pass http://127.0.0.1:$OE_PORT;
324 | add_header Cache-Control "public, no-transform";
325 | }
326 | # cache some static data in memory for 60mins.
327 | location ~ /[a-zA-Z0-9_-]*/static/ {
328 | proxy_cache_valid 200 302 60m;
329 | proxy_cache_valid 404 1m;
330 | proxy_buffering on;
331 | expires 864000;
332 | proxy_pass http://127.0.0.1:$OE_PORT;
333 | }
334 | }
335 | EOF
336 |
337 | sudo mv ~/odoo /etc/nginx/sites-available/
338 | sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/odoo
339 | sudo rm /etc/nginx/sites-enabled/default
340 | sudo service nginx reload
341 | sudo su root -c "printf 'proxy_mode = True\n' >> /etc/${OE_CONFIG}.conf"
342 | echo "Done! The Nginx server is up and running. Configuration can be found at /etc/nginx/sites-available/odoo"
343 | else
344 | echo "Nginx isn't installed due to choice of the user!"
345 | fi
346 | echo -e "* Starting Odoo Service"
347 | sudo su root -c "/etc/init.d/$OE_CONFIG start"
348 | echo "-----------------------------------------------------------"
349 | echo "Done! The Odoo server is up and running. Specifications:"
350 | echo "Port: $OE_PORT"
351 | echo "User service: $OE_USER"
352 | echo "User PostgreSQL: $OE_USER"
353 | echo "Code location: $OE_USER"
354 | echo "Addons folder: $OE_USER/$OE_CONFIG/addons/"
355 | echo "Password superadmin (database): $OE_SUPERADMIN"
356 | echo "Start Odoo service: sudo service $OE_CONFIG start"
357 | echo "Stop Odoo service: sudo service $OE_CONFIG stop"
358 | echo "Restart Odoo service: sudo service $OE_CONFIG restart"
359 | echo "-----------------------------------------------------------"
360 |
--------------------------------------------------------------------------------