Skip to content

Commit 73b4ccf

Browse files
authored
Merge pull request #1 from Yenthe666/13.0
13.0
2 parents 8c4f52f + b61b311 commit 73b4ccf

File tree

2 files changed

+358
-1
lines changed

2 files changed

+358
-1
lines changed

odoo_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ echo "-----------------------------------------------------------"
413413
echo "Done! The Odoo server is up and running. Specifications:"
414414
echo "Port: $OE_PORT"
415415
echo "User service: $OE_USER"
416-
echo "Configuraton file location: /etc/${OE_CONFIG}.conf"
416+
echo "Configuration file location: /etc/${OE_CONFIG}.conf"
417417
echo "Logfile location: /var/log/$OE_USER"
418418
echo "User PostgreSQL: $OE_USER"
419419
echo "Code location: $OE_USER"

odoo_install_centos7.sh

+357
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
#!/usr/bin/env bash
2+
################################################################################
3+
# Script for installing Odoo on Centos 7
4+
# Based on installation script by Yenthe Van Ginneken https://github.com/Yenthe666/InstallScript
5+
# Author: Fco. Javier Clavero Álvarez
6+
#-------------------------------------------------------------------------------
7+
# This script will install Odoo on your Centos 7 server. It can install multiple Odoo instances
8+
# in one Centos because of the different xmlrpc_ports
9+
#-------------------------------------------------------------------------------
10+
# Make a new file:
11+
# nano odoo-install.sh
12+
# Place this content in it and then make the file executable:
13+
# 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="13.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+
## === Centos 7 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/13.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.centos7.x86_64.rpm
51+
WKHTMLTOX_X32=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos7.i686.rpm
52+
53+
#--------------------------------------------------
54+
# Check run script as root
55+
#--------------------------------------------------
56+
if [ $EUID != 0 ]; then
57+
echo -ne "\nPlease re-run this script with sudo or as root\n\n"
58+
exit 1
59+
fi
60+
61+
#--------------------------------------------------
62+
# Update Server
63+
#--------------------------------------------------
64+
echo -e "\n---- Update Server ----"
65+
yum update -y
66+
yum upgrade -y
67+
68+
#--------------------------------------------------
69+
# Install Dependencies & Tools
70+
#--------------------------------------------------
71+
echo -e "\n--- Dependencies & Tools --"
72+
yum install -y centos-release-scl gcc epel-release
73+
yum install -y wget git libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel nodejs
74+
75+
# ODOO < 12 use less and ODOO >=12 use sass (libsass)
76+
if [ ${OE_VERSION//./} -lt 120 ]; then
77+
echo -e "\n--- Install other required packages"
78+
npm install -g less
79+
npm install -g less-plugin-clean-css
80+
fi
81+
82+
#--------------------------------------------------
83+
# Install PostgreSQL Server
84+
#--------------------------------------------------
85+
# CentOS 7 includes PostgreSQL 9.2 in its default repositories
86+
# Install PostgreSQL 10 from Software Collections (SCL)
87+
# https://wiki.centos.org/AdditionalResources/Repositories/SCL
88+
# https://www.softwarecollections.org/en/scls/rhscl/rh-postgresql10/
89+
90+
echo -e "\n---- Install PostgreSQL Server from SCL ----"
91+
yum -y install rh-postgresql10-postgresql-server rh-postgresql10-postgresql-devel
92+
scl enable rh-postgresql10 "postgresql-setup --initdb --unit rh-postgresql10-postgresql"
93+
pgdata_path=/var/opt/rh/rh-postgresql10/lib/pgsql/data
94+
grep -q '^local\s' $pgdata_path/pg_hba.conf | echo -e "local all all trust" | tee -a $pgdata_path/pg_hba.conf
95+
sed -i.bak 's/\(^local\s*\w*\s*\w*\s*\)\(peer$\)/\1trust/' $pgdata_path/pg_hba.conf
96+
systemctl enable rh-postgresql10-postgresql
97+
systemctl start rh-postgresql10-postgresql
98+
99+
echo -e "\n---- Creating the ODOO PostgreSQL User ----"
100+
su - postgres -c "scl enable rh-postgresql10 -- psql -c 'create user $OE_USER createdb'"
101+
102+
#--------------------------------------------------
103+
# Install Python
104+
#--------------------------------------------------
105+
# https://wiki.centos.org/AdditionalResources/Repositories/SCL
106+
# https://www.softwarecollections.org/en/scls/rhscl/rh-python36/
107+
108+
echo -e "\n--- Installing Python 3 from SCL --"
109+
yum install -y rh-python36
110+
111+
echo -e "\n---- Install python packages/requirements ----"
112+
scl enable rh-python36 -- pip3.6 install pip -U
113+
scl enable rh-python36 -- pip3.6 install wheel
114+
scl enable rh-python36 -- pip3.6 install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt
115+
116+
echo -e "\n---- Installing rtlcss for LTR support ----"
117+
npm install -g rtlcss
118+
119+
#--------------------------------------------------
120+
# Install Wkhtmltopdf if needed
121+
#--------------------------------------------------
122+
if [ $INSTALL_WKHTMLTOPDF = "True" ]; then
123+
echo -e "\n---- Install wkhtml and place shortcuts on correct place for ODOO 13 ----"
124+
#pick up correct one from x64 & x32 versions:
125+
if [ "$(getconf LONG_BIT)" == "64" ];then
126+
_url=$WKHTMLTOX_X64
127+
else
128+
_url=$WKHTMLTOX_X32
129+
fi
130+
yum localinstall -y $_url
131+
132+
else
133+
echo "Wkhtmltopdf isn't installed due to the choice of the user!"
134+
fi
135+
136+
echo -e "\n---- Create ODOO system user ----"
137+
adduser --system --shell=/bin/bash --home-dir=$OE_HOME --user-group $OE_USER
138+
139+
#The user should also be added to the wheel group.
140+
usermod -aG wheel $OE_USER
141+
142+
echo -e "\n---- Create Log directory ----"
143+
mkdir /var/log/$OE_USER
144+
chown $OE_USER:$OE_USER /var/log/$OE_USER
145+
146+
#--------------------------------------------------
147+
# Install ODOO
148+
#--------------------------------------------------
149+
echo -e "\n==== Installing ODOO Server ===="
150+
git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/
151+
152+
if [ $IS_ENTERPRISE = "True" ]; then
153+
# Odoo Enterprise install!
154+
su $OE_USER -c "mkdir $OE_HOME/enterprise"
155+
su $OE_USER -c "mkdir $OE_HOME/enterprise/addons"
156+
157+
GITHUB_RESPONSE=$(git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
158+
while [[ $GITHUB_RESPONSE == *"Authentication"* ]]; do
159+
echo "------------------------WARNING------------------------------"
160+
echo "Your authentication with Github has failed! Please try again."
161+
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"
162+
echo "TIP: Press ctrl+c to stop this script."
163+
echo "-------------------------------------------------------------"
164+
echo " "
165+
GITHUB_RESPONSE=$(git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
166+
done
167+
168+
echo -e "\n---- Added Enterprise code under $OE_HOME/enterprise/addons ----"
169+
echo -e "\n---- Installing Enterprise specific libraries ----"
170+
scl enable rh-python36 -- pip3.6 install num2words ofxparse dbfread ebaysdk firebase_admin pyOpenSSL
171+
fi
172+
173+
echo -e "\n---- Create custom module directory ----"
174+
mkdir -p $OE_HOME/custom/addons
175+
176+
echo -e "\n---- Setting permissions on home folder ----"
177+
chown -R $OE_USER:$OE_USER $OE_HOME/
178+
179+
echo -e "* Create server config file"
180+
touch /etc/${OE_CONFIG}.conf
181+
echo -e "* Creating server config file"
182+
su root -c "printf '[options] \n; This is the password that allows database operations:\n' >> /etc/${OE_CONFIG}.conf"
183+
if [ $GENERATE_RANDOM_PASSWORD = "True" ]; then
184+
echo -e "* Generating random admin password"
185+
OE_SUPERADMIN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
186+
fi
187+
su root -c "printf 'admin_passwd = ${OE_SUPERADMIN}\n' >> /etc/${OE_CONFIG}.conf"
188+
if [ ${OE_VERSION//./} -ge 120 ]; then
189+
su root -c "printf 'http_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf"
190+
else
191+
su root -c "printf 'xmlrpc_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf"
192+
fi
193+
su root -c "printf 'logfile = /var/log/${OE_USER}/${OE_CONFIG}.log\n' >> /etc/${OE_CONFIG}.conf"
194+
195+
if [ $IS_ENTERPRISE = "True" ]; then
196+
su root -c "printf 'addons_path=${OE_HOME}/enterprise/addons,${OE_HOME_EXT}/addons\n' >> /etc/${OE_CONFIG}.conf"
197+
else
198+
su root -c "printf 'addons_path=${OE_HOME_EXT}/addons,${OE_HOME}/custom/addons\n' >> /etc/${OE_CONFIG}.conf"
199+
fi
200+
chown $OE_USER:$OE_USER /etc/${OE_CONFIG}.conf
201+
chmod 640 /etc/${OE_CONFIG}.conf
202+
203+
echo -e "* Create startup file"
204+
su root -c "echo '#!/bin/sh' >> $OE_HOME_EXT/start.sh"
205+
su root -c "echo 'su - $OE_USER -c \"scl enable rh-python36 -- python3 $OE_HOME_EXT/odoo-bin --config=/etc/${OE_CONFIG}.conf\"' >> $OE_HOME_EXT/start.sh"
206+
chmod 755 $OE_HOME_EXT/start.sh
207+
208+
#--------------------------------------------------
209+
# Adding ODOO as a deamon (initscript)
210+
#--------------------------------------------------
211+
echo -e "* Create init file"
212+
cat > /etc/systemd/system/$OE_CONFIG.service << EOF
213+
[Unit]
214+
Description=$OE_CONFIG
215+
Requires=rh-postgresql10
216+
After=network.target rh-postgresql10
217+
218+
[Service]
219+
Type=simple
220+
SyslogIdentifier=$OE_CONFIG
221+
PermissionsStartOnly=true
222+
User=$OE_USER
223+
Group=$OE_USER
224+
ExecStart=/usr/bin/scl enable rh-python36 -- $OE_HOME_EXT/odoo-bin -c /etc/$OE_CONFIG.conf
225+
StandardOutput=journal+console
226+
227+
[Install]
228+
WantedBy=multi-user.target
229+
EOF
230+
231+
systemctl daemon-reload
232+
systemctl enable $OE_CONFIG
233+
234+
#--------------------------------------------------
235+
# Install Nginx if needed
236+
#--------------------------------------------------
237+
if [ $INSTALL_NGINX = "True" ]; then
238+
echo -e "\n---- Installing and setting up Nginx ----"
239+
yum install nginx -y
240+
systemctl enable nginx
241+
systemctl start nginx
242+
243+
mkdir /etc/nginx/sites-available
244+
245+
cat <<EOF > ~/odoo.conf
246+
server {
247+
listen 80;
248+
249+
# set proper server name after domain set
250+
server_name $WEBSITE_NAME;
251+
252+
# Add Headers for odoo proxy mode
253+
proxy_set_header X-Forwarded-Host \$host;
254+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
255+
proxy_set_header X-Forwarded-Proto \$scheme;
256+
proxy_set_header X-Real-IP \$remote_addr;
257+
add_header X-Frame-Options "SAMEORIGIN";
258+
add_header X-XSS-Protection "1; mode=block";
259+
proxy_set_header X-Client-IP \$remote_addr;
260+
proxy_set_header HTTP_X_FORWARDED_HOST \$remote_addr;
261+
262+
# odoo log files
263+
access_log /var/log/nginx/$OE_USER-access.log;
264+
error_log /var/log/nginx/$OE_USER-error.log;
265+
266+
# increase proxy buffer size
267+
proxy_buffers 16 64k;
268+
proxy_buffer_size 128k;
269+
270+
proxy_read_timeout 900s;
271+
proxy_connect_timeout 900s;
272+
proxy_send_timeout 900s;
273+
274+
# force timeouts if the backend dies
275+
proxy_next_upstream error timeout invalid_header http_500 http_502
276+
http_503;
277+
278+
types {
279+
text/less less;
280+
text/scss scss;
281+
}
282+
283+
# enable data compression
284+
gzip on;
285+
gzip_min_length 1100;
286+
gzip_buffers 4 32k;
287+
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png;
288+
gzip_vary on;
289+
client_header_buffer_size 4k;
290+
large_client_header_buffers 4 64k;
291+
client_max_body_size 0;
292+
293+
location / {
294+
proxy_pass http://127.0.0.1:$OE_PORT;
295+
# by default, do not forward anything
296+
proxy_redirect off;
297+
}
298+
299+
location /longpolling {
300+
proxy_pass http://127.0.0.1:$LONGPOLLING_PORT;
301+
}
302+
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
303+
expires 2d;
304+
proxy_pass http://127.0.0.1:$OE_PORT;
305+
add_header Cache-Control "public, no-transform";
306+
}
307+
# cache some static data in memory for 60mins.
308+
location ~ /[a-zA-Z0-9_-]*/static/ {
309+
proxy_cache_valid 200 302 60m;
310+
proxy_cache_valid 404 1m;
311+
proxy_buffering on;
312+
expires 864000;
313+
proxy_pass http://127.0.0.1:$OE_PORT;
314+
}
315+
}
316+
EOF
317+
318+
mv ~/odoo.conf /etc/nginx/sites-available/
319+
ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/conf.d/odoo.conf
320+
echo -e "* SELinux permission"
321+
setsebool -P httpd_can_network_connect 1
322+
restorecon /etc/nginx/conf.d/*
323+
systemctl reload nginx
324+
su root -c "printf 'proxy_mode = True\n' >> /etc/${OE_CONFIG}.conf"
325+
326+
# Firewalld by default and blocks access to ports 80 and 443
327+
echo -e "* enables ports 80 and 443"
328+
firewall-cmd --zone=public --permanent --add-service=http
329+
firewall-cmd --zone=public --permanent --add-service=https
330+
firewall-cmd --reload
331+
echo "Done! The Nginx server is up and running. Configuration can be found at /etc/nginx/sites-available/odoo.conf"
332+
else
333+
echo "Nginx isn't installed due to choice of the user!"
334+
fi
335+
336+
echo -e "* Starting Odoo Service"
337+
systemctl start $OE_CONFIG
338+
echo -e "* Opening Odoo Port in firewalld"
339+
firewall-cmd --permanent --zone=public --add-port=${OE_PORT}/tcp
340+
firewall-cmd --reload
341+
echo "-----------------------------------------------------------"
342+
echo "Done! The Odoo server is up and running. Specifications:"
343+
echo "Port: $OE_PORT"
344+
echo "User service: $OE_USER"
345+
echo "Configuraton file location: /etc/${OE_CONFIG}.conf"
346+
echo "Logfile location: /var/log/$OE_USER"
347+
echo "User PostgreSQL: $OE_USER"
348+
echo "Code location: $OE_USER"
349+
echo "Addons folder: $OE_USER/$OE_CONFIG/addons/"
350+
echo "Password superadmin (database): $OE_SUPERADMIN"
351+
echo "Start Odoo service: sudo systemctl start $OE_CONFIG"
352+
echo "Stop Odoo service: sudo systemctl stop $OE_CONFIG"
353+
echo "Restart Odoo service: sudo systemctl restart $OE_CONFIG"
354+
if [ $INSTALL_NGINX = "True" ]; then
355+
echo "Nginx configuration file: /etc/nginx/sites-available/odoo"
356+
fi
357+
echo "-----------------------------------------------------------"

0 commit comments

Comments
 (0)