Skip to content

Commit a4f77be

Browse files
authored
Odoo install
0 parents  commit a4f77be

File tree

10 files changed

+809
-0
lines changed

10 files changed

+809
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<h3>Installation procedure</h3>
2+
- 1. Download the script:
3+
```
4+
git clone -b All [email protected]:external/installscript.git
5+
cd installscript/odoo_install
6+
git checkout All
7+
```
8+
- 2. Modify the parameters as you wish.
9+
There are a few things you can configure, this is the most used list:<br/>
10+
```OE_USER``` will be the username for the system user.<br/>
11+
```OE_HOME``` will be the home directory of the system user.<br/>
12+
```OE_VERSION``` is the Odoo version to install, for example ```10.0``` for Odoo V10.<br/>
13+
```OE_INSTALL_DIR``` is the path where all environment will be installed to.<br/>
14+
```OE_REPO``` is the path where odoo will be clonned to.<br/>
15+
```INSTALL_WKHTMLTOPDF``` set to ```False``` if you do not want to install it, if you want to install it you should set it to ```True```.<br/>
16+
```OE_PORT``` is the port where Odoo should run on, for example 8069.<br/>
17+
```OE_NETRPC_PORT``` is the port where Odoo net-rpc should run on, for example 8070.<br/>
18+
```OE_LONGPOOL_PORT``` is the port where Odoo long pool should run on, for example 8070.<br/>
19+
```IS_ENTERPRISE``` will install the Enterprise version on top of community version if you set it to ```True```, set it to ```False``` if you want the community version of Odoo.<br/>
20+
```OE_SUPERADMIN``` is the master password for this Odoo installation.<br/>
21+
```OE_DB_PASSWORD``` is the password of postgres user.<br/>
22+
```OE_WORKERS``` is the number of Odoo workers
23+
```PG_VERSION``` is a version of postgresql installed
24+
25+
- 3. Become root
26+
```
27+
sudo su
28+
```
29+
- 3. Make the script executable
30+
```
31+
sudo chmod +x run.sh
32+
```
33+
- 4. Execute the script:
34+
```
35+
sudo ./run.sh
36+
```

apache.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
# --------------------------------------
3+
# Apache2 installation section
4+
# --------------------------------------
5+
if [ $WEB_SERVER = "apache2" ]; then
6+
7+
echo -e "* Install $WEB_SERVER"
8+
sudo apt-get install -y $WEB_SERVER
9+
10+
echo -e "Configuring Odoo with Apache"
11+
12+
echo -e "* Enable apache modules"
13+
sudo a2enmod proxy
14+
sudo a2enmod proxy_http
15+
sudo a2enmod rewrite
16+
sudo a2enmod headers
17+
sudo a2enmod ssl
18+
19+
echo -e "* Create new site with the following content"
20+
21+
cat <<EOF > $OE_WEBSERV_CONF
22+
<VirtualHost *:80>
23+
ServerName $DOMAIN_NAME
24+
EOF
25+
for alias in ${DOMAIN_ALIASES[@]} ; do
26+
cat <<EOT >>$OE_WEBSERV_CONF
27+
ServerAlias $alias
28+
EOT
29+
done
30+
cat <<EOT >>$OE_WEBSERV_CONF
31+
32+
ServerSignature Off
33+
34+
ErrorLog \${APACHE_LOG_DIR}/$OE_INIT-error.log
35+
CustomLog \${APACHE_LOG_DIR}/$OE_INIT-access.log combined
36+
37+
ProxyRequests Off
38+
39+
<Proxy *>
40+
Order deny,allow
41+
Allow from all
42+
</Proxy>
43+
44+
ProxyVia On
45+
ProxyTimeout 12000
46+
ProxyPreserveHost On
47+
48+
ProxyPass /longpolling/ http://127.0.0.1:$OE_LONGPOOL_PORT/longpolling/
49+
ProxyPassReverse /longpolling/ http://127.0.0.1:$OE_LONGPOOL_PORT/longpolling/
50+
51+
ProxyPass /webdav/ http://127.0.0.1:$OE_PORT/webdav/
52+
<Location /webdav/ >
53+
ProxyPassReverse /webdav/
54+
<Limit OPTIONS PROPFIND GET REPORT MKACTIVITY PROPPATCH PUT MOVE COPY DELETE LOCK UNLOCK>
55+
Order Deny,Allow
56+
Allow from all
57+
Satisfy Any
58+
</Limit>
59+
</Location>
60+
61+
ProxyPass / http://127.0.0.1:$OE_PORT/
62+
63+
RequestHeader set "X-Forwarded-Proto" "http"
64+
65+
# Fix IE problem (httpapache proxy dav error 408/409)
66+
# SetEnv proxy-nokeepalive 1
67+
68+
<FilesMatch "\.(cgi|shtml|phtml|php)$">
69+
SSLOptions +StdEnvVars
70+
</FilesMatch>
71+
72+
<Directory /usr/lib/cgi-bin>
73+
SSLOptions +StdEnvVars
74+
</Directory>
75+
76+
BrowserMatch "MSIE [2-6]" \
77+
nokeepalive ssl-unclean-shutdown \
78+
downgrade-1.0 force-response-1.0
79+
# MSIE 7 and newer should be able to use keepalive
80+
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
81+
82+
</VirtualHost>
83+
EOT
84+
85+
mkdir -p $OE_AUTO_SCRIPTS_DIR/etc/apache2/sites-available
86+
mv $OE_WEBSERV_CONF $OE_AUTO_SCRIPTS_DIR/etc/apache2/sites-available/
87+
88+
cat <<EOT >>$OE_AUTO_SCRIPTS_DIR/DEBIAN/postinst
89+
echo -e "* Enable site"
90+
a2ensite $OE_WEBSERV_CONF
91+
92+
echo -e "* Disable default sites"
93+
a2dissite default-ssl
94+
a2dissite 000-default
95+
96+
service apache2 reload
97+
98+
exit 0
99+
EOT
100+
101+
fi

cert.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# ------------------------------------------------------
3+
# Certificates installation section
4+
# ------------------------------------------------------
5+
echo -e "Install certificate when required"
6+
7+
if [ $INSTALL_CERTIFICATE = "True" ] && [ ! -z "$DOMAIN_NAME" ]; then
8+
9+
#--------------------------------------------------
10+
# Install Libraries needed for let's encrypt
11+
#--------------------------------------------------
12+
sudo apt-get install -y dnsutils dirmngr git wget
13+
14+
# Check if domain is reachable
15+
PUBLIC_IP=`dig +short myip.opendns.com @resolver1.opendns.com`
16+
REACHED_IP=`dig $DOMAIN_NAME A +short`
17+
if [[ $REACHED_IP == $PUBLIC_IP ]]; then
18+
INSTALL_CERTIFICATE="True"
19+
else
20+
INSTALL_CERTIFICATE="False"
21+
echo "IMPORTANT! Skipping certificate installation, as it is not possible to resolve domain ${DOMAIN_NAME} to IP ${PUBLIC_IP}"
22+
fi
23+
24+
if [ $INSTALL_CERTIFICATE = "True" ]; then
25+
sudo add-apt-repository "deb http://ftp.debian.org/debian $(lsb_release -sc)-backports main"
26+
sudo apt-get update
27+
28+
domains="-d $DOMAIN_NAME"
29+
for alias in ${DOMAIN_ALIASES[@]} ; do
30+
domains="$domains -d $alias"
31+
done
32+
if [ $WEB_SERVER = "apache2" ] ; then
33+
echo -e "Configuring certificate with Apache"
34+
sudo apt-get install python-certbot-apache -y
35+
sudo certbot --apache $domains --non-interactive --agree-tos --redirect -m $LE_EMAIL
36+
fi
37+
38+
if [ $WEB_SERVER = "nginx" ] ; then
39+
echo -e "Configuring certificate with Nginx"
40+
sudo apt-get install python-certbot-nginx -y
41+
sudo certbot --nginx $domains --non-interactive --agree-tos --redirect -m $LE_EMAIL
42+
fi
43+
fi
44+
fi

conf.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
##fixed parameters
3+
#odoo
4+
5+
OE_VERSION="14.0"
6+
OE_INSTALL_DIR="$OE_HOME/$OE_VERSION"
7+
OE_REPO="$OE_INSTALL_DIR/odoo"
8+
#Set to true if you want to install it, false if you don't need it or have it already installed.
9+
INSTALL_WKHTMLTOPDF="True"
10+
OE_PORT="8069"
11+
OE_NETRPC_PORT="8070"
12+
OE_LONGPOOL_PORT="8072"
13+
OE_WORKERS="4"
14+
#Choose the Odoo version which you want to install. For example: 9.0, 8.0, 7.0 or saas-6. When using 'trunk' the master version will be installed.
15+
#IMPORTANT! This script contains extra libraries that are specifically needed for Odoo 9.0
16+
17+
# Set this to True if you want to install Odoo Enterprise!
18+
IS_ENTERPRISE="False"
19+
#set the superadmin password
20+
OE_SUPERADMIN="admin"
21+
22+
INSTALL_PG_SERVER="True" # if false, than only client will be installed
23+
OE_DB_HOST="localhost"
24+
OE_DB_PORT="5432"
25+
OE_DB_USER="odoo"
26+
OE_DB_PASSWORD="odoo"
27+
PG_VERSION=12
28+
29+
WEB_SERVER="nginx" # or "apache2"
30+
31+
HTTP_PROTOCOL="https"
32+
HTTPS_PORT="443"
33+
INSTALL_CERTIFICATE="False"
34+
PUBLIC_IP="" # SET MANUALLY
35+
DOMAIN_NAME="demo.ventor.tech" # DNS SHOULD BE ALREADY CONFIGURED!
36+
DOMAIN_ALIASES=() # ("www.demo.ventortech.com" "zzz.demo.ventortech.com")
37+
38+
LE_CRON_SCRIPT="/etc/cron.daily/certbot-renew"
39+
40+
if [ $IS_ENTERPRISE = "True" ]; then
41+
OE_CONFIG="$OE_INSTALL_DIR/odoo-enterprise.conf"
42+
OE_INIT="odoo-$OE_VERSION-enterprise"
43+
OE_WEBSERV_CONF="odoo-$OE_VERSION-enterprise.conf"
44+
OE_WEBSERVER_HOST="odoo$OE_VERSION-e"
45+
OE_ADDONS_PATH="$OE_INSTALL_DIR/all_addons,$OE_INSTALL_DIR/enterprise/addons,$OE_REPO/addons"
46+
OE_LOG_PATH="$OE_INSTALL_DIR/logs/enterprise"
47+
OE_TEXT="Enterprise"
48+
else
49+
OE_CONFIG="$OE_INSTALL_DIR/odoo.conf"
50+
OE_INIT="odoo-$OE_VERSION"
51+
OE_WEBSERV_CONF="odoo-$OE_VERSION.conf"
52+
OE_WEBSERVER_HOST="odoo$OE_VERSION"
53+
OE_ADDONS_PATH="$OE_INSTALL_DIR/all_addons,$OE_REPO/addons"
54+
OE_LOG_PATH="$OE_INSTALL_DIR/logs/community"
55+
OE_TEXT="Community"
56+
fi
57+
58+
if [ $OE_VERSION = "11.0" ] || [ $OE_VERSION = "12.0" ] || [ $OE_VERSION = "13.0" ] || [ $OE_VERSION = "14.0" ]; then
59+
PYTHON_VERSION="3"
60+
else
61+
PYTHON_VERSION="2"
62+
fi

db.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
#--------------------------------------------------
3+
# Install PostgreSQL Server
4+
#--------------------------------------------------
5+
6+
PG_ALREADY_INSTALLED="False"
7+
export OE_DB_PORT
8+
# Let's first check if postgres already installed
9+
if [ $INSTALL_PG_SERVER = "True" ]; then
10+
SERVER_RESULT=`sudo -E -u postgres bash -c "psql -X -p $OE_DB_PORT -c \"SELECT version();\""`
11+
if [ -z "$SERVER_RESULT" ]; then
12+
echo "No postgres database is installed on port $OE_DB_PORT. So we will install it."
13+
else
14+
if [[ $SERVER_RESULT == *"PostgreSQL $PG_VERSION"* ]]; then
15+
echo "We already have PostgreSQL Server $PG_VERSION installed and running port $OE_DB_PORT. Skipping it's installation."
16+
PG_ALREADY_INSTALLED="True"
17+
else
18+
echo "Version other than PostgreSQL $PG_VERSION Server installed on port $OE_DB_PORT. Make sure that you have configured port correctly. Aborting!"
19+
exit 1
20+
fi
21+
fi
22+
else
23+
CLIENT_RESULT=`psql -V`
24+
if [ -z "$CLIENT_RESULT" ]; then
25+
echo "No PosgreSQL Client installed. Installing it."
26+
else
27+
if [[ $CLIENT_RESULT == *"$PG_VERSION"* ]]; then
28+
echo "We already have PostgreSQL Client version $PG_VERSION. Skipping installation."
29+
PG_ALREADY_INSTALLED="True"
30+
else
31+
echo "Not correct version of PostgreSQL Client installed. Required $PG_VERSION, installed '$CLIENT_RESULT'. We will try to reinstall again."
32+
fi
33+
fi
34+
fi
35+
36+
echo -e "\n---- Install PostgreSQL Server ----"
37+
if [ $PG_ALREADY_INSTALLED == "False" ]; then
38+
sudo apt-get install software-properties-common -y
39+
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main"
40+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
41+
sudo apt-get update
42+
fi
43+
44+
if [ $INSTALL_PG_SERVER = "True" ]; then
45+
46+
export PG_CONF="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
47+
export PG_HBA="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
48+
49+
if [ $PG_ALREADY_INSTALLED == "False" ]; then
50+
echo -e "\n---- Install PostgreSQL Server ----"
51+
sudo apt-get install postgresql-$PG_VERSION -y
52+
53+
# Edit postgresql.conf to change listen address to '*':
54+
sudo -u postgres sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
55+
56+
# Edit postgresql.conf to change port to '$OE_DB_PORT':
57+
sudo -u postgres sed -i "s/port = 5432/port = $OE_DB_PORT/" "$PG_CONF"
58+
fi
59+
60+
# Even if PostgresSQL Server is already installed, we may still want to optimize it for ERP and create DB user.
61+
export MEM=$(awk '/^MemTotal/ {print $2}' /proc/meminfo)
62+
export CPU=$(awk '/^processor/ {print $3}' /proc/cpuinfo | wc -l)
63+
export CONNECTIONS="100"
64+
65+
# Explicitly set default client_encoding
66+
sudo -E -u postgres bash -c 'echo "client_encoding = utf8" >> "$PG_CONF"'
67+
68+
# Explicitly set parameters for ERP/OLTP
69+
sudo -E -u postgres bash -c 'echo "effective_cache_size = $(( $MEM * 3 / 4 ))kB" >> "$PG_CONF"'
70+
sudo -E -u postgres bash -c 'echo "checkpoint_completion_target = 0.9" >> "$PG_CONF"'
71+
sudo -E -u postgres bash -c 'echo "shared_buffers = $(( $MEM / 4 ))kB" >> "$PG_CONF"'
72+
sudo -E -u postgres bash -c 'echo "maintenance_work_mem = $(( $MEM / 16 ))kB" >> "$PG_CONF"'
73+
sudo -E -u postgres bash -c 'echo "work_mem = $(( ($MEM - $MEM / 4) / ($CONNECTIONS * 3) ))kB" >> "$PG_CONF"'
74+
sudo -E -u postgres bash -c 'echo "random_page_cost = 4 # or 1.1 for SSD" >> "$PG_CONF"'
75+
sudo -E -u postgres bash -c 'echo "effective_io_concurrency = 2 # or 200 for SSD" >> "$PG_CONF"'
76+
sudo -E -u postgres bash -c 'echo "max_connections = $CONNECTIONS" >> "$PG_CONF"'
77+
78+
# Now let's create new user
79+
export OE_DB_USER
80+
export OE_DB_PASSWORD
81+
82+
# Append to pg_hba.conf to add password auth:
83+
sudo -E -u postgres bash -c 'echo "host all $OE_DB_USER all md5" >> "$PG_HBA"'
84+
85+
# Restart so that all new config is loaded:
86+
sudo service postgresql restart
87+
88+
echo -e "\n---- Creating the ODOO PostgreSQL User ----"
89+
sudo -E -u postgres bash -c "psql -X -p $OE_DB_PORT -c \"CREATE USER $OE_DB_USER WITH CREATEDB NOCREATEROLE NOSUPERUSER PASSWORD '$OE_DB_PASSWORD';\""
90+
91+
# Restart so that all new config is loaded:
92+
sudo service postgresql restart
93+
else
94+
echo -e "\n---- Install PostgreSQL Client ----"
95+
sudo apt-get install postgresql-client-$PG_VERSION -y
96+
fi

0 commit comments

Comments
 (0)