`

ODOO9 SAAS 全自动安装脚本 基于Ubuntu 14.04 LTS

 
阅读更多

 

install-odoo-saas.sh

 

#!/bin/bash
################################################################################################
# Fully automated script to install Odoo and Odoo SaaS Tool (tested on a fresh Ubuntu 14.04 LTS)
# * Install & configure last stable version of nginx
# * Install & configure last stable version of postgresql
# * Install & configure Odoo
# * Configure automated backup of Odoo databases
# * Optional: Install & configure Odoo SaaS Tool
# * Optional: Background installation: $ nohup ./odoo_install.sh > nohup.log 2>&1 </dev/null &
################################################################################################
#### GENERAL SETTINGS : Edit the following settings as needed
## Gist url
export GIST="bassn/996f8b168f0b1406dd54" #update if you've forked this gist
## E-Mail
export EMAIL_SERVER=stmp.example.com
export EMAIL_USER=mail@example.com
export EMAIL_PASS=GiveMeYourPassBaby
## PostgreSQL
export DB_PASS=`< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo;`
## Odoo
export ODOO_DOMAIN=odoo.example.com
export ODOO_DATABASE=odoo.example.com
export ODOO_USER=odoo
export ODOO_BRANCH=8.0
export ODOO_PASS=`< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-12};echo;`
## SSL
export SSL_CERT=/etc/ssl/certs/XXXX.crt
export SSL_KEY=/etc/ssl/private/XXXX.key
## DB Backup
export DB_BACKUP="yes" #set "no" if you do want to configure backup
## Odoo SaaS Tool
export ODOO_SAAS_TOOL="yes" #set "no" if you do want odoo saas tool
export SAAS_SERVER=server-1
export SAAS_TEMPLATE=template-1
## Add your private Git
export USE_PRIVATE_GIT="no" #Set to "yes", if you want to clone a private Git
export PRIVATE_GIT_REMOTE="https://MY_USER_NAME:MY_PASSWORD@bitbucket.org/MY_REMOTE_USER/MY_REMOTE_REPOSITORY.git" #remote adress of your private Git
export PRIVATE_GIT_LOCAL="/usr/local/src/odoo-addons/MY_LOCAL_ADDON_FOLDER" #local folder of your private Git
#### Detect type of system manager
export SYSTEM=''
pidof systemd && export SYSTEM='systemd'
[[ -z $SYSTEM ]] && whereis upstart | grep -q 'upstart: /' && export SYSTEM='upstart'
[[ -z $SYSTEM ]] && export SYSTEM='supervisor'
echo "SYSTEM=$SYSTEM"
#### CHECK AND UPDATE LANGUAGE
env | grep LANG
export LANGUAGE=en_US:en && \
export LANG=en_US.UTF-8 && \
export LC_ALL=en_US.UTF-8 && \
locale-gen en_US.UTF-8 && \
dpkg-reconfigure locales
locale
#### DOWNLOADS...
### Packages
apt-get update && \
apt-get upgrade -y && \
apt-get install -y git python-pip moreutils tree python-dev && \
apt-get install -y emacs23-nox || apt-get install -y emacs24-nox && \
[[ "$SYSTEM" == "supervisor" ]] && apt-get install supervisor
### PostgreSQL
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' >> /etc/apt/sources.list.d/pgdg.list &&\
apt-get update &&\
apt-get install postgresql postgresql-contrib -y && \
echo "postgresql installed"
### Python
pip install psycogreen &&\
pip install rotate-backups &&\
pip install oauthlib &&\
pip install requests --upgrade
### Deps for OCA website
pip install ipwhois
### Deps for OCA Server tools
apt-get install python-ldap &&
pip install unidecode &&\
pip install unidecode --upgrade
### Deps for addons-vauxoo
pip install pandas
### Deps for Odoo Saas Tool
pip install Boto
pip install FileChunkIO
pip install pysftp
### Odoo Souce Code
# If you change the following directories, you muss also ajust line 2 of file odoo-server.conf below
cd /usr/local/src/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/odoo/odoo.git &&\
mkdir /usr/local/src/odoo-addons -p && cd /usr/local/src/odoo-addons/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/web.git OCA/web/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/website.git OCA/website/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/account-financial-reporting.git OCA/account-financial-reporting/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/account-financial-tools.git OCA/account-financial-tools/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/partner-contact.git OCA/partner-contact/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/hr.git OCA/hr/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/pos.git OCA/pos/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/commission.git OCA/commission/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/server-tools.git OCA/server-tools/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/reporting-engine.git OCA/reporting-engine/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/rma.git OCA/rma/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/contract.git OCA/contract/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/sale-workflow.git OCA/sale-workflow/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/bank-payment.git OCA/bank-payment/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/bank-statement-import.git OCA/bank-statement-import/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/OCA/bank-statement-reconcile.git OCA/bank-statement-reconcile/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/yelizariev/pos-addons.git yelizariev/pos-addons/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/yelizariev/access-addons.git yelizariev/access-addons/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/yelizariev/website-addons.git yelizariev/website-addons/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/yelizariev/addons-yelizariev.git yelizariev/addons-yelizariev/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/yelizariev/odoo-saas-tools.git yelizariev/odoo-saas-tools/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/iledarn/e-commerce.git iledarn/e-commerce/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/xpansa/hr.git xpansa/hr/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/odoomrp/odoomrp-wip.git odoomrp/odoomrp-wip/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/odoomrp/odoomrp-utils.git odoomrp/odoomrp-utils/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/Vauxoo/addons-vauxoo.git vauxoo/ &&\
git clone -b ${ODOO_BRANCH} https://github.com/techreceptives/website_recaptcha.git techreceptives/
if [[ "$USE_PRIVATE_GIT" == "yes" ]] ###################################### IF
then
git clone -b ${ODOO_BRANCH} ${PRIVATE_GIT_REMOTE} ${PRIVATE_GIT_LOCAL}/
export COMMA=","
export PRIVATE_GIT_LOCAL="$PRIVATE_GIT_LOCAL$COMMA"
else ###################################### ELSE
export PRIVATE_GIT_LOCAL=""
fi ###################################### END IF
# further module collections
mkdir -p z-others &&\
mkdir -p z-others-p
### Odoo Deps
## python
python --version # should be 2.7 or higher
cd /usr/local/src/odoo &&\
cp odoo.py odoo.py.orig &&\
sed -i "s/'apt-get'/'apt-get', '-y'/" odoo.py &&\
cat odoo.py | python &&\
git checkout odoo.py
echo "odoo.py checked out"
## wkhtmltopdf
cd /usr/local/src
lsb_release -a
uname -i
# check version of your OS and download appropriate package
# http://wkhtmltopdf.org/downloads.html
apt-get install -y xfonts-base xfonts-75dpi
apt-get -f install
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
dpkg -i wkhtmltox-*.deb
## Less CSS via nodejs
## nodejs:
# for 14.04+
apt-get install -y npm
ln -s /usr/bin/nodejs /usr/bin/node
# for 13.10-
# check https://www.odoo.com/documentation/8.0/setup/install.html
## less css
npm install -g less less-plugin-clean-css
#### ...DOWNLOADS done.
#### Changes on Odoo Code
cd /usr/local/src/odoo
## delete matches="..." at /web/database/manager
sed -i 's/matches="[^"]*"//g' addons/web/static/src/xml/base.xml
## disable im_odoo_support
sed -i "s/'auto_install': True/'auto_install': False/" addons/im_odoo_support/__openerp__.py
#### CONFIGS
### System Config
#from http://stackoverflow.com/questions/2914220/bash-templating-how-to-build-configuration-files-from-templates-with-bash
export PERL_UPDATE_ENV="perl -p -e 's/\{\{([^}]+)\}\}/defined \$ENV{\$1} ? \$ENV{\$1} : \$&/eg' "
[[ -z $SYSTEM ]] && echo "Don't forget to define SYSTEM variable"
### Odoo System User
adduser --system --quiet --shell=/bin/bash --home=/opt/${ODOO_USER} --gecos '$OE_USER' --group ${ODOO_USER}
### Odoo DB User
sudo su - postgres bash -c "psql -c \"CREATE USER ${ODOO_USER} WITH CREATEDB PASSWORD '${DB_PASS}';\""
### Odoo Config
echo "Odoo Config"
## /var/log/odoo/
mkdir -p /var/log/odoo/
chown ${ODOO_USER}:${ODOO_USER} /var/log/odoo
## /temp import data
mkdir -p /opt/${ODOO_USER}/.local/share/User/import/
chown -R ${ODOO_USER}:${ODOO_USER} /opt/${ODOO_USER}/.local
## /etc/odoo/odoo-server.conf
mkdir -p /etc/odoo && cd /etc/odoo/
wget -q https://gist.githubusercontent.com/${GIST}/raw/odoo-server.conf -O odoo-server.conf
eval "${PERL_UPDATE_ENV} < odoo-server.conf" | sponge odoo-server.conf
chown ${ODOO_USER}:${ODOO_USER} odoo-server.conf
chmod 600 odoo-server.conf
#### NGINX
#/etc/init.d/apache2 stop
#apt-get remove apache2 -y && \
wget --quiet -O - http://nginx.org/keys/nginx_signing.key | apt-key add - &&\
echo 'deb http://nginx.org/packages/ubuntu/ trusty nginx' >> /etc/apt/sources.list.d/nginx.list &&\
echo 'deb-src http://nginx.org/packages/ubuntu/ trusty nginx' >> /etc/apt/sources.list.d/nginx.list &&\
apt-get update &&\
apt-get install nginx -y && \
echo "nginx installed"
cd /etc/nginx && \
mv nginx.conf nginx.conf.orig &&\
wget -q https://gist.githubusercontent.com/${GIST}/raw/nginx.conf -O nginx.conf
cd /etc/nginx && \
wget -q https://gist.githubusercontent.com/${GIST}/raw/nginx_odoo_params -O odoo_params && \
eval "${PERL_UPDATE_ENV} < odoo_params" | sponge odoo_params
mkdir /etc/nginx/sites-available/ -p && \
cd /etc/nginx/sites-available/ && \
wget -q https://gist.githubusercontent.com/${GIST}/raw/nginx_odoo.conf -O odoo.conf && \
eval "${PERL_UPDATE_ENV} < odoo.conf" | sponge odoo.conf
mkdir /etc/nginx/sites-enabled/ -p && \
cd /etc/nginx/sites-enabled/ && \
ln -s ../sites-available/odoo.conf odoo.conf
#cd /etc/nginx/ && \
cp -r /etc/nginx/conf.d/ /etc/nginx/conf.d.orig/
rm /etc/nginx/conf.d/default.conf && \
rm /etc/nginx/conf.d/example_ssl.conf
/etc/init.d/nginx restart
#### START CONTROL
### CONTROL SCRIPTS - systemd
if [[ "$SYSTEM" == "systemd" ]] ###################################### IF
then
cd /lib/systemd/system/
wget -q https://gist.githubusercontent.com/${GIST}/raw/odoo.service -O odoo.service
eval "${PERL_UPDATE_ENV} < odoo.service" | sponge odoo.service
## START - systemd
systemctl enable odoo.service
systemctl restart odoo.service
### CONTROL SCRIPTS - upstart
elif [[ "$SYSTEM" == "upstart" ]] #################################### ELIF
then
cd /etc/init/
wget -q https://gist.githubusercontent.com/${GIST}/raw/odoo-init.conf -O odoo.conf
eval "${PERL_UPDATE_ENV} < odoo.conf" | sponge odoo.conf
## START - upstart
start odoo # alt: stop odoo / restart odoo
### CONTROL SCRIPTS - supervisor
else #################################### ELSE
cd /etc/supervisor/conf.d/
wget -q https://gist.githubusercontent.com/${GIST}/raw/odoo-supervisor.conf -O odoo.conf
eval "${PERL_UPDATE_ENV} < odoo.conf" | sponge odoo.conf
## START - supervisor
supervisorctl reread
supervisorctl update
supervisorctl restart odoo
fi ################################ END IF
echo "Do not forget to set server parameter report.url = 0.0.0.0:8069"
### CONTROL SCRIPTS - /etc/init.d/*
# Such scripts are not recommended, because you will not get supervision features.
# Use this link to find ones: https://gist.github.com/yelizariev/2abdd91d00dddc4e4fa4/d0ac3bd971e81213d17332647d9a74a580cfde6b
#### ODOO DB BACKUP
if [[ "$DB_BACKUP" == "yes" ]] ###################################### IF
then
mkdir -p /opt/${ODOO_USER}/backups/
chown ${ODOO_USER}:${ODOO_USER} /opt/${ODOO_USER}/backups/
cd /usr/local/bin/
wget -q https://gist.githubusercontent.com/${GIST}/raw/odoo-backup.py -O odoo-backup.py
chmod +x odoo-backup.py
echo "### check url for undestanding time parameters: https://github.com/xolox/python-rotate-backups" >> /etc/crontab
echo -e "#6 6\t* * *\t${ODOO_USER} odoo-backup.py -d ${ODOO_DATABASE} -p /opt/${ODOO_USER}/backups/ --no-save-filestore --daily 8 --weekly 0 --monthly 0 --yearly 0" >> /etc/crontab
echo -e "#4 4\t* * 7\t${ODOO_USER} odoo-backup.py -d ${ODOO_DATABASE} -p /opt/${ODOO_USER}/backups/" >> /etc/crontab
## to test run:
# sudo su - ${ODOO_USER} -s /bin/bash -c "odoo-backup.py -d ${ODOO_DATABASE} -p /opt/${ODOO_USER}/backups/"
# e.g.
# cd /usr/local/bin/ && sudo su - odoo -s /bin/bash -c "odoo-backup.py -d ergodoo.com -p /opt/odoo/backups/"
fi ################################## END IF
#### Odoo Saas Tool
if [[ "$ODOO_SAAS_TOOL" == "yes" ]] ###################################### IF
then
#emacs /etc/odoo/odoo-server.conf # change dbfilter to ^%h$ if needed
echo $ODOO_PASS
echo $ODOO_DOMAIN
stop odoo
sudo su - ${ODOO_USER} -s /bin/bash -c "python /usr/local/src/odoo-addons/yelizariev/odoo-saas-tools/saas.py \
--odoo-script=/usr/local/src/odoo/openerp-server \
--odoo-config=/etc/odoo/odoo-server.conf \
--portal-create --server-create --plan-create --run \
--admin-password=${ODOO_PASS} \
--portal-db-name=${ODOO_DOMAIN} \
--server-db-name=${SAAS_SERVER}.${ODOO_DOMAIN} \
--plan-template-db-name=${SAAS_TEMPLATE}.${ODOO_DOMAIN} \
--plan-clients=demo-%i.${ODOO_DOMAIN}"
fi ################################## END IF
#### DEBUG
## show settings (admin password, addons path)
head /etc/odoo/odoo-server.conf
## show odoo version
grep '^version_info ' /usr/local/src/odoo/openerp/release.py
## Reminders
echo "Do not forget PGTune: http://pgtune.leopard.in.ua/"
## log
tail -f -n 100 /var/log/odoo/odoo-server.log
## start from console (for ODOO_USER=odoo):
# sudo su - odoo -s /bin/bash -c "/usr/local/src/odoo/openerp-server -c /etc/odoo/odoo-server.conf"
## psql (use name of your database)
# sudo -u odoo psql DATABASE
## some common issues:
## https://www.odoo.com/forum/help-1/question/dataerror-new-encoding-utf8-is-incompatible-with-the-encoding-of-the-template-database-sql-ascii-52124

 

分享到:
评论

相关推荐

    Odoo saas~16.3 (最新版本)

    SaaS(Software as a Service)代表了软件的交付模式,用户通过网络访问而非本地安装,这通常意味着 Odoo 16.3 可以作为云服务提供,便于远程管理和多用户协作。 总的来说,Odoo 16.3的发布带来了诸多改进和新特性...

    odoo-saas-tools-12.0.zip

    Odoo SaaS Tools System to sale and manage odoo databases. Main Project Website: https://it-projects-llc.github.io/odoo-saas-tools/ Getting Started: ...

    Ubuntu14.04下安装Odoo8正式版

    这是一篇翻译文章,出处为 ...8-on-ubuntu-server-14-04-lts/ 原作者为Alan Lord 由odoo 中文社区 郑州-Dean 翻译。本文内容大致与原文一致,翻译时根据国内 情况,有少量修改。

    odoo-saas-tools-11.0.zip

    Odoo SaaS Tools System to sale and manage odoo databases. Main Project Website: https://it-projects-llc.github.io/odoo-saas-tools/ Getting Started: ...

    OdooScript:适用于Ubuntu 14.04、15.04、16.04、18.04的Odoo 10 11 12.13安装脚本(通用)

    OdooScript 适用于Ubuntu 14.04、15.04、16.04的Odoo依赖安装脚本(通用) 在运行脚本后,必须使用pycharm IDE使您的环境为所有odoo做好准备,您必须手动下载odoo复制此脚本并在您的终端上运行出口LC_ALL =“ zh_...

    odoo一键安装脚本(修改增加中文字体安装)

    odoo一键安装脚本(修改增加中文字体安装)

    Odoo12一键安装脚本.txt

    Odoo12一键安装脚本命令 下载文件成功后需要自行编辑一下 编辑包含删除文件内无用提示以及服务器安装时需要你指定的安装路径 编辑完成后以.sh为结尾保存文件即可在服务器通过命令一键执行安装

    odoo install script for ubuntu-ubuntu安装

    odoo ubuntu ubuntu安装 ubuntu安装 ubuntu安装 ubuntu安装 ubuntu安装

    Ubuntu20.04/Win10安装配置Odoo14

    Ubuntu20.04 和Win10系统下 配置python虚拟环境 PostgreSQL安装 Odoo14安装 以及Win10系统Pycharm配置Odoo

    Odoo9启动脚本

    Odoo9启动脚本,批处理地运行odoo服务器的启动和停止等动作。

    odoo8安装步骤

    ### Odoo 8 在 CentOS Linux 下的安装步骤详解 Odoo 是一款开源的企业资源管理系统,提供了包括销售管理、采购管理、库存管理等在内的多种业务功能模块。Odoo 的前身是 OpenERP,在版本 8 中正式更名为 Odoo。本文...

    odoo-saas-manager:odoo SaaS管理器模块

    odoo-saas-manager(已弃用) 抱歉,这个项目已经折旧了,我们现在正在处理,这是一个比这个更大的项目。 我们使这个项目继续进行下去,因为仍然需要迁移到odoo基础设施一些内容。 对不起!

    全新odoo_win10安装手册1

    在本教程中,我们将详细讲解如何在Windows 10操作系统上安装和配置Odoo。首先,我们需要确保使用的是Python 2.7版本,因为当前版本的Odoo还不支持Python 3。你可以从Python官方网站下载32位的2.7版本(例如2.7.13....

    odoo-digitalocean-ubuntu-lamp-install:带有SSH和反向代理的Odoo自动化安装脚本

    具有SSH和反向代理的Odoo v8的自动安装脚本 Odoo v9正在进行中,它将基于 基础 这里有几个odoo安装脚本,以下两个是此脚本的基础。 该脚本特定于下面描述的平台目标。 如果以上脚本对您不起作用,则可以随时尝试...

    ubuntu16.04安装odoo11.docx

    Ubuntu 16.04 安装 Odoo 11 详细教程 本文档旨在指导用户在 Ubuntu 16.04 服务器上安装 Odoo 11,Odoo 11 是一款免费开源的 CRM 客户管理系统。本文将一步步指导用户完成安装过程,包括系统更新、安装依赖项、创建 ...

    ODOO SaaS ERP和CRM_源码下载

    Odoo 是一系列开源商业应用程序,可满足贵公司的所有需求,包括CRM客户关系管理、电子商务、会计、库存、POS、项目管理等。 Odoo 的独特价值定位同时兼顾使用便利性和全面集成性。

    odoo-saas-docker

    Odoo for SaaS解决方案 该存储库包含Odoo(以前的OpenERP)映像,以提供SaaS解决方案。 什么是Odoo Odoo(以前称为OpenERP)是一套用Python编写并根据AGPL许可发行的开源业务应用程序。 这套应用程序套件涵盖了从...

    odoo10 windiws10 源码安装 环境搭建

    odoo10 windiws10 源码安装 环境搭建

    Odoo-Install:Odoo脚本安装

    Este脚本安装和执行社区14.0 no Ubuntu 20.04 Este脚本安装了一个LocalizaçãoBrasileira desenvolvida pela TrustCode。 安装Ubuntu 20.04的必要步骤 Este脚本安装了Odoo 14.0社区版,并在巴西本地发行了TrustCode...

Global site tag (gtag.js) - Google Analytics