odoo 10.0部署shell
环境ubuntu16+nginx+python2.7.12+postgresql9.5+odoo 10.0 community
1 #!/bin/bash 2 #author:guoyihot@outlook.com bonainfo.com 3 #date:2017-09-06 4 #license:LGPL V3 5 #description:部署odoo 10.0 shell ubuntu >=14 6 7 8 odoo_options='gevent -c /usr/local/odoo/odoo.config' 9 odoo_parent_path=/usr/local 10 odoo_path=/usr/local/odoo 11 svc_odoo_user_name=odoo 12 svc_nginx_user_name=nginx 13 odoo_config_path=$odoo_path/odoo.config 14 odoo_pwd=123456 15 odoo_svc_root=/usr/lib/systemd/system 16 odoo_svc_path=$odoo_svc_root/odoo.service 17 18 19 echo '===================create user odoo for odoo serivce================== ' 20 sudo useradd $svc_odoo_user_name 21 sudo passwd $svc_odoo_user_name 22 23 echo '===================create user nginx for nginx========================' 24 sudo useradd $svc_nginx_user_name 25 sudo passwd $svc_nginx_user_name 26 27 28 echo '===================install soft gcc,git,nginx.......===================' 29 sudo apt-get update 30 31 sudo apt-get install gcc git nginx postgresql node.js python python-pip python-dev libxml2-dev libxslt-dev zlib1g-dev libldap2-dev libsasl2-dev 32 33 echo '===================git check out odoo source code .....=================' 34 sudo rm -rf $odoo_path 35 sudo mkdir $odoo_path 36 sudo git clone https://github.com/odoo/odoo.git $odoo_path 37 38 echo '=================== pip install -r requirements.txt=====================' 39 sudo pip install -r $odoo_path/requirements.txt 40 41 sudo apt-get install -y npm 42 sudo ln -s /usr/bin/nodejs /usr/bin/node 43 sudo npm install -g less 44 45 echo '====================config postgresql user info.....===================' 46 sudo su - postgres psql -c 'createuser -s -P -l -e odoo' 47 48 echo '==================create odoo.config==================================' 49 50 #修改文件夹权限 51 sudo chmod o+rw /var/lib 52 sudo chmod o+rw /var/log 53 54 cat<<EOF | sudo tee $odoo_config_path 55 [options] 56 addons_path = /usr/local/odoo/odoo/addons,/usr/local/odoo/addons 57 admin_passwd = admin 58 csv_internal_sep = , 59 data_dir = /var/lib/odoo 60 db_host = False 61 db_maxconn = 64 62 db_name = False 63 db_password = $odoo_pwd 64 db_port = False 65 db_template = template1 66 db_user = $svc_odoo_user_name 67 dbfilter = .* 68 demo = {} 69 email_from = False 70 geoip_database = /usr/share/GeoIP/GeoLiteCity.dat 71 import_partial = 72 limit_memory_hard = 2684354560 73 limit_memory_soft = 2147483648 74 limit_request = 8192 75 limit_time_cpu = 60 76 limit_time_real = 120 77 limit_time_real_cron = -1 78 list_db = True 79 log_db = False 80 log_db_level = warning 81 log_handler = :INFO 82 log_level = info 83 logfile = /var/log/odoo/log.txt 84 logrotate = True 85 longpolling_port = 8072 86 max_cron_threads = 2 87 osv_memory_age_limit = 1.0 88 osv_memory_count_limit = False 89 pg_path = None 90 pidfile = None 91 proxy_mode = False 92 reportgz = False 93 server_wide_modules = web,web_kanban 94 smtp_password = False 95 smtp_port = 25 96 smtp_server = localhost 97 smtp_ssl = False 98 smtp_user = False 99 syslog = False 100 test_commit = False 101 test_enable = False 102 test_file = False 103 test_report_directory = False 104 translate_modules = ['all'] 105 unaccent = False 106 without_demo = False 107 workers = 0 108 xmlrpc = True 109 xmlrpc_interface = 110 xmlrpc_port = 8069 111 EOF 112 113 #配置odoo服务 114 echo '===========================config odoo.service=======================' 115 sudo mkdir $odoo_svc_root 116 117 cat<<EOF | sudo tee $odoo_svc_path 118 [Unit] 119 120 Description=Odoo 121 122 After=postgresql.service 123 124 [Service] 125 126 Type=simple 127 128 User=odoo 129 130 Group=odoo 131 132 ExecStart=/usr/local/odoo/odoo-bin $odoo_options 133 134 [Install] 135 136 WantedBy=multi-user.target 137 138 EOF 139 140 echo '================================enble odoo.service====================' 141 sudo systemctl daemon-reload 142 sudo systemctl enable $odoo_svc_path 143 echo '================================restart odoo.service==================' 144 sudo systemctl restart odoo.service 145 sudo systemctl status odoo.service 146 147 148 149 #配置nginx 150 #先备份 151 echo '===============================config nginx==========================' 152 sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx_conf_default 153 154 http_host='$http_host' 155 remote_addr='$remote_addr' 156 scheme='$scheme' 157 http_upgrade='$http_upgrade' 158 159 cat<<EOF | sudo tee /etc/nginx/nginx.conf 160 worker_processes 2; 161 events { 162 use epoll; 163 worker_connections 65535; 164 } 165 http { 166 include mime.types; 167 default_type application/octet-stream; 168 sendfile on; 169 server_tokens off; 170 keepalive_timeout 10; 171 tcp_nodelay on; 172 gzip on; 173 upstream fkcloud { 174 server 127.0.0.1:8072; 175 } 176 server { 177 listen 80; 178 server_name localhost; 179 location / { 180 proxy_pass_header Server; 181 proxy_set_header Host $http_host; 182 proxy_redirect off; 183 proxy_set_header X-Real-IP $remote_addr; 184 proxy_set_header X-Scheme $scheme; 185 proxy_http_version 1.1; 186 proxy_set_header Upgrade $http_upgrade; 187 proxy_set_header Connection "Upgrade"; 188 proxy_pass http://fkcloud; 189 client_max_body_size 20m; 190 } 191 } 192 } 193 194 195 EOF 196 197 sudo systemctl daemon-reload 198 #备份 sites-available 199 sudo cp /etc/nginx/sites-available/default /home/$svc_nginx_user_name/sites-available_default 200 sudo rm -rf /etc/nginx/sites-available/default 201 202 # 解决Failed to read PID from file /run/nginx.pid: Invalid argument 203 sudo mkdir -p /etc/systemd/system/nginx.service.d 204 echo "[Service]\nExecStartPost=/bin/sleep 0.1\n" | sudo tee /etc/systemd/system/nginx.service.d/override.conf 205 sudo systemctl daemon-reload 206 sudo nginx -s reload 207 sudo systemctl restart nginx.service 208 sudo systemctl status nginx.service
清风明月入怀抱,猿鹤听我再抚琴