Skip to content

Commit fa28926

Browse files
authored
[ADD] odoo_install_debian: install script for Debian 10
[ADD] odoo_install_debian: install script for Debian 10
2 parents e5e7fba + fe3bc9a commit fa28926

1 file changed

Lines changed: 359 additions & 0 deletions

File tree

odoo_install_debian.sh

Lines changed: 359 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,359 @@
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="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+
## === 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 <<EOF > ~/$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 <<EOF > ~/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 "-----------------------------------------------------------"

0 commit comments

Comments
 (0)