diff --git a/install-odoo.sh b/install-odoo.sh index 6e1d4e9..a3c36dd 100644 --- a/install-odoo.sh +++ b/install-odoo.sh @@ -1,41 +1,10 @@ #!/bin/bash -# -# Author: Sherif Khaled -# Copyright (c) 2019. -# -# This program is free software; you can redistribute it and/or modify it under the -# terms of the GNU Lesser General Public License as published by the Free Software -# Foundation; either version 3.0 of the License, or (at your option) any later -# version. -# -# This install-odoo.sh script automates many of the instrallation and configuration -# steps at -# https://www.odoo.com/documentation/10.0/setup/install.html -# -# Eamples:- -# Install odoo version 10 and configure using server external IP address -# .\install-odoo.sh -v 10 -# -# Install odoo version 10 and configure using hostname odoo.example.com -# .\install-odoo.sh -v 10 -s odoo.example.com -# -# Install odoo version 10 with a SSL certificate from Let's Encrypt using e-mail info@example.com: -# .\install-odoo.sh -v 10 -s odoo.example.com -e info@example.com -# -# Install odoo version 10 with specific port 8070 -# .\install-odoo.sh -v 10 -s odoo.example.com -e info@example.com -r 8070 -# -# Install odoo version 10 with postgres password and Master password -# .\install-odoo.sh -v 10 -s odoo.example.com -e info@example.com -r 8070 -p sql123 -P admin123 -# -# Note: this script tested on ubuntu 16.4. -# USAGE(){ cat 1>&2 < Install given version of odoo (e.g. '10.0') [required] + -m Model of odoo system (e.g. 'community') [required] + -p Password for odoo administrator [recommended] - -P setup password for postgresql [recommended] - -r spsifec server port + -P setup password for postgresql [recommended] + -r spsifec server port -h Print help OPTIONS (support SSL) @@ -55,12 +26,13 @@ USAGE(){ EXAMPLES - setup odoo system + setup a odoo system - .\install-odoo.sh -v 10 - .\install-odoo.sh -v 10 -s odoo.example.com -p 123 - .\install-odoo.sh -v 10 -s odoo.example.com -e info@example.com -p 123 -P sql123 - .\install-odoo.sh -v 10 -s odoo.example.com -e info@example.com -p 123 -P sql123 -r 8069 + .\install-odoo.sh -v 10.0 -m community + .\install-odoo.sh -v 10.0 -m community -p admin123 + .\install-odoo.sh -v 10.0 -m community -p admin123 -sp sql123 + .\install-odoo.sh -v 10.0 -m community -p admin123 -sp sql123 + .\install-odoo.sh -v 10.0 -m community -p admin123 -sp sql123 -port 8069 SUPPORT: Source: https://github.com/Sherif-khaled/install-odoo @@ -79,7 +51,7 @@ main(){ HOST=$EXTERNAL_IP PORT=8069 - while builtin getopts "hv:p:P:r:s:e:" opt "${@}"; do + while builtin getopts "hv:m:p:P:r:s:e:" opt "${@}"; do case $opt in h) USAGE @@ -90,6 +62,10 @@ main(){ VERSION=$OPTARG check_version $VERSION ;; + m) + MODEL=$OPTARG + check_model $MODEL + ;; p) PASS=$OPTARG check_admin_pass $PASS @@ -155,6 +131,20 @@ check_version(){ esac } +check_model(){ + model='' + if [ -z $1 ];then + err "please select odoo model" + else + if [ $1 == "community" ];then + model='community' + elif [ $1 == 'enterprise' ];then + model='enterprise' + else + err "check the model spling" + fi + fi +} check_admin_pass(){ if [ -z $1 ];then err "please enter the admin password" @@ -248,7 +238,7 @@ install_dependencies(){ eval "apt-get install ${dependencies[$i]} -y" done - if [ $VERSION -eq 10 ] || [ $VERSION -eq 9 ];then + if [ $VERSION -eq 10 ];then for (( i = 0; i < ${#python_env[@]} ; i++ )); do printf "\n**** python env installing now: ${python_env[$i]} *****\n\n" @@ -257,7 +247,7 @@ install_dependencies(){ eval "apt-get install ${python_env[$i]} -y" done -elif [ $VERSION -eq 12 ] || [ $VERSION -eq 11 ];then +elif [ $VERSION -eq 12 ];then for (( i = 0; i < ${#python3_env[@]} ; i++ )); do printf "\n**** python3 env Installing now : ${python3_env[$i]} *****\n\n" @@ -269,9 +259,7 @@ fi create_user(){ #create postgresql user #createuser odoo10 -U postgres -dRS | printf '123456\n123456\n' | ./install-odoo.sh -# su - postgres && createuser odoo$VERSION -U postgres -dRS && printf '123456\n123456\n' && exit - sudo -u postgres -H -- psql -d postgres -c "CREATE USER odoo$VERSION WITH PASSWORD '$PASS'" - sudo -u postgres -H -- psql -d postgres -c "ALTER USER odoo$VERSION WITH SUPERUSER;" + su - postgres && createuser odoo$VERSION -U postgres -dRS && printf '123456\n123456\n' && exit #create odoo user adduser --system --home=/opt/odoo$VERSION --group odoo$VERSION @@ -398,10 +386,10 @@ systemctl restart nginx } create_ssl_cert(){ - echo -n "\n" | add-apt-repository ppa:certbot/certbot + add-apt-repository ppa:certbot/certbot apt-get update apt-get install python-certbot-nginx -y - yes N | certbot --nginx -d $HOST -d www.$HOST -m $EMAIL --agree-tos + certbot --nginx -d $HOST -d www.$HOST -m $EMAIL --agree-tos openssl dhparam -out /etc/nginx/dhparams.pem 4096 chmod 600 /etc/nginx/dhparams.pem service nginx restart @@ -503,17 +491,10 @@ test_the_server(){ } print_url(){ if [ -z $EMAIL ];then - HOST=http://$HOST + echo http://$HOST else - HOST=https://$HOST + echo https://$HOST fi - cat 1>&2 <