You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
11 KiB

4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
  1. #!/bin/bash
  2. # modified for cloudron - Samir Saidani
  3. ################################################################################
  4. # Script for installing Odoo on Ubuntu 14.04, 15.04, 16.04 and 18.04 (could be used for other version too)
  5. # Author: Yenthe Van Ginneken
  6. #-------------------------------------------------------------------------------
  7. # This script will install Odoo on your Ubuntu 16.04 server. It can install multiple Odoo instances
  8. # in one Ubuntu 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. OE_USER="odoo"
  18. OE_HOME="/app/code"
  19. OE_HOME_EXT="$OE_HOME/${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="False"
  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: 12.0, 11.0, 10.0 or saas-18. When using 'master' the master version will be installed.
  26. # IMPORTANT! This script contains extra libraries that are specifically needed for Odoo 12.0
  27. OE_VERSION="12.0"
  28. # Set this to True if you want to install the Odoo enterprise version!
  29. IS_ENTERPRISE="False"
  30. # set the superadmin password
  31. OE_SUPERADMIN="admin"
  32. OE_CONFIG="${OE_USER}"
  33. ##
  34. ### WKHTMLTOPDF download links
  35. ## === Ubuntu Trusty x64 & x32 === (for other distributions please replace these two links,
  36. ## in order to have correct version of wkhtmltopdf installed, for a danger note refer to
  37. ## https://github.com/odoo/odoo/wiki/Wkhtmltopdf ):
  38. WKHTMLTOX_X64=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.trusty_amd64.deb
  39. WKHTMLTOX_X32=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.trusty_i386.deb
  40. #--------------------------------------------------
  41. # Update Server
  42. #--------------------------------------------------
  43. echo -e "\n---- Update Server ----"
  44. # add-apt-repository can install add-apt-repository Ubuntu 18.x
  45. sudo apt-get install software-properties-common -y
  46. # universe package is for Ubuntu 18.x
  47. sudo add-apt-repository universe
  48. # libpng12-0 dependency for wkhtmltopdf
  49. sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu/ xenial main"
  50. sudo apt-get update
  51. sudo apt-mark hold postfix phpmyadmin
  52. sudo apt-get upgrade -y
  53. #--------------------------------------------------
  54. # Install PostgreSQL Server
  55. #--------------------------------------------------
  56. #echo -e "\n---- Install PostgreSQL Server ----"
  57. #sudo apt-get install postgresql -y
  58. echo -e "\n---- Creating the ODOO PostgreSQL User ----"
  59. sudo su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true
  60. #--------------------------------------------------
  61. # Install Dependencies
  62. #--------------------------------------------------
  63. echo -e "\n--- Installing Python 3 + pip3 --"
  64. sudo apt-get install git python3 python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libpng12-0 gdebi -y
  65. sudo apt-get install python3-pypdf2 -y
  66. echo -e "\n---- Upgrade pip ----"
  67. pip install --upgrade pip
  68. echo -e "\n---- Install python packages/requirements ----"
  69. sudo pip3 install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt
  70. echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
  71. sudo apt-get install nodejs npm -y
  72. #sudo npm install -g rtlcss
  73. echo -e "\n---- Installing modules necessary for mysqldb ----"
  74. sudo pip3 install pyserial
  75. #--------------------------------------------------
  76. # Install Wkhtmltopdf if needed
  77. #--------------------------------------------------
  78. if [ $INSTALL_WKHTMLTOPDF = "True" ]; then
  79. echo -e "\n---- Install wkhtml and place shortcuts on correct place for ODOO 12 ----"
  80. #pick up correct one from x64 & x32 versions:
  81. if [ "`getconf LONG_BIT`" == "64" ];then
  82. _url=$WKHTMLTOX_X64
  83. else
  84. _url=$WKHTMLTOX_X32
  85. fi
  86. sudo wget $_url
  87. sudo apt-get install gdebi-core -y
  88. sudo gdebi --n `basename $_url`
  89. sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
  90. sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
  91. else
  92. echo "Wkhtmltopdf isn't installed due to the choice of the user!"
  93. fi
  94. echo -e "\n---- Create ODOO system user ----"
  95. sudo adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'ODOO' --group $OE_USER
  96. #The user should also be added to the sudo'ers group.
  97. sudo adduser $OE_USER sudo
  98. sudo chown -R $OE_USER:$OE_USER /app/code
  99. sudo chown -R $OE_USER:$OE_USER /app/data
  100. echo -e "\n---- Create Log directory ----"
  101. sudo mkdir /var/log/$OE_USER
  102. sudo chown $OE_USER:$OE_USER /var/log/$OE_USER
  103. #--------------------------------------------------
  104. # Install ODOO
  105. #--------------------------------------------------
  106. echo -e "\n==== Installing ODOO Server ===="
  107. sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/
  108. if [ $IS_ENTERPRISE = "True" ]; then
  109. # Odoo Enterprise install!
  110. echo -e "\n--- Create symlink for node"
  111. sudo ln -s /usr/bin/nodejs /usr/bin/node
  112. sudo su $OE_USER -c "mkdir $OE_HOME/enterprise"
  113. sudo su $OE_USER -c "mkdir $OE_HOME/enterprise/addons"
  114. GITHUB_RESPONSE=$(sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
  115. while [[ $GITHUB_RESPONSE == *"Authentication"* ]]; do
  116. echo "------------------------WARNING------------------------------"
  117. echo "Your authentication with Github has failed! Please try again."
  118. 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"
  119. echo "TIP: Press ctrl+c to stop this script."
  120. echo "-------------------------------------------------------------"
  121. echo " "
  122. GITHUB_RESPONSE=$(sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/enterprise "$OE_HOME/enterprise/addons" 2>&1)
  123. done
  124. echo -e "\n---- Added Enterprise code under $OE_HOME/enterprise/addons ----"
  125. echo -e "\n---- Installing Enterprise specific libraries ----"
  126. sudo pip3 install num2words ofxparse
  127. sudo npm install -g less
  128. sudo npm install -g less-plugin-clean-css
  129. fi
  130. echo -e "\n---- Create custom module directory ----"
  131. # sudo su $OE_USER -c "mkdir $OE_HOME/custom"
  132. # sudo su $OE_USER -c "mkdir $OE_HOME/custom/addons"
  133. sudo su $OE_USER -c "mkdir $OE_HOME/extra-addons"
  134. echo -e "\n---- Setting permissions on home folder ----"
  135. sudo chown -R $OE_USER:$OE_USER $OE_HOME/*
  136. echo -e "* Create server config file"
  137. sudo touch /app/data/${OE_CONFIG}.conf
  138. sudo chown $OE_USER:$OE_USER /app/data/${OE_CONFIG}.conf
  139. sudo chmod 640 /app/data/${OE_CONFIG}.conf
  140. echo -e "* Creating server config file"
  141. sudo su root -c "printf '[options] \n; This is the password that allows database operations:\n' >> /app/data/${OE_CONFIG}.conf"
  142. sudo su root -c "printf 'admin_passwd = ${OE_SUPERADMIN}\n' >> /app/data/${OE_CONFIG}.conf"
  143. sudo su root -c "printf 'xmlrpc_port = ${OE_PORT}\n' >> /app/data/${OE_CONFIG}.conf"
  144. sudo su root -c "printf 'logfile =/var/log/${OE_USER}/${OE_CONFIG}.log\n' >> /app/data/${OE_CONFIG}.conf"
  145. if [ $IS_ENTERPRISE = "True" ]; then
  146. sudo su root -c "printf 'addons_path=${OE_HOME}/enterprise/addons,${OE_HOME_EXT}/addons\n' >> /app/data/${OE_CONFIG}.conf"
  147. else
  148. sudo su root -c "printf 'addons_path=${OE_HOME_EXT}/addons,${OE_HOME}/extra-addons\n' >> /app/data/${OE_CONFIG}.conf"
  149. fi
  150. echo -e "* Create startup file"
  151. sudo su root -c "echo '#!/bin/sh' >> $OE_HOME_EXT/start-odoo.sh"
  152. sudo su root -c "echo 'sudo -u $OE_USER $OE_HOME_EXT/odoo-bin --config=/app/data/${OE_CONFIG}.conf' >> $OE_HOME_EXT/start-odoo.sh"
  153. sudo chmod 755 $OE_HOME_EXT/start-odoo.sh
  154. #--------------------------------------------------
  155. # Adding ODOO as a deamon (initscript)
  156. #--------------------------------------------------
  157. echo -e "* Create init file"
  158. cat <<EOF > ~/$OE_CONFIG
  159. #!/bin/sh
  160. ### BEGIN INIT INFO
  161. # Provides: $OE_CONFIG
  162. # Required-Start: \$remote_fs \$syslog
  163. # Required-Stop: \$remote_fs \$syslog
  164. # Should-Start: \$network
  165. # Should-Stop: \$network
  166. # Default-Start: 2 3 4 5
  167. # Default-Stop: 0 1 6
  168. # Short-Description: Enterprise Business Applications
  169. # Description: ODOO Business Applications
  170. ### END INIT INFO
  171. PATH=/bin:/sbin:/usr/bin
  172. DAEMON=$OE_HOME_EXT/odoo-bin
  173. NAME=$OE_CONFIG
  174. DESC=$OE_CONFIG
  175. # Specify the user name (Default: odoo).
  176. USER=$OE_USER
  177. # Specify an alternate config file (Default: /etc/openerp-server.conf).
  178. CONFIGFILE="/app/data/${OE_CONFIG}.conf"
  179. # pidfile
  180. PIDFILE=/var/run/\${NAME}.pid
  181. # Additional options that are passed to the Daemon.
  182. DAEMON_OPTS="-c \$CONFIGFILE"
  183. [ -x \$DAEMON ] || exit 0
  184. [ -f \$CONFIGFILE ] || exit 0
  185. checkpid() {
  186. [ -f \$PIDFILE ] || return 1
  187. pid=\`cat \$PIDFILE\`
  188. [ -d /proc/\$pid ] && return 0
  189. return 1
  190. }
  191. case "\${1}" in
  192. start)
  193. echo -n "Starting \${DESC}: "
  194. start-stop-daemon --start --quiet --pidfile \$PIDFILE \
  195. --chuid \$USER --background --make-pidfile \
  196. --exec \$DAEMON -- \$DAEMON_OPTS
  197. echo "\${NAME}."
  198. ;;
  199. stop)
  200. echo -n "Stopping \${DESC}: "
  201. start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
  202. --oknodo
  203. echo "\${NAME}."
  204. ;;
  205. restart|force-reload)
  206. echo -n "Restarting \${DESC}: "
  207. start-stop-daemon --stop --quiet --pidfile \$PIDFILE \
  208. --oknodo
  209. sleep 1
  210. start-stop-daemon --start --quiet --pidfile \$PIDFILE \
  211. --chuid \$USER --background --make-pidfile \
  212. --exec \$DAEMON -- \$DAEMON_OPTS
  213. echo "\${NAME}."
  214. ;;
  215. *)
  216. N=/etc/init.d/\$NAME
  217. echo "Usage: \$NAME {start|stop|restart|force-reload}" >&2
  218. exit 1
  219. ;;
  220. esac
  221. exit 0
  222. EOF
  223. echo -e "* Security Init File"
  224. sudo mv ~/$OE_CONFIG /etc/init.d/$OE_CONFIG
  225. sudo chmod 755 /etc/init.d/$OE_CONFIG
  226. sudo chown root: /etc/init.d/$OE_CONFIG
  227. echo -e "* Start ODOO on Startup"
  228. sudo update-rc.d $OE_CONFIG defaults
  229. echo -e "* Starting Odoo Service"
  230. sudo su root -c "/etc/init.d/$OE_CONFIG start"
  231. echo "-----------------------------------------------------------"
  232. echo "Done! The Odoo server is up and running. Specifications:"
  233. echo "Port: $OE_PORT"
  234. echo "User service: $OE_USER"
  235. echo "User PostgreSQL: $OE_USER"
  236. echo "Code location: $OE_USER"
  237. echo "Addons folder: $OE_HOME/addons/"
  238. echo "Start Odoo service: sudo service $OE_CONFIG start"
  239. echo "Stop Odoo service: sudo service $OE_CONFIG stop"
  240. echo "Restart Odoo service: sudo service $OE_CONFIG restart"
  241. echo "-----------------------------------------------------------"