Đoạn script tự động cài đặt OpenERP 7.0 trong Ubuntu server

Thảo luận trong 'Linux' bắt đầu bởi admin, 7/2/13.

  1. admin Administrator

    Cách dùng:
    Để tạo một bản OpenERP 7.0 đầy đủ, ta dùng lệnh: ./oe-admin install tên_csdl_mới --full; ví dụ: ./oe-admin install demo_openerp --full
    Để start service OpenERP 7.0, ta dùng lệnh: ./oe-admin start tên_bản_openerp_muốn_chạy; ví dụ: ./oe-admin start demo_openerp
    Nếu muốn thì các bạn chỉnh sửa lại một tí đoạn code ở dưới để chạy theo ý muốn của mình.
    Mã (bash):
    1. #!/bin/bash
    2. ################################################################################
    3. # A one-line installation for OpenERP 7.0 server instances
    4. #-------------------------------------------------------------------------------
    5. # USAGE:
    6. #
    7. # * Setup openerp server and create a first OpenERP7 7 instance
    8. #  oe-admin install [name1] --full
    9. #
    10. # * Create an additional OpenERP7 7 instance
    11. #    oe-admin install [name2]
    12. #
    13. # * Start one OpenERP instance (to the terminal)
    14. #    oe-admin start [name2] [server options]
    15. #
    16. # EXAMPLE:
    17. # oe-admin install development --full
    18. # oe-admin install staging
    19. # oe-admin start staging --xmlrpc-port=8080 &
    20. # oe-admin start development --xmlrpc-port=8080 --debug
    21. #
    22. # Author: Daniel Reis, 2013
    23. ################################################################################
    24.  
    25. #fixed parameters:
    26. OEADMIN_USER="openerp"
    27. OEADMIN_HOME="/opt/openerp"
    28. #sudo apt-get update
    29. #sudo locale-gen en_US en_US.UTF-8
    30. case "$1" in
    31. install)
    32.     #--------------------------------------------------
    33.     # Install required dependencies
    34.     #--------------------------------------------------
    35.     if [ "$3" = "--full" ] ; then
    36.         #Make this script available anywhere:
    37.         #sudo ln -sf /usr/local/bin $0
    38.         echo -e "\n---- Install PostgreSQL ----"
    39.         sudo apt-get install postgresql
    40.        
    41.         echo -e "\n---- Install tool debian packages ----"
    42.         yes | sudo apt-get install bzr bzrtools python-pip
    43.  
    44.         echo -e "\n---- Install python debian packages ----"
    45.         yes | sudo apt-get install python-dateutil python-docutils python-feedparser \
    46.         python-gdata python-jinja2 python-ldap python-libxslt1 python-lxml python-mako \
    47.         python-mock python-openid python-psycopg2 python-psutil python-pybabel \
    48.         python-pychart python-pydot python-pyparsing python-reportlab python-simplejson \
    49.         python-tz python-unittest2 python-vatnumber python-vobject python-webdav \
    50.         python-werkzeug python-xlwt python-yaml python-zsi
    51.        
    52.         echo -e "\n---- Install python libraries ----"
    53.         sudo pip install gdata
    54.        
    55.         echo -e "\n---- Create system user ----"
    56.         sudo adduser --system --quiet --shell=/bin/bash --home=$OEADMIN_HOME --gecos 'OpenERP' --group $OEADMIN_USER
    57.         sudo mkdir /var/log/$OEADMIN_USER
    58.         sudo chown $OEADMIN_USER:$OEADMIN_USER /var/log/$OEADMIN_USER
    59.         sudo mkdir -p $OEADMIN_HOME/$OEADMIN_USER
    60.         sudo chown $OEADMIN_USER:$OEADMIN_USER $OEADMIN_HOME/$OEADMIN_USER
    61.     fi
    62.    
    63.     #--------------------------------------------------
    64.     # Create a new instance
    65.     #--------------------------------------------------
    66.     INSTANCE=$2
    67.     echo -e "\n==== Create instance $INSTANCE ===="
    68.  
    69.     echo "* Create instance directory"
    70.     mkdir -p $OEADMIN_HOME/$INSTANCE
    71.  
    72.     echo "* Create postgres user"
    73.     echo "* Please enter your postgres username:"
    74.     read postgres_username
    75.     echo "* Please enter your postgres password:"
    76.     read postgres_userpass
    77.     echo "* postgres username: $postgres_username - password: $postgres_userpass"
    78.     #sudo su -c "createuser --createdb --no-createrole --no-superuser openerp-$INSTANCE" postgres
    79.     #sudo -u postgres psql -c "ALTER USER openerpabc with PASSWORD 'newpassword'"
    80.     sudo -u postgres psql -c "CREATE USER $postgres_username WITH CREATEDB PASSWORD '$postgres_userpass'"
    81.  
    82.     if [ -d $OEADMIN_HOME/$INSTANCE/server ] ; then
    83.         echo "* Server directory exists: skipping"
    84.     else
    85.         echo -e "* Download files"
    86.         #Download nightly builds
    87.         mkdir -p $OEADMIN_HOME/downloads
    88.         wget --no-clobber http://nightly.openerp.com/7.0/nightly/src/openerp-7.0-latest.tar.gz -P $OEADMIN_HOME/downloads
    89.         echo -e "* Uncompress files"
    90.         rm -rf $OEADMIN_HOME/downloads/tmp
    91.         mkdir -p $OEADMIN_HOME/downloads/tmp
    92.         tar xf $OEADMIN_HOME/downloads/openerp-7.0-latest.tar.gz --directory=$OEADMIN_HOME/downloads/tmp
    93.         echo -e "* Install files"
    94.         mkdir -p $OEADMIN_HOME/$INSTANCE/server
    95.         mv $OEADMIN_HOME/downloads/tmp/`ls $OEADMIN_HOME/downloads/tmp/`/* $OEADMIN_HOME/$INSTANCE/server
    96.         #bzr co lp:openerp-web/7.0 $OEADMIN_HOME/$INSTANCE/web
    97.         #bzr co lp:openobject-server/7.0 $OEADMIN_HOME/$INSTANCE/server
    98.         #bzr co lp:openobject-addons/7.0 $OEADMIN_HOME/$INSTANCE/addons
    99.     fi
    100.    
    101.     echo -e "* Create server config file"
    102.     cp $OEADMIN_HOME/$INSTANCE/server/install/openerp-server.conf $OEADMIN_HOME/$INSTANCE --backup=numbered
    103.     sed -i s/"db_user = .*"/"db_user = $postgres_username"/g $OEADMIN_HOME/$INSTANCE/openerp-server.conf
    104.     sed -i s/"db_password = .*"/"db_password = $postgres_userpass"/g $OEADMIN_HOME/$INSTANCE/openerp-server.conf
    105.     sed -i s/"db_host = .*"/"db_host = localhost"/g $OEADMIN_HOME/$INSTANCE/openerp-server.conf
    106.     sed -i s/"db_port = .*"/"db_port = 5432"/g $OEADMIN_HOME/$INSTANCE/openerp-server.conf
    107.     #echo "logfile = /var/log/openerp/openerp-$INSTANCE.log" >> $OEADMIN_HOME/$INSTANCE/openerp-server.conf
    108.     #echo "addons_path=/opt/openerp/$INSTANCE/addons,/opt/openerp/$INSTANCE/web/addons" >> $OEADMIN_HOME/$INSTANCE/openerp-server.conf
    109.     echo "#!/bin/sh
    110. sudo -u $OEADMIN_USER $OEADMIN_HOME/$INSTANCE/server/openerp-server --config=$OEADMIN_HOME/$INSTANCE/openerp-server.conf \$*
    111. " > $OEADMIN_HOME/$INSTANCE/start.sh
    112.     chmod 755 $OEADMIN_HOME/$INSTANCE/start.sh
    113.     ;;
    114.  
    115. start)
    116.     INSTANCE=$2
    117.     shift 2
    118.     $OEADMIN_HOME/$INSTANCE/start.sh $*
    119.     ;;
    120.    
    121. esac
    122. echo "Done!"
    123.  
    124. # TODO IDEAS:  add options to
    125. # * set listening xmlrpc port
    126. # * start in background, see instances running, and stop instances
    127. # * set instance to autostart on boot
    128. # * provide better conf file template
    129. # * install from source
    130. # * install and add an additional addons directory to an existing instance
    131. # * update instance files
    132. # * remove instance
    133. # * rebuild and run tests on throw-away instances
    Tham khảo từ: http://www.serpentcs.com/serpentcs-...-installation-of-openerp-7-0-server-instances
    Quanvm and Nguyễn Trần Vũ like this.
  2. wickerfurniture New Member

    Dear bác, mình đọc bài thấy có nhiều kiến thức khá mới, cũng muốn hỏi thêm có cách nào tốt hơn, ngon hơn, hiệu quả hơn hay không, hay chỉ dừng lại ở những việc này thôi ạ! Cảm ơn bác!
  3. NHD New Member

    Ý của bạn là kiến thức của odoo hay của đoạn bash trên vậy? :))

Chia sẻ trang này