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.

182 lines
4.6 KiB

  1. #!/bin/bash
  2. set -eux # -x for verbose logging to juju debug-log
  3. ##
  4. ## Options (changeable thanks to ``/etc/charm/openerp.conf``)
  5. ##
  6. OPENERP_PASSWORD=${OPENERP_PASSWORD:-openerp_password}
  7. ## 0k git remote path
  8. GIT_0K_BASE=${GIT_0K_BASE:-"git.0k.io:/var/git"}
  9. ## 0k git remote options
  10. GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""}
  11. ## 0k git-sub setup options
  12. GIT_0K_SUB_SETUP_OPTIONS=${GIT_0K_SUB_SETUP_OPTIONS:-""}
  13. ## 0k git default checkout reference (for 0k-oe root package)
  14. GIT_0K_CHECKOUT_REF=${GIT_0K_CHECKOUT_REF:-"7.0/0k/dev/master"}
  15. ##
  16. ## Code
  17. ##
  18. apt-get install sudo libxml2-dev libxslt-dev libpq-dev libyaml-dev \
  19. zlib1g-dev libfreetype6-dev \
  20. libjpeg-dev libmysqlclient-dev -y --force-yes
  21. set +eux
  22. source /srv/virtualenv/default/bin/activate
  23. set -eux
  24. ## install deps for PIL compilations
  25. ## from http://www.sandersnewmedia.com/why/2012/04/16/installing-pil-virtualenv-ubuntu-1204
  26. if ! [ -e "/usr/lib/libjpeg.so" ]; then
  27. apt-get build-dep python-imaging -y --force-yes
  28. ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
  29. ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
  30. ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
  31. fi
  32. ## Installing PIL with our archive is safer.
  33. #pip install pil
  34. (
  35. cd /tmp &&
  36. scp "$GIT_0K_BASE"/archives/PIL-1.1.7.tar.gz . &&
  37. tar xvzf PIL-1.1.7.tar.gz &&
  38. cd PIL-1.1.7 &&
  39. python setup.py install
  40. )
  41. pip install lxml genshi==0.6 pyparsing==1.5.7 psycopg2 pyyaml reportlab mako \
  42. pywebdav==0.9.4 feedparser caldav pytz pydot \
  43. python-dateutil==1.5 cherrypy==3.1.2 formencode==1.2.2 \
  44. babel simplejson==2.0.9 python-openid mysql-python vatnumber \
  45. mock unittest2 fudge docutils jinja2 gdata sact.epoch \
  46. shyaml
  47. ## Install pychart... from our repo as :
  48. ## download link in PyPi is dead,
  49. ## and gna.org was down recently
  50. (
  51. scp "$GIT_0K_BASE/archives/PyChart-1.39.tar.gz" /tmp &&
  52. cd /tmp && tar xvzf PyChart*.tar.gz &&
  53. cd PyChart* &&
  54. python setup.py install
  55. )
  56. ## Install OOOP... from our git repo as:
  57. ## we have some bug correction and custom features
  58. if ! [ -d "/opt/apps/ooop" ]; then
  59. (
  60. cd /opt/apps &&
  61. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/ooop.git" &&
  62. cd /opt/apps/ooop &&
  63. git checkout 0k/prod/master &&
  64. ## beurk
  65. ln -sf /opt/apps/ooop/ooop.py /srv/virtualenv/default/lib/python2.7/ooop.py
  66. )
  67. fi
  68. ##
  69. ## Install 0k-oe
  70. ##
  71. (
  72. cd /opt/apps &&
  73. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/0k-oe.git &&
  74. cd /opt/apps/0k-oe &&
  75. git checkout "$GIT_0K_CHECKOUT_REF" &&
  76. git sub setup $GIT_0K_SUB_SETUP_OPTIONS -r
  77. )
  78. adduser --system --home=/var/lib/openerp --group openerp
  79. ## XXXvlab: warning password in charm !!
  80. cp -i etc/openerp-server.conf /etc/
  81. sed -ri "s/%%PASSWORD%%/$OPENERP_PASSWORD/g" /etc/openerp-server.conf
  82. cp -i etc/init.d/openerp-server /etc/init.d/
  83. chown openerp /etc/openerp-server.conf
  84. chmod 600 /etc/openerp-server.conf
  85. chown openerp /etc/init.d/openerp-server
  86. update-rc.d openerp-server defaults
  87. mkdir /var/log/openerp
  88. touch /var/log/openerp/openerp-server.log
  89. chown openerp /var/log/openerp -R
  90. ## Install add-ons
  91. ## make a better way for installing add-ons
  92. #addons_path=/opt/apps/openobject-addons/0k
  93. #if ! [ -d "$addons_path" ]; then
  94. # mkdir -p $addons_path
  95. # for addons in $(/var/git/list-addons 0k/dev/master | grep ^0k); do
  96. # git clone -s /var/git/$addons /opt/apps/openobject-addons/${addons%.git}
  97. # (cd /opt/apps/openobject-addons/${addons%.git}
  98. # git checkout 6.1/0k/prod/master ||
  99. # git checkout 0k/prod/master ||
  100. # git checkout 0k/dev/master ||
  101. # git checkout 6.1/simplee/prod/master ||
  102. # git checkout simplee/prod/master ||
  103. # git checkout simplee/dev/master ||
  104. # git checkout master
  105. # )
  106. # done
  107. #else
  108. # echo 'WARNING: skipping modules installation as directory was already existent !'
  109. #fi
  110. ## Install werkzeug from github last version
  111. ## because last PyPi version is 8.4 and we need the 9.0+
  112. (
  113. cd /tmp &&
  114. git clone https://github.com/mitsuhiko/werkzeug.git &&
  115. cd werkzeug &&
  116. python setup.py install
  117. )
  118. ##
  119. ## Linking with external filestore !
  120. ##
  121. (
  122. cd /opt/apps/0k-oe/openobject-server/openerp &&
  123. ln -sf /var/openerp-filestore filestore &&
  124. cd /var/openerp-filestore &&
  125. chown openerp .
  126. )
  127. ##
  128. ## Install 0k-manage for the handy oe command
  129. ##
  130. (
  131. cd /opt/apps &&
  132. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" &&
  133. cd /opt/apps/0k-manage &&
  134. git checkout 0k/prod/master &&
  135. ## beurk
  136. ln -sf "/opt/apps/0k-manage/src/bin/oe" "/usr/local/bin/oe"
  137. )