|
| 1 | +#!/bin/bash |
| 2 | +################################################################################ |
| 3 | +# Script for installing Odoo V10 on Debian (could be used for other version too) |
| 4 | +# Based on installation script by Yenthe Van Ginneken https://github.com/Yenthe666/InstallScript |
| 5 | +# Author: William Olhasque |
| 6 | +#------------------------------------------------------------------------------- |
| 7 | +# This script will install Odoo on your Debian Jessie server. It can install multiple Odoo instances |
| 8 | +# in one Ubuntu 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 | +##fixed parameters |
| 19 | +#odoo |
| 20 | +OE_USER="odoo" |
| 21 | +OE_HOME="/$OE_USER" |
| 22 | +OE_HOME_EXT="/$OE_USER/${OE_USER}-server" |
| 23 | +OE_ADDONS_PATH="$OE_HOME_EXT/addons,$OE_HOME/custom/addons" |
| 24 | +#The default port where this Odoo instance will run under (provided you use the command -c in the terminal) |
| 25 | +#Set to true if you want to install it, false if you don't need it or have it already installed. |
| 26 | +INSTALL_WKHTMLTOPDF="True" |
| 27 | +#Set the default Odoo port (you still have to use -c /etc/odoo-server.conf for example to use this.) |
| 28 | +OE_PORT="8069" |
| 29 | +#Choose the Odoo version which you want to install. For example: 10.0, 9.0, 8.0, 7.0 or saas-6. When using 'trunk' the master version will be installed. |
| 30 | +#IMPORTANT! This script contains extra libraries that are specifically needed for Odoo 10.0 |
| 31 | +OE_VERSION="10.0" |
| 32 | +# Set this to True if you want to install Odoo 10 Enterprise! |
| 33 | +IS_ENTERPRISE="False" |
| 34 | +#set the superadmin password |
| 35 | +OE_SUPERADMIN="admin" |
| 36 | +OE_CONFIG="${OE_USER}-server" |
| 37 | + |
| 38 | +#Python env |
| 39 | +OE_PYTHON_ENV="${OE_HOME}/python_env" |
| 40 | + |
| 41 | +#PostgreSQL Version |
| 42 | +OE_POSTGRESQL_VERSION="9.6" |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +## |
| 47 | +### WKHTMLTOPDF download links |
| 48 | +## === Debian Jessie |
| 49 | +## https://www.odoo.com/documentation/8.0/setup/install.html#deb ): |
| 50 | +WKHTMLTOX_X64=https://nightly.odoo.com/extra/wkhtmltox-0.12.1.2_linux-jessie-amd64.deb |
| 51 | + |
| 52 | +# |
| 53 | +# Install dialog |
| 54 | +# |
| 55 | +echo -e "\n---- Update Server ----" |
| 56 | +apt-get update >> ./install_log |
| 57 | +echo -e "\n---- Install dialog ----" |
| 58 | +apt-get install dialog -y >> ./install_log |
| 59 | +# |
| 60 | +# Remove Odoo and PostgreSQL |
| 61 | +# |
| 62 | +echo -e "\n---- Purge odoo postgresql wkhtmltox ----" |
| 63 | +apt-get remove --purge wkhtmltox postgresql postgresql-9.4 postgresql-client postgresql-client-9.4 postgresql-client-common postgresql-common odoo -y >> ./install_log |
| 64 | +apt-get autoremove -y >> ./install_log |
| 65 | +#-------------------------------------------------- |
| 66 | +# Update Server |
| 67 | +#-------------------------------------------------- |
| 68 | +echo -e "\n---- Upgrade Server ----" |
| 69 | +apt-get upgrade -y >> ./install_log |
| 70 | + |
| 71 | +#-------------------------------------------------- |
| 72 | +# Install PostgreSQL Server |
| 73 | +#-------------------------------------------------- |
| 74 | +# Add official repository |
| 75 | +cat <<EOF > /etc/apt/sources.list.d/pgdg.list |
| 76 | +deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main |
| 77 | +EOF |
| 78 | + |
| 79 | +echo -e "\n---- Install PostgreSQL Repo Key ----" |
| 80 | +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - |
| 81 | + |
| 82 | + |
| 83 | +echo -e "\n---- Install PostgreSQL Server ${OE_POSTGRESQL_VERSION} ----" |
| 84 | +apt-get update >> ./install_log |
| 85 | +apt-get install postgresql-${OE_POSTGRESQL_VERSION} postgresql-server-dev-${OE_POSTGRESQL_VERSION} -y >> ./install_log |
| 86 | + |
| 87 | +echo -e "\n---- Creating the ODOO PostgreSQL User ----" |
| 88 | +su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true |
| 89 | + |
| 90 | +#-------------------------------------------------- |
| 91 | +# Install Dependencies |
| 92 | +#-------------------------------------------------- |
| 93 | +echo -e "\n---- Install packages ----" |
| 94 | +apt-get install libjpeg-dev curl wget git python-pip gdebi-core python-dev libxml2-dev libxslt1-dev zlib1g-dev libldap2-dev libsasl2-dev node-clean-css node-less python-gevent -y >> ./install_log |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +#-------------------------------------------------- |
| 100 | +# Install Wkhtmltopdf if needed |
| 101 | +#-------------------------------------------------- |
| 102 | +if [ $INSTALL_WKHTMLTOPDF = "True" ]; then |
| 103 | + echo -e "\n---- Install wkhtml and place shortcuts on correct place for ODOO 10 ----" |
| 104 | + _url=$WKHTMLTOX_X64 |
| 105 | + wget --quiet $_url |
| 106 | + gdebi --n `basename $_url` >> ./install_log |
| 107 | + rm `basename $_url` |
| 108 | +else |
| 109 | + echo "Wkhtmltopdf isn't installed due to the choice of the user!" |
| 110 | +fi |
| 111 | + |
| 112 | +echo -e "\n---- Create ODOO system user ----" |
| 113 | +adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'ODOO' --group $OE_USER >> ./install_log |
| 114 | +#The user should also be added to the sudo'ers group. |
| 115 | +adduser $OE_USER sudo >> ./install_log |
| 116 | + |
| 117 | +echo -e "\n---- Create Log and data directory ----" |
| 118 | +mkdir /var/log/$OE_USER >> ./install_log |
| 119 | +mkdir /var/lib/$OE_USER >> ./install_log |
| 120 | +chown $OE_USER:$OE_USER /var/log/$OE_USER |
| 121 | +chown $OE_USER:$OE_USER /var/lib/$OE_USER |
| 122 | + |
| 123 | +#-------------------------------------------------- |
| 124 | +# Install ODOO |
| 125 | +#-------------------------------------------------- |
| 126 | +echo -e "\n==== Installing ODOO Server ====" |
| 127 | +git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/ >> ./install_log |
| 128 | + |
| 129 | +if [ $IS_ENTERPRISE = "True" ]; then |
| 130 | + # Odoo Enterprise install! |
| 131 | + su $OE_USER -c "mkdir $OE_HOME/enterprise" |
| 132 | + su $OE_USER -c "mkdir $OE_HOME/enterprise/addons" |
| 133 | + |
| 134 | + echo -e "\n---- Adding Enterprise code under $OE_HOME/enterprise/addons ----" |
| 135 | + git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" |
| 136 | + |
| 137 | + echo -e "\n---- Installing Enterprise specific libraries ----" |
| 138 | + apt-get install nodejs npm -y >> ./install_log |
| 139 | + npm install -g less |
| 140 | + npm install -g less-plugin-clean-css |
| 141 | + echo -e "\n--- Create symlink for node" |
| 142 | + ln -s /usr/bin/nodejs /usr/bin/node |
| 143 | + OE_ADDONS_PATH="$OE_HOME/enterprise/addons,$OE_ADDONS_PATH" |
| 144 | +fi |
| 145 | + |
| 146 | +echo -e "\n---- Create custom module directory ----" |
| 147 | +su $OE_USER -c "mkdir $OE_HOME/custom" >> ./install_log |
| 148 | +su $OE_USER -c "mkdir $OE_HOME/custom/addons" >> ./install_log |
| 149 | + |
| 150 | + |
| 151 | +echo -e "\n---- Setting permissions on home folder ----" |
| 152 | +chown -R $OE_USER:$OE_USER $OE_HOME/* |
| 153 | + |
| 154 | +echo -e "* Create server config file" |
| 155 | + |
| 156 | +cat <<EOF > /etc/${OE_CONFIG}.conf |
| 157 | +[options] |
| 158 | +addons_path = $OE_ADDONS_PATH |
| 159 | +admin_passwd = $OE_SUPERADMIN |
| 160 | +csv_internal_sep = , |
| 161 | +data_dir = /var/lib/$OE_USER/.local/share/Odoo |
| 162 | +db_host = False |
| 163 | +db_maxconn = 64 |
| 164 | +db_name = False |
| 165 | +db_password = False |
| 166 | +db_port = False |
| 167 | +db_template = template1 |
| 168 | +db_user = $OE_USER |
| 169 | +dbfilter = .* |
| 170 | +debug_mode = False |
| 171 | +demo = {} |
| 172 | +email_from = False |
| 173 | +geoip_database = /usr/share/GeoIP/GeoLiteCity.dat |
| 174 | +import_partial = |
| 175 | +limit_memory_hard = 2684354560 |
| 176 | +limit_memory_soft = 2147483648 |
| 177 | +limit_request = 8192 |
| 178 | +limit_time_cpu = 60 |
| 179 | +limit_time_real = 120 |
| 180 | +list_db = True |
| 181 | +log_db = False |
| 182 | +log_db_level = warning |
| 183 | +log_handler = :INFO |
| 184 | +log_level = info |
| 185 | +logfile = /var/log/$OE_USER/$OE_CONFIG |
| 186 | +logrotate = True |
| 187 | +longpolling_port = 8072 |
| 188 | +max_cron_threads = 1 |
| 189 | +osv_memory_age_limit = 1.0 |
| 190 | +osv_memory_count_limit = False |
| 191 | +pg_path = None |
| 192 | +pidfile = None |
| 193 | +proxy_mode = True |
| 194 | +reportgz = False |
| 195 | +server_wide_modules = None |
| 196 | +smtp_password = False |
| 197 | +smtp_port = 25 |
| 198 | +smtp_server = localhost |
| 199 | +smtp_ssl = False |
| 200 | +smtp_user = False |
| 201 | +syslog = False |
| 202 | +test_commit = False |
| 203 | +test_enable = False |
| 204 | +test_file = False |
| 205 | +test_report_directory = False |
| 206 | +translate_modules = ['all'] |
| 207 | +unaccent = False |
| 208 | +without_demo = False |
| 209 | +workers = 2 |
| 210 | +xmlrpc = True |
| 211 | +xmlrpc_interface = |
| 212 | +xmlrpc_port = 8069 |
| 213 | +EOF |
| 214 | + |
| 215 | +chown $OE_USER:$OE_USER /etc/${OE_CONFIG}.conf |
| 216 | +chmod 640 /etc/${OE_CONFIG}.conf |
| 217 | + |
| 218 | + |
| 219 | +echo -e "\n---- Install python packages and virtualenv ----" |
| 220 | +pip install virtualenv >> ./install_log |
| 221 | +mkdir $OE_PYTHON_ENV >> ./install_log |
| 222 | +virtualenv $OE_PYTHON_ENV -p /usr/bin/python2.7 >> ./install_log |
| 223 | +source /odoo/python_env/bin/activate && pip install -r $OE_HOME_EXT/requirements.txt >> ./install_log |
| 224 | +deactivate |
| 225 | + |
| 226 | + |
| 227 | +#-------------------------------------------------- |
| 228 | +# Adding ODOO as a deamon (initscript) |
| 229 | +#-------------------------------------------------- |
| 230 | + |
| 231 | +echo -e "* Create service file" |
| 232 | +cat <<EOF > ~/$OE_CONFIG.service |
| 233 | +[Unit] |
| 234 | +Description=Odoo server |
| 235 | +Documentation=https://odoo.com |
| 236 | +After=network.target |
| 237 | +
|
| 238 | +[Service] |
| 239 | +User=odoo |
| 240 | +Group=odoo |
| 241 | +ExecStart=$OE_PYTHON_ENV/bin/python $OE_HOME_EXT/odoo-bin --config=/etc/${OE_CONFIG}.conf |
| 242 | +
|
| 243 | +
|
| 244 | +[Install] |
| 245 | +WantedBy=multi-user.target |
| 246 | +
|
| 247 | +EOF |
| 248 | + |
| 249 | +echo -e "* Security Init File" |
| 250 | +mv ~/$OE_CONFIG.service /etc/systemd/system/$OE_CONFIG.service |
| 251 | + |
| 252 | +echo -e "* Start ODOO on Startup" |
| 253 | +systemctl enable $OE_CONFIG.service |
| 254 | + |
| 255 | + |
| 256 | +echo -e "* Starting Odoo Service" |
| 257 | +systemctl start $OE_CONFIG.service |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | +echo "-----------------------------------------------------------" |
| 264 | +echo "Done! The Odoo server is up and running. Specifications:" |
| 265 | +echo "Port: $OE_PORT" |
| 266 | +echo "User service: $OE_USER" |
| 267 | +echo "User PostgreSQL: $OE_USER" |
| 268 | +echo "Code location: $OE_USER" |
| 269 | +echo "Addons folder: $OE_USER/$OE_CONFIG/addons/" |
| 270 | +echo "Start Odoo service: systemctl start $OE_CONFIG.service" |
| 271 | +echo "Stop Odoo service: systemctl stop $OE_CONFIG.service" |
| 272 | +echo "Restart Odoo service: systemctl restart $OE_CONFIG.service" |
| 273 | +echo "-----------------------------------------------------------" |
0 commit comments